Skip to content

Commit d6c1f63

Browse files
nasahlpaandreaskurth
authored andcommitted
Update lowrisc_ibex to lowRISC/ibex@75ef275c
Update code from upstream repository https://github.com/lowRISC/ibex.git to revision 75ef275cb34b7cae55325a1d64d8672a0cd72269 * [rtl] Lint fixes for recent Zc code (Andreas Kurth) * [doc] Clarify usage of data independent timing & branch prediction (Pascal Nasahl) * [doc] PMP instruction fetch check clarified (Marno van der Maas) Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
1 parent 2804186 commit d6c1f63

6 files changed

Lines changed: 28 additions & 8 deletions

File tree

hw/vendor/lowrisc_ibex.lock.hjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
upstream:
1010
{
1111
url: https://github.com/lowRISC/ibex.git
12-
rev: 0c233f54361d769f370889223acc456f2ac19d46
12+
rev: 75ef275cb34b7cae55325a1d64d8672a0cd72269
1313
}
1414
}

hw/vendor/lowrisc_ibex/doc/03_reference/instruction_fetch.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ The interfaces of the icache module are the same as the prefetch buffer with two
2626
Firstly, a signal to enable the cache which is driven from a custom CSR.
2727
Secondly a signal to the flush the cache which is set every time a ``fence.i`` instruction is executed.
2828

29+
.. _branch-prediction:
30+
2931
Branch Prediction
3032
-----------------
3133

hw/vendor/lowrisc_ibex/doc/03_reference/pmp.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ When PMPEnable is zero, the PMP module is not instantiated and all PMP registers
2121
PMP Integration
2222
---------------
2323

24-
Addresses from the instruction fetch unit and load-store unit are passed to the PMP module for checking, and the output of the PMP check is used to gate the external request.
24+
Addresses from the instruction fetch unit and load-store unit are passed to the PMP module for checking.
25+
The output of PMP check is used to gate the external request of the load-store unit.
26+
This is because both writes and reads can have side-effects on MMIO devices connected to the data memory bus.
27+
The request coming from the instruction fetch unit are not gated by the PMP check, so integrators must choose carefully what to connect to the instruction fetch bus.
28+
Specifically, no devices that experience side-effects due to reading should be available on this bus.
29+
In general, connecting memories to the instruction fetch bus should be safe.
30+
2531
To maintain consistency with external errors, the instruction fetch unit and load-store unit progress with their request as if it was granted externally.
2632
The PMP error is registered and consumed by the core when the data would have been consumed.
2733

hw/vendor/lowrisc_ibex/doc/03_reference/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Software that has need of data independent timing may wish to disable the instru
3636
The instruction cache is controlled by the **icache_enable** bit in the **cpuctrl** register.
3737
Precise details of fetch timing will depend upon the memory system Ibex is connected to.
3838

39+
If data independent timing is needed for branches, turn off the branch prediction feature as it is :ref:`experimental<branch-prediction>`.
40+
3941
Dummy Instruction Insertion
4042
---------------------------
4143

hw/vendor/lowrisc_ibex/rtl/ibex_compressed_decoder.sv

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ module ibex_compressed_decoder #(
5757
function automatic logic [4:0] cm_stack_adj_word(input logic [3:0] rlist,
5858
input logic [1:0] spimm);
5959
logic [6:0] tmp;
60-
logic [1:0] _unused;
60+
logic [1:0] unused_tmp;
6161
tmp = cm_stack_adj(.rlist(rlist), .spimm(spimm));
62-
_unused = tmp[1:0];
62+
unused_tmp = tmp[1:0];
6363
return tmp[6:2];
6464
endfunction
6565

@@ -79,8 +79,12 @@ module ibex_compressed_decoder #(
7979
function automatic logic [31:0] cm_push_store_reg(input logic [4:0] rlist,
8080
input logic [4:0] sp_offset);
8181
logic [11:0] neg_offset;
82+
logic signed [11:0] neg_offset_signed;
8283
logic [31:0] instr;
83-
neg_offset = ~{5'b00000, sp_offset, 2'b00} + 12'd1;
84+
// Compute two's complement on signed variable, then cast back to unsigned
85+
// for the part select operations below.
86+
neg_offset_signed = -signed'({5'b00000, sp_offset, 2'b00});
87+
neg_offset = unsigned'(neg_offset_signed);
8488
instr[ 6: 0] /* opcode */ = OPCODE_STORE;
8589
instr[11: 7] /* offset[4:0] */ = neg_offset[4:0];
8690
instr[14:12] /* width */ = 3'b010; // 32 bit
@@ -105,15 +109,18 @@ module ibex_compressed_decoder #(
105109
input logic [1:0] spimm,
106110
input logic decr = 1'b0);
107111
logic [11:0] imm;
112+
logic signed [11:0] imm_signed;
108113
logic [31:0] instr;
109114
imm[11:7] = '0;
110115
imm[ 6:0] = cm_stack_adj(.rlist(rlist), .spimm(spimm));
111-
if (decr) imm = ~imm + 12'd1;
116+
// Compute two's complement on signed variable, but as it will be used in
117+
// unsigned targets below, it will have to be cast back to unsigned then.
118+
imm_signed = decr ? -signed'(imm) : signed'(imm);
112119
instr[ 6: 0] /* opcode */ = OPCODE_OP_IMM;
113120
instr[11: 7] /* dest reg */ = 5'd2; // x2 (sp / stack pointer)
114121
instr[14:12] /* funct3 */ = 3'b000; // addi
115122
instr[19:15] /* src reg */ = 5'd2; // x2
116-
instr[31:20] /* imm[11:0] */ = imm;
123+
instr[31:20] /* imm[11:0] */ = unsigned'(imm_signed);
117124
return instr;
118125
endfunction
119126

hw/vendor/lowrisc_ibex/rtl/ibex_core.sv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,10 +1932,13 @@ module ibex_core import ibex_pkg::*; #(
19321932
end
19331933

19341934
`else
1935-
logic unused_instr_new_id, unused_instr_id_done, unused_instr_done_wb;
1935+
logic unused_instr_new_id, unused_instr_id_done, unused_instr_done_wb,
1936+
unused_instr_expanded_id, unused_instr_gets_expanded_id;
19361937
assign unused_instr_id_done = instr_id_done;
19371938
assign unused_instr_new_id = instr_new_id;
19381939
assign unused_instr_done_wb = instr_done_wb;
1940+
assign unused_instr_expanded_id = ^instr_expanded_id;
1941+
assign unused_instr_gets_expanded_id = ^instr_gets_expanded_id;
19391942
`endif
19401943

19411944
// Certain parameter combinations are not supported

0 commit comments

Comments
 (0)