Professional Documents
Culture Documents
18-CP-01
Section: Alpha
Solution:
Output:
Question no 2: Design a register file, consisting of 32, 8-bit
registers, include RW 1-bit signal to differentiate between the
operations.
#2 RF_Din = 8'b00000010;
RF_Add = 5'b00001;
#2 RF_Din = 8'b00000011;
RF_Add = 5'b00010;
#2 RF_Din = 8'b00000100;
RF_Add = 5'b00011;
#2 RF_RW = 1'b0;
RF_Add = 5'b00000;
#2 RF_RW = 1'b0;
RF_Add = 5'b00000;
#2 RF_Add = 5'b00001;
#2 RF_Add = 5'b00010;
#2 RF_Add = 5'b00011;
end
endmodule
Output:
Solution :
CODE: Test Bench:
RF_Din = 8'b00000010;
RF_Add = 5'b00001;
#2
RF_Din = 8'b00000011;
RF_Add = 5'b00010;
#2
RF_Din = 8'b00000100;
RF_Add = 5'b00011;
#2
RF_RW = 1'b0;
RF_Add = 5'b00000;
#2
RF_RW = 1'b0;
RF_Add = 5'b00000;
#2
RF_Add = 5'b00001;
#2
RF_Add = 5'b00010;
#2
RF_Add = 5'b00011;
end
endmodule
in (RF_Din ) ,
.RF_out (RF_out ) );
initial
begin
RF_RW = 1'b1;
RF_Din = 8'b00000001;
RF_Add = 5'b00000;
#2
RF_Din = 8'b00000010;
RF_Add = 5'b00001;
#2
RF_Din = 8'b00000011;
RF_Add = 5'b00010;
#2
RF_Din = 8'b00000100;
RF_Add = 5'b00011;
#2
RF_RW = 1'b0;
RF_Add = 5'b00000;
#2
RF_RW = 1'b0;
RF_Add = 5'b00000;
#2
RF_Add = 5'b00001;
#2
RF_Add = 5'b00010;
#2
RF_Add = 5'b00011;
end
endmodule
Output: