Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why doesn't my code load anything onto the registers. module Control _ Circuit ( input clk , input rst , input [ 1 5 :
Why doesn't my code load anything onto the registers.
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
;
Instantiate oneHot modules to generate Rin and Rout
oneHot ringen
selectnextstate
outRin
;
oneHot routgen
selectcurrentstate
outRout
;
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 datapath clk rst instruction, enableRegistersin, enableRegistersout, bus, myWire, addSub;
input clk rst;
input : instruction;
input : enableRegistersin;
input : enableRegistersout;
input : addSub;
output : bus;
output : myWire;
genvar i;
generate
for i ; i ; i i begin: registerGeneration
Register RR
myreg regin
clockclk
xbus
enableenableRegistersini
ymyWirei
rstrst
;
tristatebuffer regout
amyWirei
enableenableRegistersouti
bbus
;
end
endgenerate
Register A
myreg regA
clockclk
xbus
enableenableRegistersin
ymyWire
rstrst
;
ALU
aLU alu
amyWire
bbus
addSubaddSub: Assuming the ALU takes opcode from instruction
resultmyWire
;
Register G
myreg regG
clockclk
xmyWire
enableenableRegistersin
ymyWire
rstrst
;
Tristate buffer for RegG output
tristatebuffer regGout
amyWire
enableenableRegistersout
bbus
;
endmodule
module NextState
input : instruction,
input : currentstate,
output reg : nextstate
;
always @ begin
case currentstate
b: begin
case instruction:
b: nextstate b;
b: nextstate b;
b: nextstate b;
b: nextstate b;
b: nextstate b;
default: nextstate b; default state if no match
endcase
end
b: nextstate b;
b: nextstate b;
b: nextstate b;
b: nextstate b;
b: nextstate b;
b: nextstate b;
default: nextstate b; default state if no match
endcase
end
endmodule
module outputter
input : state,
input : instruction,
output reg : Rin,
output reg : Rout,
output reg : addSub
;
reg : triReg, RegEnable;
Wires for oneHot module outputs
wire : triStateWire, triRegEnableWire;
Instantiate oneHot modules
oneHot writeDemux
selecttriReg
outtriStateWire
;
oneHot readDemux
selectRegEnable
outtriRegEnableWire
;
Assignments to the outputs
always @state or instruction begin
casestate
b: begin load
triReg b; No output enable in this state
RegEnable instruction:; Rxin enable
end
b: begin load
triReg b; Data triReg enable
RegEnable b; No register enable in this state
end
b: begin move
triReg instruction:; Rxout
RegEnable instruction:; Ryin
end
b: begin add sub xor
triReg instruction:; Rxout
RegEnable b; Ain
end
b: begin add sub xor
triReg instruction:; Ryout
RegEnable b; Gin
if instruction:b
addSub b; sub
else if instruction:b
addSub b; xor
else
addSub b; add
end
b: begin add sub xor
triReg b; Gout
RegEnable instruction:; Ryin
addSu
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started