Skip to content

Commit ec1d774

Browse files
committed
[RTL] Register file output ports DCLS comparison
When DCLS and `lockstep_regfile_enable` is enabled, previously, a subset of registers were directly compared. This has two drawbacks: - Area overhead is quite large as multiple registers need to be compared - No comprehensive protection as only a subset of registers were covered. This commit switches from a comparison of a subset of registers to the comparison of the read output ports of the main and the shadow core. This: - Saves area as only the output ports need to be compared - Covers all registers The detection latency is a bit higher as a fault injected into a registes is only detected when the register is read from the RF. However, this is fine as we are interested in detecting a fault when we are consuming the register file value. Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
1 parent efc5d1b commit ec1d774

5 files changed

Lines changed: 38 additions & 44 deletions

File tree

design/dec/el2_dec.sv

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,17 +435,8 @@ module el2_dec
435435

436436
`ifdef RV_LOCKSTEP_REGFILE_ENABLE
437437
el2_regfile_if regfile_if ();
438-
assign regfile.gpr.ra = regfile_if.gpr.ra;
439-
assign regfile.gpr.sp = regfile_if.gpr.sp;
440-
assign regfile.gpr.fp = regfile_if.gpr.fp;
441-
assign regfile.gpr.a0 = regfile_if.gpr.a0;
442-
assign regfile.gpr.a1 = regfile_if.gpr.a1;
443-
assign regfile.gpr.a2 = regfile_if.gpr.a2;
444-
assign regfile.gpr.a3 = regfile_if.gpr.a3;
445-
assign regfile.gpr.a4 = regfile_if.gpr.a4;
446-
assign regfile.gpr.a5 = regfile_if.gpr.a5;
447-
assign regfile.gpr.a6 = regfile_if.gpr.a6;
448-
assign regfile.gpr.a7 = regfile_if.gpr.a7;
438+
assign regfile.gpr.rd0 = regfile_if.gpr.rd0;
439+
assign regfile.gpr.rd1 = regfile_if.gpr.rd1;
449440

450441
assign regfile.tlu.pc = regfile_if.tlu.pc;
451442
assign regfile.tlu.npc = regfile_if.tlu.npc;

design/dec/el2_dec_gpr_ctl.sv

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,8 @@ import el2_pkg::*;
5555
logic [31:1] gpr_wr_en;
5656

5757
`ifdef RV_LOCKSTEP_REGFILE_ENABLE
58-
assign regfile.gpr.ra = gpr_out[1][31:0]; // x1
59-
assign regfile.gpr.sp = gpr_out[2][31:0]; // x2
60-
assign regfile.gpr.fp = gpr_out[8][31:0]; // x8
61-
assign regfile.gpr.a0 = gpr_out[10][31:0]; // x10
62-
assign regfile.gpr.a1 = gpr_out[11][31:0]; // x11
63-
assign regfile.gpr.a2 = gpr_out[12][31:0]; // x12
64-
assign regfile.gpr.a3 = gpr_out[13][31:0]; // x13
65-
assign regfile.gpr.a4 = gpr_out[14][31:0]; // x14
66-
assign regfile.gpr.a5 = gpr_out[15][31:0]; // x15
67-
assign regfile.gpr.a6 = gpr_out[16][31:0]; // x16
68-
assign regfile.gpr.a7 = gpr_out[17][31:0]; // x17
58+
assign regfile.gpr.rd0 = rd0[31:0];
59+
assign regfile.gpr.rd1 = rd1[31:0];
6960
`endif
7061

7162
// GPR Write Enables

design/el2_veer_lockstep.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ module el2_veer_lockstep
762762
delayed_main_core_regfile[0].tlu <= '0;
763763
end else begin
764764
delayed_main_core_regfile[0].gpr <= main_core_regfile.gpr;
765+
delayed_main_core_regfile[0].gpr.rd0 <= main_core_regfile.gpr;
765766
delayed_main_core_regfile[0].tlu <= main_core_regfile.tlu;
766767
end
767768
end

design/lib/el2_regfile_if.sv

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
interface el2_regfile_if
2020
import el2_pkg::*;
2121
();
22+
// Compare the read output ports of the register file.
23+
// When a fault corrupts a register, this is detected by DCLS once
24+
// the register file content is read.
2225
typedef struct packed {
23-
// General Purpose Registers
24-
logic [31:0] ra; // Return address
25-
logic [31:0] sp; // Stack pointer
26-
logic [31:0] fp; // Frame pointer
27-
logic [31:0] a0, a1; // Function arguments 0-1 / Return values 0-1
28-
logic [31:0] a2, a3, a4, a5, a6, a7; // Function arguments 2-7
26+
logic [31:0] rd0; // GPR read port 0 data (raddr0 / rs1)
27+
logic [31:0] rd1; // GPR read port 1 data (raddr1 / rs2)
2928
} el2_regfile_gpr_pkt_t;
3029

3130
typedef struct packed {

docs/source/dual-core-lock-step.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The diagram below outlines the architecture of the proposed solution.
2121

2222
![VeeR DCLS Overview](img/dcls_block_diagram.png)
2323

24-
Outputs and the register file from the main core are delayed by `DELAY` cycles and passed to the `Equivalency Checker` for verification against the outputs and the register file of the Shadow Core.
24+
Outputs and the register file from the main core are delayed by `DELAY` cycles and passed to the `Equivalency Checker` for verification against the outputs and the register file outputs of the Shadow Core.
2525

2626
### Error Policy
2727

@@ -35,27 +35,23 @@ The corruption error will be reported always when all of the following requireme
3535

3636
### Monitored Registers
3737

38-
The Shadow Core can have its internal copy of the register file by setting a proper VeeR EL2 configuration flag.
38+
#### Register File
39+
40+
Enabling the `lockstep_regfile_enable` VeeR EL2 configuration flag exposes the register file read ports of both cores to the `Equivalency Checker`.
3941
Even though every discrepancy between register files of the Main Core and Shadow Core will eventually lead to difference between IOs of these modules, it might take some time for the mismatch to manifest.
40-
To determine whether a discrepancy has occurred immediately, the register files from both cores will be compared taking into account a reasonable subset of the VeeR EL2 registers, as defined in the table below:
42+
To detect the discrepancy on a read immediately, the register file read port outputs from both cores are compared.
43+
44+
#### Control and Status Registers
45+
46+
The following CSRs from both cores will be compared:
4147

42-
:::{list-table} Monitored VeeR EL2 Registers
48+
:::{list-table} Monitored VeeR EL2 CSRs
4349
:header-rows: 0
44-
:name: tab-dcls-monitored-veer-el2-registers
50+
:name: tab-dcls-monitored-veer-el2-csrs
4551
:align: center
4652

4753
* - **Name**
4854
- **Description**
49-
* - x1 (ra)
50-
- Return address
51-
* - x2 (sp)
52-
- Stack pointer
53-
* - x8 (s0/fp)
54-
- Saved register / frame pointer
55-
* - x10-x11 (a0-a1)
56-
- Function arguments / return values
57-
* - x12-17 (a2-7)
58-
- Function arguments
5955
* - pc
6056
- Program Counter
6157
* - npc
@@ -1179,7 +1175,7 @@ Entering Debug Mode with DCLS enabled will disable DCLS until the next reset.
11791175
The DCLS feature can be enabled via `-set lockstep_enable=1` option.
11801176
There are two configuration options:
11811177
* `-set lockstep_delay={2, 3, 4}` - the delay applied on the Shadow Core between 2 and 4 cycles,
1182-
* `-set lockstep_regfile_enable=1` - enable exposing the VeeR Register File so the Shadow Core will have an internal copy to compare with the Main Core Register File.
1178+
* `-set lockstep_regfile_enable=1` - enable exposing the VeeR register file read ports so the Shadow Core's read-port outputs can be compared against the Main Core's.
11831179

11841180
The configuration options are ignored and their macros are not generated if the Dual Core Lockstep feature is disabled.
11851181

@@ -1307,4 +1303,20 @@ The DCLS feature will be tested within:
13071303
- `dcls_debug`
13081304
* -
13091305
-
1306+
* - **Function**
1307+
- **Register file fault injection detection**
1308+
* - Reference Document
1309+
-
1310+
* - Check description
1311+
- Inject a fault into the register file or the register file output ports of the main or the shadow core.
1312+
* - Coverage groups
1313+
-
1314+
* - Assertions
1315+
- Detection bit is asserted upon encountered corruption. Error behavior follows the relevant error handling policy. No action is taken if no corruption was introduced.
1316+
* - Comments
1317+
-
1318+
* - Test Name
1319+
-
1320+
* -
1321+
-
13101322
:::

0 commit comments

Comments
 (0)