diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-12-30 23:04:27 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-12-30 23:04:27 +0200 |
| commit | 56a97a389b9c192411ea43d199ad56e4753dba71 (patch) | |
| tree | 17fc0deb542d24683ba3b9edc403b049e07fa1d5 /atk16_fpga/cu_tb.v | |
| parent | 9b073ffbd7f9e7262bc4cb2e5991ceb6bc50cb54 (diff) | |
Move sram out of cu module
Diffstat (limited to 'atk16_fpga/cu_tb.v')
| -rw-r--r-- | atk16_fpga/cu_tb.v | 219 |
1 files changed, 121 insertions, 98 deletions
diff --git a/atk16_fpga/cu_tb.v b/atk16_fpga/cu_tb.v index ec23c65..8c8ec10 100644 --- a/atk16_fpga/cu_tb.v +++ b/atk16_fpga/cu_tb.v @@ -7,10 +7,33 @@ module cu_tb(); reg clk, rst; reg [3:0] int_lines; + wire sram_cs_n, sram_wr_n, sram_rd_n; + wire [17:0] sram_addr; + wire [15:0] sram_data_in; + wire [15:0] sram_data_out; + sram sram_inst( + .cs_n(sram_cs_n), + .wr_n(sram_wr_n), + .rd_n(sram_rd_n), + .addr(sram_addr), + .data_in(sram_data_in), + .data_out(sram_data_out) + ); + + wire [15:0] sram_addr_short; + assign sram_addr = { 2'b0, sram_addr_short }; + cu dut( .clk(clk), .rst(rst), - .int_lines(int_lines) + .int_lines(int_lines), + + .sram_cs_n(sram_cs_n), + .sram_wr_n(sram_wr_n), + .sram_rd_n(sram_rd_n), + .sram_addr(sram_addr_short), + .sram_in(sram_data_in), + .sram_out(sram_data_out) ); // Clock generation @@ -30,12 +53,12 @@ module cu_tb(); #10 // Wait for reset phase to finish // set up halt instruction at PC = 1, used by all tests - dut.sram_inst.mem[1] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[1] = { 4'b1111, 12'd0 }; // HLT // test ALR dut.regbank[0] = 16'd10; dut.regbank[1] = 16'd20; - dut.sram_inst.mem[0] = { 4'b0000, 3'd2, 3'd0, 3'd1, 3'd0 }; // ALR RC, RA, RB, S=PLUS + sram_inst.mem[0] = { 4'b0000, 3'd2, 3'd0, 3'd1, 3'd0 }; // ALR RC, RA, RB, S=PLUS expected = 16'd30; #200 if (dut.regbank[2] == expected) begin @@ -48,7 +71,7 @@ module cu_tb(); // test ALI dut.regbank[0] = 16'd10; - dut.sram_inst.mem[0] = { 4'b0001, 3'd2, 3'd0, 3'd7, 3'd0 }; // ALI RC, RA, 7, S=PLUS + sram_inst.mem[0] = { 4'b0001, 3'd2, 3'd0, 3'd7, 3'd0 }; // ALI RC, RA, 7, S=PLUS expected = 16'd17; #200 if (dut.regbank[2] == expected) begin @@ -60,9 +83,9 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDR, absolute addressing - dut.sram_inst.mem[16'd100] = 16'hffff; + sram_inst.mem[16'd100] = 16'hffff; dut.regbank[1] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd1, 1'd1 }; // LDR RA, RB, absolute, direct + sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd1, 1'd1 }; // LDR RA, RB, absolute, direct expected = 16'hffff; #200 if (dut.regbank[0] == expected) begin @@ -74,9 +97,9 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDR, relative addressing - dut.sram_inst.mem[16'd10] = 16'hffff; + sram_inst.mem[16'd10] = 16'hffff; dut.regbank[1] = 16'd10; - dut.sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd0, 1'd1 }; // LDR RA, RB, relative, direct + sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd0, 1'd1 }; // LDR RA, RB, relative, direct expected = 16'hffff; #200 if (dut.regbank[0] == expected) begin @@ -88,10 +111,10 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDR, absolute addressing, indirect - dut.sram_inst.mem[16'd100] = 16'd200; - dut.sram_inst.mem[16'd200] = 16'hffff; + sram_inst.mem[16'd100] = 16'd200; + sram_inst.mem[16'd200] = 16'hffff; dut.regbank[1] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd1, 1'd0 }; // LDR RA, RB, absolute, indirect + sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd1, 1'd0 }; // LDR RA, RB, absolute, indirect expected = 16'hffff; #200 if (dut.regbank[0] == expected) begin @@ -103,10 +126,10 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDR, relative addressing, indirect - dut.sram_inst.mem[16'd10] = 16'd20; - dut.sram_inst.mem[16'd20] = 16'hffff; + sram_inst.mem[16'd10] = 16'd20; + sram_inst.mem[16'd20] = 16'hffff; dut.regbank[1] = 16'd10; - dut.sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd0, 1'd0 }; // LDR RA, RB, relative, indirect + sram_inst.mem[16'd0] = { 4'b0010, 3'd0, 3'd1, 4'd0, 1'd0, 1'd0 }; // LDR RA, RB, relative, indirect expected = 16'hffff; #200 if (dut.regbank[0] == expected) begin @@ -120,13 +143,13 @@ module cu_tb(); // test STR, absolute addressing, direct dut.regbank[0] = 16'hfafa; dut.regbank[1] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd1, 1'd1 }; // STR RB, RA, absolute, direct + sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd1, 1'd1 }; // STR RB, RA, absolute, direct expected = 16'hfafa; - #200 if (dut.sram_inst.mem[16'd100] == expected) begin + #200 if (sram_inst.mem[16'd100] == expected) begin $display("\033[0;32m[PASS]\033[0m STR direct absolute ok"); end else begin - $display("\033[0;31m[FAIL]\033[0m STR direct absolute not working, memory location contains %04h, expected %04h", dut.sram_inst.mem[16'd100], expected); + $display("\033[0;31m[FAIL]\033[0m STR direct absolute not working, memory location contains %04h, expected %04h", sram_inst.mem[16'd100], expected); failed = 1; end rst = 1; #10 rst = 0; #10 @@ -134,13 +157,13 @@ module cu_tb(); // test STR, relative addressing, direct dut.regbank[0] = 16'hafaf; dut.regbank[1] = 16'd10; - dut.sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd0, 1'd1 }; // STR RB, RA, relative, direct + sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd0, 1'd1 }; // STR RB, RA, relative, direct expected = 16'hafaf; - #200 if (dut.sram_inst.mem[16'd10] == expected) begin + #200 if (sram_inst.mem[16'd10] == expected) begin $display("\033[0;32m[PASS]\033[0m STR direct relative ok"); end else begin - $display("\033[0;31m[FAIL]\033[0m STR direct relative not working, memory location contains %04h, expected %04h", dut.sram_inst.mem[16'd10], expected); + $display("\033[0;31m[FAIL]\033[0m STR direct relative not working, memory location contains %04h, expected %04h", sram_inst.mem[16'd10], expected); failed = 1; end rst = 1; #10 rst = 0; #10 @@ -148,14 +171,14 @@ module cu_tb(); // test STR, absolute addressing, indirect dut.regbank[0] = 16'hfafa; dut.regbank[1] = 16'd100; - dut.sram_inst.mem[16'd100] = 16'd200; - dut.sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd1, 1'd0 }; // STR RB, RA, absolute, indirect + sram_inst.mem[16'd100] = 16'd200; + sram_inst.mem[16'd0] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd1, 1'd0 }; // STR RB, RA, absolute, indirect expected = 16'hfafa; - #200 if (dut.sram_inst.mem[16'd200] == expected) begin + #200 if (sram_inst.mem[16'd200] == expected) begin $display("\033[0;32m[PASS]\033[0m STR indirect absolute ok"); end else begin - $display("\033[0;31m[FAIL]\033[0m STR indirect absolute not working, memory location contains %04h, expected %04h", dut.sram_inst.mem[16'd200], expected); + $display("\033[0;31m[FAIL]\033[0m STR indirect absolute not working, memory location contains %04h, expected %04h", sram_inst.mem[16'd200], expected); failed = 1; end rst = 1; #10 rst = 0; #10 @@ -163,21 +186,21 @@ module cu_tb(); // test STR, relative addressing, indirect dut.regbank[0] = 16'hafaf; dut.regbank[1] = -16'd10; - dut.sram_inst.mem[16'd10] = 16'd20; - dut.sram_inst.mem[16'd20] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd0, 1'd0 }; // STR RB, RA, relative, indirect + sram_inst.mem[16'd10] = 16'd20; + sram_inst.mem[16'd20] = { 4'b0011, 3'd0, 3'd1, 4'd0, 1'd0, 1'd0 }; // STR RB, RA, relative, indirect dut.pc = 16'd20; expected = 16'hafaf; - #200 if (dut.sram_inst.mem[16'd20] == expected) begin + #200 if (sram_inst.mem[16'd20] == expected) begin $display("\033[0;32m[PASS]\033[0m STR indirect relative ok"); end else begin - $display("\033[0;31m[FAIL]\033[0m STR indirect relative not working, memory location contains %04h, expected %04h", dut.sram_inst.mem[16'd20], expected); + $display("\033[0;31m[FAIL]\033[0m STR indirect relative not working, memory location contains %04h, expected %04h", sram_inst.mem[16'd20], expected); failed = 1; end rst = 1; #10 rst = 0; #10 // test LDI, absolute addressing, direct - dut.sram_inst.mem[16'd0] = { 4'b0100, 3'd0, 7'd123, 1'd1, 1'd1 }; // LDI RA, 1, absolute, direct + sram_inst.mem[16'd0] = { 4'b0100, 3'd0, 7'd123, 1'd1, 1'd1 }; // LDI RA, 1, absolute, direct expected = 16'd123; #200 if (dut.regbank[0] == expected) begin @@ -189,7 +212,7 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDI, relative addressing, direct - dut.sram_inst.mem[16'd150] = { 4'b0100, 3'd0, -7'd20, 1'd0, 1'd1 }; // LDI RA, 1, relative, direct + sram_inst.mem[16'd150] = { 4'b0100, 3'd0, -7'd20, 1'd0, 1'd1 }; // LDI RA, 1, relative, direct dut.pc = 16'd150; expected = 16'd130; @@ -202,8 +225,8 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDI, absolute addressing, indirect - dut.sram_inst.mem[16'd0] = { 4'b0100, 3'd0, 7'd50, 1'd1, 1'd0 }; // LDI RA, 1, absolute, indirect - dut.sram_inst.mem[16'd50] = 16'd123; + sram_inst.mem[16'd0] = { 4'b0100, 3'd0, 7'd50, 1'd1, 1'd0 }; // LDI RA, 1, absolute, indirect + sram_inst.mem[16'd50] = 16'd123; expected = 16'd123; #200 if (dut.regbank[0] == expected) begin @@ -215,8 +238,8 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test LDI, relative addressing, indirect - dut.sram_inst.mem[16'd150] = { 4'b0100, 3'd0, -7'd20, 1'd0, 1'd0 }; // LDI RA, 1, relative, indirect - dut.sram_inst.mem[16'd130] = 16'd123; + sram_inst.mem[16'd150] = { 4'b0100, 3'd0, -7'd20, 1'd0, 1'd0 }; // LDI RA, 1, relative, indirect + sram_inst.mem[16'd130] = 16'd123; dut.pc = 16'd150; expected = 16'd123; @@ -230,8 +253,8 @@ module cu_tb(); // test JPR, absolute addressing, direct dut.regbank[0] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0101, 1'd1, 1'd1, 3'd0, 7'd0 }; // JPR RA, absolute, direct - dut.sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0101, 1'd1, 1'd1, 3'd0, 7'd0 }; // JPR RA, absolute, direct + sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT expected = 16'd101; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -244,8 +267,8 @@ module cu_tb(); // test JPR, relative addressing, direct dut.regbank[0] = 16'd50; - dut.sram_inst.mem[16'd0] = { 4'b0101, 1'd0, 1'd1, 3'd0, 7'd0 }; // JPR RA, relative, direct - dut.sram_inst.mem[16'd50] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0101, 1'd0, 1'd1, 3'd0, 7'd0 }; // JPR RA, relative, direct + sram_inst.mem[16'd50] = { 4'b1111, 12'd0 }; // HLT expected = 16'd51; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -258,9 +281,9 @@ module cu_tb(); // test JPR, absolute addressing, indirect dut.regbank[0] = 16'd100; - dut.sram_inst.mem[16'd100] = 16'd200; - dut.sram_inst.mem[16'd0] = { 4'b0101, 1'd1, 1'd0, 3'd0, 7'd0 }; // JPR RA, absolute, indirect - dut.sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd100] = 16'd200; + sram_inst.mem[16'd0] = { 4'b0101, 1'd1, 1'd0, 3'd0, 7'd0 }; // JPR RA, absolute, indirect + sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT expected = 16'd201; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -273,9 +296,9 @@ module cu_tb(); // test JPR, relative addressing, indirect dut.regbank[0] = 16'd50; - dut.sram_inst.mem[16'd60] = 16'd100; - dut.sram_inst.mem[16'd10] = { 4'b0101, 1'd0, 1'd0, 3'd0, 7'd0 }; // JPR RA, relative, indirect - dut.sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd60] = 16'd100; + sram_inst.mem[16'd10] = { 4'b0101, 1'd0, 1'd0, 3'd0, 7'd0 }; // JPR RA, relative, indirect + sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT dut.pc = 16'd10; expected = 16'd101; // PC ends up at &HLT + 1 @@ -288,8 +311,8 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test JPI, absolute addressing, direct - dut.sram_inst.mem[16'd0] = { 4'b0110, 1'd1, 1'd1, 10'd123 }; // JPI 123, absolute, direct - dut.sram_inst.mem[16'd123] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0110, 1'd1, 1'd1, 10'd123 }; // JPI 123, absolute, direct + sram_inst.mem[16'd123] = { 4'b1111, 12'd0 }; // HLT expected = 16'd124; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -301,8 +324,8 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test JPI, relative addressing, direct - dut.sram_inst.mem[16'd30] = { 4'b0110, 1'd0, 1'd1, -10'd20 }; // JPI -20, relative, direct - dut.sram_inst.mem[16'd10] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd30] = { 4'b0110, 1'd0, 1'd1, -10'd20 }; // JPI -20, relative, direct + sram_inst.mem[16'd10] = { 4'b1111, 12'd0 }; // HLT dut.pc = 16'd30; expected = 16'd11; // PC ends up at &HLT + 1 @@ -315,9 +338,9 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test JPI, absolute addressing, indirect - dut.sram_inst.mem[16'd10] = { 4'b0110, 1'd1, 1'd0, 10'd50 }; // JPI 50, absolute, indirect - dut.sram_inst.mem[16'd50] = 16'd123; - dut.sram_inst.mem[16'd123] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd10] = { 4'b0110, 1'd1, 1'd0, 10'd50 }; // JPI 50, absolute, indirect + sram_inst.mem[16'd50] = 16'd123; + sram_inst.mem[16'd123] = { 4'b1111, 12'd0 }; // HLT dut.pc = 16'd10; expected = 16'd124; // PC ends up at &HLT + 1 @@ -330,9 +353,9 @@ module cu_tb(); rst = 1; #10 rst = 0; #10 // test JPI, relative addressing, indirect - dut.sram_inst.mem[16'd30] = { 4'b0110, 1'd0, 1'd0, -10'd20 }; // JPI -20, relative, indirect - dut.sram_inst.mem[16'd10] = 16'd50; - dut.sram_inst.mem[16'd50] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd30] = { 4'b0110, 1'd0, 1'd0, -10'd20 }; // JPI -20, relative, indirect + sram_inst.mem[16'd10] = 16'd50; + sram_inst.mem[16'd50] = { 4'b1111, 12'd0 }; // HLT dut.pc = 16'd30; expected = 16'd51; // PC ends up at &HLT + 1 @@ -347,10 +370,10 @@ module cu_tb(); // test BRR, absolute addressing, direct, true branch dut.regbank[0] = 16'd100; dut.regbank[2] = 16'd110; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd1, 2'd0, 3'd2, 5'd0 }; // BRR RC, absolute, direct, F=ZERO - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd110] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd1, 2'd0, 3'd2, 5'd0 }; // BRR RC, absolute, direct, F=ZERO + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd110] = { 4'b1111, 12'd0 }; // HLT expected = 16'd111; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -364,10 +387,10 @@ module cu_tb(); // test BRR, absolute addressing, direct, false branch dut.regbank[0] = 16'd100; dut.regbank[2] = 16'd110; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd1, 2'd1, 3'd2, 5'd0 }; // BRR RC, absolute, direct, F=NEGATIVE - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd110] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd1, 2'd1, 3'd2, 5'd0 }; // BRR RC, absolute, direct, F=NEGATIVE + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd110] = { 4'b1111, 12'd0 }; // HLT expected = 16'd3; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -382,10 +405,10 @@ module cu_tb(); dut.regbank[0] = 16'd100; dut.regbank[2] = 16'd109; dut.pc = 16'd10; - dut.sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd11] = { 4'b0111, 1'd0, 1'd1, 2'd0, 3'd2, 5'd0 }; // BRR RC, relative, direct, F=ZERO - dut.sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd120] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd11] = { 4'b0111, 1'd0, 1'd1, 2'd0, 3'd2, 5'd0 }; // BRR RC, relative, direct, F=ZERO + sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd120] = { 4'b1111, 12'd0 }; // HLT expected = 16'd121; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -399,11 +422,11 @@ module cu_tb(); // test BRR, absolute addressing, indirect dut.regbank[0] = 16'd100; dut.regbank[2] = 16'd110; - dut.sram_inst.mem[16'd110] = 16'd200; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd0, 2'd0, 3'd2, 5'd0 }; // BRR RC, absolute, indirect, F=ZERO - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd110] = 16'd200; + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b0111, 1'd1, 1'd0, 2'd0, 3'd2, 5'd0 }; // BRR RC, absolute, indirect, F=ZERO + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT expected = 16'd201; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -418,11 +441,11 @@ module cu_tb(); dut.regbank[0] = 16'd100; dut.regbank[2] = 16'd109; dut.pc = 16'd10; - dut.sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd11] = { 4'b0111, 1'd0, 1'd0, 2'd0, 3'd2, 5'd0 }; // BRR RC, relative, indirect, F=ZERO - dut.sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd120] = 16'd130; - dut.sram_inst.mem[16'd130] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd11] = { 4'b0111, 1'd0, 1'd0, 2'd0, 3'd2, 5'd0 }; // BRR RC, relative, indirect, F=ZERO + sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd120] = 16'd130; + sram_inst.mem[16'd130] = { 4'b1111, 12'd0 }; // HLT expected = 16'd131; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -435,10 +458,10 @@ module cu_tb(); // test BRI, absolute addressing, direct, true branch dut.regbank[0] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd1, 2'd0, 8'd100 }; // BRI 100, absolute, direct, F=ZERO - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd1, 2'd0, 8'd100 }; // BRI 100, absolute, direct, F=ZERO + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT expected = 16'd101; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -451,10 +474,10 @@ module cu_tb(); // test BRI, absolute addressing, direct, false branch dut.regbank[0] = 16'd100; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd1, 2'd1, 8'd100 }; // BRI 100, absolute, direct, F=NEGATIVE - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd1, 2'd1, 8'd100 }; // BRI 100, absolute, direct, F=NEGATIVE + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd100] = { 4'b1111, 12'd0 }; // HLT expected = 16'd3; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -468,10 +491,10 @@ module cu_tb(); // test BRI, relative addressing, direct dut.regbank[0] = 16'd100; dut.pc = 16'd10; - dut.sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd11] = { 4'b1000, 1'd0, 1'd1, 2'd0, 8'd9 }; // BRI 9, relative, direct, F=ZERO - dut.sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd20] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd11] = { 4'b1000, 1'd0, 1'd1, 2'd0, 8'd9 }; // BRI 9, relative, direct, F=ZERO + sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd20] = { 4'b1111, 12'd0 }; // HLT expected = 16'd21; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -484,11 +507,11 @@ module cu_tb(); // test BRI, absolute addressing, indirect dut.regbank[0] = 16'd100; - dut.sram_inst.mem[16'd100] = 16'd200; - dut.sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd0, 2'd0, 8'd100 }; // BRI 100, absolute, indirect, F=ZERO - dut.sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd100] = 16'd200; + sram_inst.mem[16'd0] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd1] = { 4'b1000, 1'd1, 1'd0, 2'd0, 8'd100 }; // BRI 100, absolute, indirect, F=ZERO + sram_inst.mem[16'd2] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd200] = { 4'b1111, 12'd0 }; // HLT expected = 16'd201; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin @@ -502,11 +525,11 @@ module cu_tb(); // test BRI, relative addressing, indirect dut.regbank[0] = 16'd100; dut.pc = 16'd10; - dut.sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS - dut.sram_inst.mem[16'd11] = { 4'b1000, 1'd0, 1'd0, 2'd0, 8'd9 }; // BRI 9, relative, indirect, F=ZERO - dut.sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT - dut.sram_inst.mem[16'd20] = 16'd130; - dut.sram_inst.mem[16'd130] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd10] = { 4'b0000, 3'd1, 3'd0, 3'd0, 3'd1 }; // ALR RB, RA, RA, S=MINUS + sram_inst.mem[16'd11] = { 4'b1000, 1'd0, 1'd0, 2'd0, 8'd9 }; // BRI 9, relative, indirect, F=ZERO + sram_inst.mem[16'd12] = { 4'b1111, 12'd0 }; // HLT + sram_inst.mem[16'd20] = 16'd130; + sram_inst.mem[16'd130] = { 4'b1111, 12'd0 }; // HLT expected = 16'd131; // PC ends up at &HLT + 1 #200 if (dut.pc == expected) begin |
