Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I wish to incorporate a onehot decoder for my registers so that only one register is accessing the bus at a time. I also wish
I wish to incorporate a onehot decoder for my registers so that only one register is accessing the bus at a time. I also wish to introduce a memory system that uses a program counter to navigate through my memory. The memory is an address system that stores each instruction code.
This is what my current code looks like
module datapath
input clk
input rst
input : instruction,
input : addSub
;
Register enables and tristate buffers
wire : Rout;
wire : bus;
wire : myWire :;
Control circuit controlsignal
controlcircuit controlsignal
clkclk
rstrst
instructioninstruction
regenableenableRegisterin
trienableenableRegistersout
;
Register Generation
genvar i;
generate
for i ; i ; i i begin: registerGeneration
Registers
myreg regin
clockclk
xbus
enableRini
ymyWirei
rstrst
;
Tristate buffer
tristatebuffer regout
amyWirei
enableRouti
bbus
;
end
Register A
myreg regA
clockclk
xbus
enableRin
ymyWire
rstrst
;
ALU
ALU alu
amyWire
bbus
addSubaddSub
resultmyWire
;
Register G
myreg regG
clockclk
xmyWire
enableRin
ymyWire
rstrst
;
Tristate buffer for RegG output
tristatebuffer regGout
amyWire
enableRout
bbus
;
endgenerate
endmodule
module myreg
input clock,
input : x
input enable,
output reg : y
input rst
;
always @posedge clock or posedge rst
begin
if rst
y b;
else if enable
y x;
end
endmodule
module ALU
input : a
input : b
input : addSub,
output reg : result
;
always @
begin
case addSub
b: result a b; add
b: result a b; subtract
b: result a b; xor
default: result b; default to
endcase
end
endmodule
module NextState instructioncurrentstate,nextstate;
input :instruction;
input :currentstate;
output :reg nextstate;
casecurrentstate
b:begin
caseinstruction:
b: nextstateb;
b: nextstateb;
b: nextstateb;
b: nextstateb;
b: nextstateb;
end
b: nextstateb;
b: nextstateb;
b: nextstateb;
b: nextstateb;
b: nextstateb;
b: nextstateb;
endmodule
module tristatebuffer
input : a
output reg : b
input enable
;
always @
begin
if enable
b a;
else
b bZ; tristate
end
endmodule
module tristateenablestate instruction, Rin, Rout, addSub;
input : state;
input : instruction;
input : branch;
output : Rin, Rout;
output addSub;
wire: triReg, triRegEnable
oneHot writeDemuxselecttriRegouttriStateWire
GoutRout
oneHot readDemuxselectRegEnableouttriRegEnableWire
GinAin,RinRin
always@state begin
casestate
: beginload
triReg Data trireg enable
RegEnable instruction:Rxin enable
branch b
end
: beginload
triReg Data trireg enable
branch b
end
: beginmove
triReg instruction:Rxout
RegEnable instruction:Ryin
branch
end
: beginadd sub xor
triReg instruction:Rxout
RegEnable Ain
end
: begin add sub xor
triReg instruction:
RegEnable
if instruction:b
addSub b;
else if instruction:b
addSub b;
else
addSub b;
end
: begin add sub xor
triReg
RegEnable instruction:
module instructionmemoryaddress data;
input : address;
output : data;
have to grab instruction then grab number
load
move
add
XOR
REG
REG
always @address begin hard coded instruction not write to memory
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