Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please provide a code solutiontionwhy does my simulation have errors module outputter ( input [ 3 : 0 ] state, input [ 1 5 :
please provide a code solutiontionwhy does my simulation have errors module outputter input : state, input : instruction, output reg : Rin, output reg : Rout, output reg : addSub ; reg : triReg, RegEnable; Internal wires for onehot encoding wire : triStateWires, enableWires; Instantiate oneHot modules oneHot writeDemuxselectRegEnableouttriStateWires; oneHot readDemuxselecttriRegoutenableWires; State machine to control Rin, Rout, and addSub always @state or instruction begin triReg b; Default no output enable RegEnable b; Default no register enable addSub b; Default add operation casestate b: begin Load triReg b; Data triReg enable RegEnable instruction:; Rxin enable end b: begin Move triReg instruction:; Rxout RegEnable instruction:; Ryin end b: begin AddSubXor first state triReg instruction:; Rxout RegEnable b; Ain end b: begin Add middle state triReg instruction:; Ryout RegEnable b; Gin addSub b; add end b: begin Sub middle state triReg instruction:; Ryout RegEnable b; Gin addSub b; sub end b: begin Xor middle state triReg instruction:; Ryout RegEnable b; Gin addSub b; xor end b: begin AddSubXor last state triReg b; Gout RegEnable instruction:; Ryin end default: begin triReg b; RegEnable b; addSub b; end endcase end Assign outputs from the oneHot module results always @ begin Rin triStateWires; Rout enableWires; end endmodule module ControlCircuit input clk input rst input : instruction, output : Rin, output : Rout, output : addSub ; wire : currentstate; wire : nextstate; reg : statereg; Instantiate NextState FSM NextState fsm instructioninstruction currentstatecurrentstate nextstatenextstate ; outputter asd statecurrentstate instructioninstruction RinRin RoutRout addSubaddSub ; Register to hold the current state always @posedge clk or posedge rst begin if rst statereg b; Initial state else statereg nextstate; end assign currentstate statereg; endmodule module tristatebuffer input : a output reg : b input enable ; always @ begin if enable b a; else b bZ; tristate end endmodule module oneHotselect out; input : select; output reg : out; always @select begin out b; Default value to avoid latches case select b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; b : out b; endcase end endmodule module NextState input : instruction, input : currentstate, output reg : nextstate ; always @ begin case currentstate b: begin case instruction: b: nextstate b; Load b: nextstate b; Move b: nextstate b; AddSubXor first state b: nextstate b; AddSubXor first state b: nextstate b; AddSubXor first state default: nextstate b; Default state endcase end b: nextstate b; Return to initial after Load b: n tableMsgstbprocessorckhsqrtLtbprocessorrsthtbprocessorinstrhsqrtsqrt
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started
please provide a code solutiontionwhy does my simulation have errors module outputter
input : state,
input : instruction,
output reg : Rin,
output reg : Rout,
output reg : addSub
;
reg : triReg, RegEnable;
Internal wires for onehot encoding
wire : triStateWires, enableWires;
Instantiate oneHot modules
oneHot writeDemuxselectRegEnableouttriStateWires;
oneHot readDemuxselecttriRegoutenableWires;
State machine to control Rin, Rout, and addSub
always @state or instruction begin
triReg b; Default no output enable
RegEnable b; Default no register enable
addSub b; Default add operation
casestate
b: begin Load
triReg b; Data triReg enable
RegEnable instruction:; Rxin enable
end
b: begin Move
triReg instruction:; Rxout
RegEnable instruction:; Ryin
end
b: begin AddSubXor first state
triReg instruction:; Rxout
RegEnable b; Ain
end
b: begin Add middle state
triReg instruction:; Ryout
RegEnable b; Gin
addSub b; add
end
b: begin Sub middle state
triReg instruction:; Ryout
RegEnable b; Gin
addSub b; sub
end
b: begin Xor middle state
triReg instruction:; Ryout
RegEnable b; Gin
addSub b; xor
end
b: begin AddSubXor last state
triReg b; Gout
RegEnable instruction:; Ryin
end
default: begin
triReg b;
RegEnable b;
addSub b;
end
endcase
end
Assign outputs from the oneHot module results
always @ begin
Rin triStateWires;
Rout enableWires;
end
endmodule
module ControlCircuit
input clk
input rst
input : instruction,
output : Rin,
output : Rout,
output : addSub
;
wire : currentstate;
wire : nextstate;
reg : statereg;
Instantiate NextState FSM
NextState fsm
instructioninstruction
currentstatecurrentstate
nextstatenextstate
;
outputter asd
statecurrentstate
instructioninstruction
RinRin
RoutRout
addSubaddSub
;
Register to hold the current state
always @posedge clk or posedge rst begin
if rst
statereg b; Initial state
else
statereg nextstate;
end
assign currentstate statereg;
endmodule
module tristatebuffer
input : a
output reg : b
input enable
;
always @
begin
if enable
b a;
else
b bZ; tristate
end
endmodule
module oneHotselect out;
input : select;
output reg : out;
always @select begin
out b; Default value to avoid latches
case select
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
b : out b;
endcase
end
endmodule
module NextState
input : instruction,
input : currentstate,
output reg : nextstate
;
always @ begin
case currentstate
b: begin
case instruction:
b: nextstate b; Load
b: nextstate b; Move
b: nextstate b; AddSubXor first state
b: nextstate b; AddSubXor first state
b: nextstate b; AddSubXor first state
default: nextstate b; Default state
endcase
end
b: nextstate b; Return to initial after Load
b: n
tableMsgstbprocessorckhsqrtLtbprocessorrsthtbprocessorinstrhsqrtsqrt
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started