In: Electrical Engineering
Create a circuit that allows the client to add numbers one by one into a register file (8 four-bit registers) by inputting: 1) the number itsself 2) the memory location The circuit can be logic gates OR verilog code. whichever you prefer! Thank you and I will rate!
We would be creating a Design that allows the client / user to write number one by one into a register file having 8 four-bit registers.
We are having 8 memory locations. So, bits required to represent 8 memory locations = log2(8) = log2(23) = 3log2(2) = 3.
The Design has DataIN (Number) as a 4 bit input, Address (Memory Location) as a 3 bit input, a Read/Write' input signal for reading/writing from/into the Register memory, CLK (Clock) signal as a clocking source for sequential stuffs and a DataOUT signal as a 4 bit output for reading from the Memory.
The Block Representation of the Design is shown below:
Verilog Implementation of this Design is given below:
module memory (output [3:0] DataOUT, input [3:0] DataIN, input [2:0] Address, input CLK, input RW); // module definition
reg [3:0] mem [2:0]; // register bank with 8 locations of 4 bits each
always @ (posedge CLK) // reading or writing will occur at
positive edges of clock
begin
if (RW) DataOUT <= mem[Address]; // if
Read/Write' is HIGH, memory will be read to DataOUT
else mem[Address] <= DataIN; // if Read/Write' is
LOW, memory will be written from DataIN
end
endmodule
If you find the solution having any issue, drop down a comment and I'll be happy to solve the same. Have a good day.