summaryrefslogtreecommitdiff
path: root/gpr/v0.1/test_gpr_register.v
diff options
context:
space:
mode:
authordianshi <dianshi@main.lv>2022-01-19 22:03:50 +0000
committerdianshi <dianshi@main.lv>2022-01-19 22:03:50 +0000
commit8661ed2084e8d50ef19a2827484fefd07c4f20e1 (patch)
tree8a516be79571d1ef46ecabe676ffa7ce17c6ffab /gpr/v0.1/test_gpr_register.v
parentf3a300ce5927cad9ecf02821b3be007f9d2af22b (diff)
downloadcpu8_v-8661ed2084e8d50ef19a2827484fefd07c4f20e1.tar.gz
cpu8_v-8661ed2084e8d50ef19a2827484fefd07c4f20e1.zip
Added general purpose memory
Diffstat (limited to 'gpr/v0.1/test_gpr_register.v')
-rw-r--r--gpr/v0.1/test_gpr_register.v89
1 files changed, 89 insertions, 0 deletions
diff --git a/gpr/v0.1/test_gpr_register.v b/gpr/v0.1/test_gpr_register.v
new file mode 100644
index 0000000..bad146b
--- /dev/null
+++ b/gpr/v0.1/test_gpr_register.v
@@ -0,0 +1,89 @@
+`timescale 1ns/1ps
+
+module test_gpr_register;
+
+ reg clk;
+
+ reg reg_write_en;
+ reg [2:0]reg_write_dest;
+ reg [15:0]reg_write_data;
+
+ reg [2:0]reg_read_addr_1;
+ reg [15:0]reg_read_data_1;
+
+ reg [2:0]reg_read_addr_2;
+ reg [15:0]reg_read_data_2;
+
+
+gpr_register gpr(
+ .clk(clk),
+ .reg_write_en(reg_write_en),
+ .reg_write_dest(reg_write_dest),
+ .reg_write_data(reg_write_data),
+ .reg_read_addr_1(reg_read_addr_1),
+ .reg_read_data_1(reg_read_data_1),
+ .reg_read_addr_2(reg_read_addr_2),
+ .reg_read_data_2(reg_read_data_2)
+);
+initial begin
+ $display("Start testing register");
+ $dumpfile("test_gpr_register.vcd");
+ $dumpvars(0,test_gpr_register);
+
+ clk=0;
+ reg_read_addr_1=0;
+ reg_read_addr_2=0;
+ reg_write_dest=0;
+ reg_write_en=0;
+
+ #10
+ clk=1;
+ reg_write_dest=1;
+ reg_write_data=16'hAA;
+ reg_write_en=1;
+
+ #10
+ clk=1;
+
+ #10
+ clk=0;
+ reg_write_dest=2;
+ reg_write_data=16'hBB;
+ reg_write_en=1;
+
+ #10
+ clk=1;
+
+ #10
+ clk=0;
+ reg_write_en=0;
+ reg_read_addr_1=0;
+ reg_read_addr_2=1;
+
+ //#10
+ //clk = 1;
+
+ //#10
+ //clk = 0;
+
+ #10
+ clk=1;
+ reg_read_addr_1=1;
+ reg_read_addr_2=2;
+
+ #10
+ clk = 0;
+
+ #10
+ clk = 1;
+
+ #10
+ clk = 0;
+
+end
+
+initial begin
+ $monitor("At time=%t",$time);
+end
+
+endmodule \ No newline at end of file