diff --git a/testplan_final.md b/testplan_final.md index b109465..c773358 100644 --- a/testplan_final.md +++ b/testplan_final.md @@ -49,45 +49,45 @@ small area to debug. - SRL - EBREAK -| Test ID | Test name | Functionality being tested | Expected result | Status | -| ------- | -------------------------------- | ---------------------------------------- | ------------------------------------------------------------------ | ------- | -| 1.1 | add overflow | add two regs causing an overflow | overflow discarded | Planned | -| 1.2 | addi overflow | add imm to reg causing an overflow | overflow discarded | Planned | -| 1.3 | addi negative | add negative imm | imm is subtracted | Planned | -| 1.4 | add typical | add two regs | regs added properly | Planned | -| 1.5 | addi typical | add imm to reg | imm added properly | Planned | -| 1.6 | addi negative overflow | add negative numbers causing an overflow | negative overflow wrap around | Planned | -| 1.7 | sub overflow | subtract two regs causing an overflow | negative overflow wrap around | Planned | -| 1.8 | sub typical | subtract two regs | regs subtracted properly | Planned | -| 1.9 | sll oob | shift left by larger than 2^5 bits | left shift constrainted to 2^5 | Planned | -| 1.10 | srl oob | shift right by larger than 2^5 bits | right shift constrainted to 2^5 | Planned | -| 1.11 | sll zero | shift left by zero bits | no shift | Planned | -| 1.12 | srl zero | shift right by zero bits | no shift | Planned | -| 1.13 | sll one | shift left by one bit | logical left shift by one bit | Planned | -| 1.14 | srl one | shift right by one bit | logical right shift by one bit | Planned | -| 1.15 | sll typical | shift left by <2^5 bits | correct logical left shift | Planned | -| 1.16 | srl typical | shift right by <2^5 bits | correct logical right shift | Planned | -| 1.17 | lw zero offset | lw with zero offset | zero offset computed | Planned | -| 1.18 | sw zero offset | sw with zero offset | zero offset computed + stored | Planned | -| 1.19 | lw positive | lw with positive offset | correct offset computed | Planned | -| 1.20 | sw positive | sw with positive offset | correct offset computed + stored | Planned | -| 1.21 | lw negative | lw with negative offset | correct offset computed | Planned | -| 1.22 | sw negative | sw with negative offset | correct offset computed + stored | Planned | -| 1.23 | lw x0 | lw into x0 reg | write discarded, x0 remains 0 | Planned | -| 1.24 | beq x0 | beq with both regs as x0 | take branch | Planned | -| 1.25 | beq not taken | beq with non-equal regs | branch not taken | Planned | -| 1.26 | beq typical | beq with equal regs | branch taken | Planned | -| 1.27 | ebreak immediately | ebreak as first instruction | halt CPU | Planned | -| 1.28 | beq backward loop | beq used as a backward branch | loop runs to completion | Planned | -| 1.29 | reset while running | rst_i asserted mid-program | registers clear, execution does not resume | Planned | -| 1.30 | external halt | halt_cpu_i pulsed mid-program | CPU stops short of completion, memory ownership returns externally | Planned | -| 1.31 | isram boundary words | external access to isram word 0 and 1023 | both words read back correctly, no aliasing | Planned | -| 1.32 | dsram boundary words | external access to dsram word 0 and 1023 | both words read back correctly, no aliasing | Planned | -| 1.33 | external register boundary reads | external read of x0 and x31 | x0 reads 0, x31 reads the value the CPU wrote | Planned | +| Test ID | Test name | Functionality being tested | Expected result | Status | +| ------- | ---------------------------------- | ---------------------------------------- | ------------------------------------------------------------------ | ------- | +| 1.1 | `add_overflow` | add two regs causing an overflow | overflow discarded | Planned | +| 1.2 | `addi_overflow` | add imm to reg causing an overflow | overflow discarded | Planned | +| 1.3 | `addi_negative` | add negative imm | imm is subtracted | Planned | +| 1.4 | `add_typical` | add two regs | regs added properly | Planned | +| 1.5 | `addi_typical` | add imm to reg | imm added properly | Planned | +| 1.6 | `addi_negative_overflow` | add negative numbers causing an overflow | negative overflow wrap around | Planned | +| 1.7 | `sub_overflow` | subtract two regs causing an overflow | negative overflow wrap around | Planned | +| 1.8 | `sub_typical` | subtract two regs | regs subtracted properly | Planned | +| 1.9 | `sll_oob` | shift left by larger than 2^5 bits | left shift constrainted to 2^5 | Planned | +| 1.10 | `srl_oob` | shift right by larger than 2^5 bits | right shift constrainted to 2^5 | Planned | +| 1.11 | `sll_zero` | shift left by zero bits | no shift | Planned | +| 1.12 | `srl_zero` | shift right by zero bits | no shift | Planned | +| 1.13 | `sll_one` | shift left by one bit | logical left shift by one bit | Planned | +| 1.14 | `srl_one` | shift right by one bit | logical right shift by one bit | Planned | +| 1.15 | `sll_typical` | shift left by <2^5 bits | correct logical left shift | Planned | +| 1.16 | `srl_typical` | shift right by <2^5 bits | correct logical right shift | Planned | +| 1.17 | `lw_zero_offset` | lw with zero offset | zero offset computed | Planned | +| 1.18 | `sw_zero_offset` | sw with zero offset | zero offset computed + stored | Planned | +| 1.19 | `lw_positive` | lw with positive offset | correct offset computed | Planned | +| 1.20 | `sw_positive` | sw with positive offset | correct offset computed + stored | Planned | +| 1.21 | `lw_negative` | lw with negative offset | correct offset computed | Planned | +| 1.22 | `sw_negative` | sw with negative offset | correct offset computed + stored | Planned | +| 1.23 | `lw_x0` | lw into x0 reg | write discarded, x0 remains 0 | Planned | +| 1.24 | `beq_x0` | beq with both regs as x0 | take branch | Planned | +| 1.25 | `beq_not_taken` | beq with non-equal regs | branch not taken | Planned | +| 1.26 | `beq_typical` | beq with equal regs | branch taken | Planned | +| 1.27 | `ebreak_immediately` | ebreak as first instruction | halt CPU | Planned | +| 1.28 | `beq_backward_loop` | beq used as a backward branch | loop runs to completion | Planned | +| 1.29 | `reset_while_running` | rst_i asserted mid-program | registers clear, execution does not resume | Planned | +| 1.30 | `external_halt` | halt_cpu_i pulsed mid-program | CPU stops short of completion, memory ownership returns externally | Planned | +| 1.31 | `isram_boundary_words` | external access to isram word 0 and 1023 | both words read back correctly, no aliasing | Planned | +| 1.32 | `dsram_boundary_words` | external access to dsram word 0 and 1023 | both words read back correctly, no aliasing | Planned | +| 1.33 | `external_register_boundary_reads` | external read of x0 and x31 | x0 reads 0, x31 reads the value the CPU wrote | Planned | ### Functional-test details -### 1.1 — `add overflow` +### 1.1 — `add_overflow` **Functionality:** add two registers together that would cause an overflow @@ -108,6 +108,7 @@ prog = '{ asm_instr(.op(OP_ADD), .rd(2), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("add_overflow", prog); ``` **Expected result:** @@ -120,7 +121,7 @@ prog = '{ **Final result:** -### 1.2 — `addi overflow` +### 1.2 — `addi_overflow` **Functionality:** add an immediate to a register that would cause an overflow @@ -140,6 +141,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(1), .rs1(1), .imm(1)), EBREAK_WORD }; +run_directed("addi_overflow", prog); ``` **Expected result:** @@ -152,7 +154,7 @@ prog = '{ **Final result:** -### 1.3 — `addi negative` +### 1.3 — `addi_negative` **Functionality:** adds a negative value to a register using addi, effectively subtracting from that register @@ -172,6 +174,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(1), .rs1(1), .imm(-1)), EBREAK_WORD }; +run_directed("addi_negative", prog); ``` **Expected result:** @@ -184,7 +187,7 @@ prog = '{ **Final result:** -### 1.4 — `add typical` +### 1.4 — `add_typical` **Functionality:** add two registers with values that will not cause an overflow @@ -200,11 +203,12 @@ prog = '{ ```systemverilog prog = '{ - asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(0x123)), - asm_instr(.op(OP_ADDI), .rd(2), .rs1(0), .imm(0x123)), + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm('h123)), + asm_instr(.op(OP_ADDI), .rd(2), .rs1(0), .imm('h123)), asm_instr(.op(OP_ADD), .rd(2), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("add_typical", prog); ``` **Expected result:** @@ -217,7 +221,7 @@ prog = '{ **Final result:** -### 1.5 — `addi typical` +### 1.5 — `addi_typical` **Functionality:** addi with immediate added to register without causing an overflow @@ -233,9 +237,10 @@ prog = '{ ```systemverilog prog = '{ - asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(0x123)), + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm('h123)), EBREAK_WORD }; +run_directed("addi_typical", prog); ``` **Expected result:** @@ -248,7 +253,7 @@ prog = '{ **Final result:** -### 1.6 — `addi negative overflow` +### 1.6 — `addi_negative_overflow` **Functionality:** addi with a negative number causes an overflow wrap around to the register @@ -267,6 +272,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(-1)), EBREAK_WORD }; +run_directed("addi_negative_overflow", prog); ``` **Expected result:** @@ -279,7 +285,7 @@ prog = '{ **Final result:** -### 1.7 — `sub overflow` +### 1.7 — `sub_overflow` **Functionality:** sub registers that would cause an overflow wrap around @@ -299,6 +305,7 @@ prog = '{ asm_instr(.op(OP_SUB), .rd(1), .rs1(0), .rs2(1)), EBREAK_WORD }; +run_directed("sub_overflow", prog); ``` **Expected result:** @@ -311,7 +318,7 @@ prog = '{ **Final result:** -### 1.8 — `sub typical` +### 1.8 — `sub_typical` **Functionality:** sub two registers without causing an overflow @@ -327,11 +334,12 @@ prog = '{ ```systemverilog prog = '{ - asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(0x123)), - asm_instr(.op(OP_ADDI), .rd(2), .rs1(0), .imm(0x23)), + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm('h123)), + asm_instr(.op(OP_ADDI), .rd(2), .rs1(0), .imm('h23)), asm_instr(.op(OP_SUB), .rd(2), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("sub_typical", prog); ``` **Expected result:** @@ -344,7 +352,7 @@ prog = '{ **Final result:** -### 1.9 — `srl oob` +### 1.9 — `srl_oob` **Functionality:** srl masks to bottom 5 bits of data only, cannot shift more than 31 @@ -365,6 +373,7 @@ prog = '{ asm_instr(.op(OP_SRL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("srl_oob", prog); ``` **Expected result:** @@ -377,7 +386,7 @@ prog = '{ **Final result:** -### 1.10 — `sll oob` +### 1.10 — `sll_oob` **Functionality:** sll masks to bottom 5 bits of data only, cannot shift more than 31 @@ -398,6 +407,7 @@ prog = '{ asm_instr(.op(OP_SLL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("sll_oob", prog); ``` **Expected result:** @@ -410,7 +420,7 @@ prog = '{ **Final result:** -### 1.11 — `sll zero` +### 1.11 — `sll_zero` **Functionality:** sll with zero, causing no shift @@ -430,6 +440,7 @@ prog = '{ asm_instr(.op(OP_SLL), .rd(1), .rs1(1), .rs2(0)), EBREAK_WORD }; +run_directed("sll_zero", prog); ``` **Expected result:** @@ -442,7 +453,7 @@ prog = '{ **Final result:** -### 1.12 — `srl zero` +### 1.12 — `srl_zero` **Functionality:** srl with zero, causing no shift @@ -462,6 +473,7 @@ prog = '{ asm_instr(.op(OP_SRL), .rd(1), .rs1(1), .rs2(0)), EBREAK_WORD }; +run_directed("srl_zero", prog); ``` **Expected result:** @@ -474,7 +486,7 @@ prog = '{ **Final result:** -### 1.13 — `sll one` +### 1.13 — `sll_one` **Functionality:** sll with one, causing a shift once to the left @@ -495,6 +507,7 @@ prog = '{ asm_instr(.op(OP_SLL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("sll_one", prog); ``` **Expected result:** @@ -507,7 +520,7 @@ prog = '{ **Final result:** -### 1.14 — `srl one` +### 1.14 — `srl_one` **Functionality:** srl with one, causing a shift once to the right @@ -528,6 +541,7 @@ prog = '{ asm_instr(.op(OP_SRL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("srl_one", prog); ``` **Expected result:** @@ -540,7 +554,7 @@ prog = '{ **Final result:** -### 1.15 — `sll typical` +### 1.15 — `sll_typical` **Functionality:** sll with a shift greater than 1 and less than 2^5 @@ -561,6 +575,7 @@ prog = '{ asm_instr(.op(OP_SLL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("sll_typical", prog); ``` **Expected result:** @@ -573,7 +588,7 @@ prog = '{ **Final result:** -### 1.16 — `srl typical` +### 1.16 — `srl_typical` **Functionality:** srl with a shift greater than 1 and less than 2^5 @@ -594,6 +609,7 @@ prog = '{ asm_instr(.op(OP_SRL), .rd(1), .rs1(1), .rs2(2)), EBREAK_WORD }; +run_directed("srl_typical", prog); ``` **Expected result:** @@ -606,7 +622,7 @@ prog = '{ **Final result:** -### 1.17 — `lw zero offset` +### 1.17 — `lw_zero_offset` **Functionality:** lw with zero offset, loading in the register rs1 @@ -625,6 +641,7 @@ prog = '{ asm_instr(.op(OP_LW), .rd(1), .rs1(0), .imm(0)), EBREAK_WORD }; +run_directed("lw_zero_offset", prog); ``` **Expected result:** @@ -637,7 +654,7 @@ prog = '{ **Final result:** -### 1.18 — `sw zero offset` +### 1.18 — `sw_zero_offset` **Functionality:** sw with zero offset, storing in memory addr of rs1 @@ -657,6 +674,7 @@ prog = '{ asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), EBREAK_WORD }; +run_directed("sw_zero_offset", prog); ``` **Expected result:** @@ -669,7 +687,7 @@ prog = '{ **Final result:** -### 1.19 — `lw positive` +### 1.19 — `lw_positive` **Functionality:** lw with a positive offset @@ -688,6 +706,7 @@ prog = '{ asm_instr(.op(OP_LW), .rd(1), .rs1(0), .imm(4)), EBREAK_WORD }; +run_directed("lw_positive", prog); ``` **Expected result:** @@ -700,7 +719,7 @@ prog = '{ **Final result:** -### 1.20 — `sw positive` +### 1.20 — `sw_positive` **Functionality:** sw with a positive offset @@ -720,6 +739,7 @@ prog = '{ asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(4)), EBREAK_WORD }; +run_directed("sw_positive", prog); ``` **Expected result:** @@ -732,7 +752,7 @@ prog = '{ **Final result:** -### 1.21 — `lw negative` +### 1.21 — `lw_negative` **Functionality:** lw with a negative offset from a nonzero base register, landing on a legal, word-aligned address inside DSRAM @@ -752,6 +772,7 @@ prog = '{ asm_instr(.op(OP_LW), .rd(2), .rs1(1), .imm(-4)), EBREAK_WORD }; +run_directed("lw_negative", prog); ``` **Expected result:** @@ -764,7 +785,7 @@ prog = '{ **Final result:** -### 1.22 — `sw negative` +### 1.22 — `sw_negative` **Functionality:** sw with a negative offset from a nonzero base register, landing on a legal, word-aligned address inside DSRAM @@ -785,6 +806,7 @@ prog = '{ asm_instr(.op(OP_SW), .rs1(1), .rs2(2), .imm(-4)), EBREAK_WORD }; +run_directed("sw_negative", prog); ``` **Expected result:** @@ -797,7 +819,7 @@ prog = '{ **Final result:** -### 1.23 — `lw x0` +### 1.23 — `lw_x0` **Functionality:** attempt to lw into x0 register @@ -816,6 +838,7 @@ prog = '{ asm_instr(.op(OP_LW), .rd(0), .rs1(0), .imm(0)), EBREAK_WORD }; +run_directed("lw_x0", prog); ``` **Expected result:** @@ -828,7 +851,7 @@ prog = '{ **Final result:** -### 1.24 — `beq x0` +### 1.24 — `beq_x0` **Functionality:** beq with both sources as x0 @@ -849,6 +872,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(2)), EBREAK_WORD }; +run_directed("beq_x0", prog); ``` **Expected result:** @@ -861,7 +885,7 @@ prog = '{ **Final result:** -### 1.25 — `beq not taken` +### 1.25 — `beq_not_taken` **Functionality:** beq on two non-equal registers @@ -882,6 +906,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(2), .rs1(0), .imm(-1)), EBREAK_WORD }; +run_directed("beq_not_taken", prog); ``` **Expected result:** @@ -894,7 +919,7 @@ prog = '{ **Final result:** -### 1.26 — `beq typical` +### 1.26 — `beq_typical` **Functionality:** beq on two equal registers that are not x0 @@ -917,6 +942,7 @@ prog = '{ asm_instr(.op(OP_ADDI), .rd(3), .rs1(0), .imm(2)), EBREAK_WORD }; +run_directed("beq_typical", prog); ``` **Expected result:** @@ -929,7 +955,7 @@ prog = '{ **Final result:** -### 1.27 — `ebreak immediately` +### 1.27 — `ebreak_immediately` **Functionality:** ebreak as first instruction, subsequent instructions not run @@ -948,6 +974,7 @@ prog = '{ EBREAK_WORD, asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(-1)) }; +run_directed("ebreak_immediately", prog); ``` **Expected result:** @@ -960,7 +987,7 @@ prog = '{ **Final result:** -### 1.28 — `beq backward loop` +### 1.28 — `beq_backward_loop` **Functionality:** beq used as a backward branch creating a countdown loop @@ -982,6 +1009,7 @@ prog = '{ asm_instr(.op(OP_BEQ), .rs1(0), .rs2(0), .imm(-8)), EBREAK_WORD }; +run_directed("beq_backward_loop", prog); ``` **Expected result:** @@ -994,7 +1022,7 @@ prog = '{ **Final result:** -### 1.29 — `reset while running` +### 1.29 — `reset_while_running` **Functionality:** rst_i asserted partway through a running program @@ -1038,7 +1066,7 @@ readback(2, 1, 1); **Final result:** -### 1.30 — `external halt` +### 1.30 — `external_halt` **Functionality:** halt_cpu_i pulsed partway through a running program @@ -1078,7 +1106,7 @@ readback(2, 1, 1); **Final result:** -### 1.31 — `isram boundary words` +### 1.31 — `isram_boundary_words` **Functionality:** external port access to the first and last ISRAM words @@ -1111,7 +1139,7 @@ readback(0, 1, 1023); **Final result:** -### 1.32 — `dsram boundary words` +### 1.32 — `dsram_boundary_words` **Functionality:** external port access to the first and last DSRAM words @@ -1144,7 +1172,7 @@ readback(1, 1, 1023); **Final result:** -### 1.33 — `external register boundary reads` +### 1.33 — `external_register_boundary_reads` **Functionality:** external, read-only register-file port access to x0 and x31 @@ -1277,15 +1305,17 @@ X0_REMAINS_0: **Evidence that it detects a violation:** -### 3.2 — `NO_RW_CONCURRENCY` +### 3.2 — `STABLE_WHEN_DISABLED` -**Timing requirement in words:** on every clock pulse, check that read and write are not both enabled +**Timing requirement in words:** when the CPU is disabled or inactive, the PC and register file should not change ```systemverilog -NO_RW_CONCURRENCY: +STABLE_WHEN_DISABLED : assert property (@(posedge clk) disable iff (rst) - !(cpu_if.w_en_i && cpu_if.r_en_i)) - else assertion_fail("halt did not pulse correctly"); + (!cpu_if.en_cpu || !cpu_if.cpu_active) |=> ($stable( + dut.register_crossbar + ))) + else assertion_fail("register file/pc changed while cpu inactive"); ``` **Evidence that it detects a violation:**