Skip to content

Commit 9796bb3

Browse files
authored
⚠️ remove CFU CSRs (#1377)
2 parents 6931a04 + e6fce82 commit 9796bb3

File tree

11 files changed

+87
-211
lines changed

11 files changed

+87
-211
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ mimpid = 0x01040312 -> Version 01.04.03.12 -> v1.4.3.12
2929

3030
| Date | Version | Comment | Ticket |
3131
|:----:|:-------:|:--------|:------:|
32-
| 14.09.2025 | 1.12.1.7 | :bug: fix unaligned instruction fetch bus error; do not trigger co-processors if pending instruction-related exception | [#1367](https://github.com/stnolting/neorv32/pull/1376) |
32+
| 14.09.2025 | 1.12.1.8 | :warning: remove CFU CSRs (`cfureg[0..3]`) | [#1377](https://github.com/stnolting/neorv32/pull/1377) |
33+
| 13.09.2025 | 1.12.1.7 | :bug: fix unaligned instruction fetch bus error; do not trigger co-processors if pending instruction-related exception | [#1367](https://github.com/stnolting/neorv32/pull/1376) |
3334
| 13.09.2025 | 1.12.1.6 | minor RTL edits; add `Zca` ISA extension flag to `mxisa` CSR | [#1375](https://github.com/stnolting/neorv32/pull/1375) |
3435
| 09.09.2025 | 1.12.1.5 | TRACER: rework instruction decoding logic and add all remaining ISA extensions | [#1368](https://github.com/stnolting/neorv32/pull/1368) |
3536
| 05.09.2025 | 1.12.1.4 | improve TRACER's simulation-mode instruction decoding | [#1366](https://github.com/stnolting/neorv32/pull/1366) |

docs/datasheet/cpu_cfu.adoc

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ program memory requirements when implemented entirely in software. Some potentia
1010
use-cases might include:
1111

1212
* **AI:** sub-word / vertical vector/SIMD operations like processing all four sub-bytes of a 32-bit data word individually
13-
* **Cryptographic:** bit substitution and permutation
13+
* **Cryptography:** bit substitution and permutation
1414
* **Communication:** data conversions like binary to gray-code
1515
* **Arithmetic:** BCD (binary-coded decimal) operations; multiply-add operations; shift-and-add algorithms like CORDIC or BKM
1616
* **Image processing:** look-up-tables for color space transformations
1717
* implementing instructions from **other RISC-V ISA extensions** that are not yet supported by NEORV32
1818
19-
The NEORV32 CFU supports two different instruction formats (R3-type and R4-type; see <<_cfu_instruction_formats>>) and also
20-
allows to implement up to 4 CFU-internal custom control and status registers (see <<_cfu_control_and_status_registers_cfu_csrs>>).
19+
The NEORV32 CFU supports two different instruction formats: RISC-V R3-type (up to two source operands) and RISC-V R4-type
20+
(up to three source operands) instructions. See <<_cfu_instruction_formats>> for more information.
2121

2222
.CFU Complexity
2323
[NOTE]
@@ -30,7 +30,7 @@ https://stnolting.github.io/neorv32/ug/#_adding_custom_hardware_modules[Adding C
3030
.Default CFU Hardware Example
3131
[TIP]
3232
The default CFU module (`rtl/core/neorv32_cpu_cp_cfu.vhd`) implements the _Extended Tiny Encryption Algorithm (XTEA)_
33-
as "real world" application example.
33+
as application example.
3434

3535

3636
:sectnums:
@@ -45,8 +45,8 @@ The NEORV32 CFU utilizes these two opcodes to support user-defined **R3-type** i
4545
1 destination register) and **R4-type** instructions (3 source registers, 1 destination register). Both instruction
4646
formats are compliant to the RISC-V specification.
4747

48-
* `custom-0`: `0001011` RISC-V standard, used for NEORV32 <<_cfu_r3_type_instructions>> (3x register addresses)
49-
* `custom-1`: `0101011` RISC-V standard, used for NEORV32 <<_cfu_r4_type_instructions>> (4x register addresses)
48+
* `custom-0`: `0001011` RISC-V standard, used for NEORV32 <<_cfu_r3_type_instructions>> (3 register addresses)
49+
* `custom-1`: `0101011` RISC-V standard, used for NEORV32 <<_cfu_r4_type_instructions>> (4 register addresses)
5050
5151
[TIP]
5252
The provided instructions formats are _predefined_ to allow an easy integration framework.
@@ -184,34 +184,6 @@ There is an example program for the CFU, which shows how to use the _default_ CF
184184
This example program is located in `sw/example/demo_cfu`.
185185

186186

187-
:sectnums:
188-
==== CFU Control and Status Registers (CFU-CSRs)
189-
190-
The CPU provides up to four control and status registers (<<_cfureg, `cfureg*`>>) to be used within the CFU.
191-
These CSRs are mapped to the "custom user-mode read/write" CSR address space, which is explicitly reserved for
192-
platform-specific application by the RISC-V spec. For example, these CSRs can be used to pass additional operands
193-
to the CFU, to obtain additional results, to check processing status or to configure operation modes.
194-
195-
.CFU CSR Access Example
196-
[source,c]
197-
----
198-
neorv32_cpu_csr_write(CSR_CFUREG0, 0xabcdabcd); // write data to CFU CSR 0
199-
uint32_t tmp = neorv32_cpu_csr_read(CSR_CFUREG3); // read data from CFU CSR 3
200-
----
201-
202-
.Additional CFU-internal CSRs
203-
[TIP]
204-
If more than four CFU-internal CSRs are required the designer can implement an "indirect access mechanism" based
205-
on just two of the default CSRs: one CSR is used to configure the index while the other is used as alias to exchange
206-
data with the indexed CFU-internal CSR - this concept is similar to the RISC-V Indirect CSR Access Extension
207-
Specification (`Smcsrind`).
208-
209-
.Security Considerations
210-
[NOTE]
211-
The CFU CSRs are mapped to the user-mode CSR space so software running at _any privilege level_ can access these
212-
CSRs.
213-
214-
215187
:sectnums:
216188
==== Custom Instructions Hardware
217189

docs/datasheet/cpu_csr.adoc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ In the following table these CSRs are highlighted with "⚠️".
8181
| 0xf14 | <<_mhartid>> | `CSR_MHARTID` | MRO | Machine hardware thread ID
8282
| 0xf15 | <<_mconfigptr>> | `CSR_MCONFIGPTR` | MRO | Machine configuration pointer register
8383
5+^| **<<_neorv32_specific_csrs>>**
84-
| 0x800 .. 0x803 | <<_cfureg, `cfureg0`>> .. <<_cfureg, `cfureg3`>> | `CSR_CFUCREG0` .. `CSR_CFUCREG3` | URW | Custom CFU registers 0 to 3
8584
| 0xbc0 | <<_mxcsr>> | `CSR_MXCSR` | MRW | Machine status and control register
8685
| 0xfc0 | <<_mxisa>> | `CSR_MXISA` | MRO | Extended machine CPU ISA and extensions
8786
|=======================
@@ -921,24 +920,6 @@ ID of each core is unique and starts at 0 and is incremented continuously.
921920
All NEORV32-specific CSRs are mapped to addresses that are explicitly reserved for custom/implementation-specific use.
922921

923922

924-
[discrete]
925-
===== **`cfureg`**
926-
927-
[cols="<1,<8"]
928-
[grid="none"]
929-
|=======================
930-
| Name | Custom (user-defined) CFU CSRs
931-
| Address | `0x800` (`cfureg0`)
932-
| | `0x801` (`cfureg1`)
933-
| | `0x802` (`cfureg2`)
934-
| | `0x803` (`cfureg3`)
935-
| Reset value | `0x00000000`
936-
| ISA | `Zicsr` & `Zxcfu`
937-
| Description | User-defined CSRs to be used within the <<_custom_functions_unit_cfu>>.
938-
|=======================
939-
940-
941-
{empty} +
942923
[discrete]
943924
===== **`mxcsr`**
944925

rtl/core/neorv32_cpu_alu.vhd

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ architecture neorv32_cpu_alu_rtl of neorv32_cpu_alu is
6262
-- comparator --
6363
signal cmp_rs1 : std_ulogic_vector(XLEN downto 0);
6464
signal cmp_rs2 : std_ulogic_vector(XLEN downto 0);
65-
signal cmp : std_ulogic_vector(1 downto 0); -- comparator status
65+
signal cmp : std_ulogic_vector(1 downto 0);
6666

6767
-- operands --
6868
signal opa, opb : std_ulogic_vector(XLEN-1 downto 0);
@@ -74,22 +74,18 @@ architecture neorv32_cpu_alu_rtl of neorv32_cpu_alu is
7474

7575
-- co-processor interface --
7676
type cp_data_t is array (0 to 6) of std_ulogic_vector(XLEN-1 downto 0);
77-
signal cp_result : cp_data_t; -- co-processor result
78-
signal cp_valid : std_ulogic_vector(6 downto 0); -- co-processor done
79-
signal cp_shamt : std_ulogic_vector(index_size_f(XLEN)-1 downto 0); -- shift amount
77+
signal cp_result : cp_data_t;
78+
signal cp_valid : std_ulogic_vector(6 downto 0);
79+
signal cp_shamt : std_ulogic_vector(index_size_f(XLEN)-1 downto 0);
8080

81-
-- CSR proxy --
82-
signal fpu_csr_en, cfu_csr_en : std_ulogic;
83-
signal fpu_csr_we, cfu_csr_we : std_ulogic;
84-
signal fpu_csr_rd, cfu_csr_rd : std_ulogic_vector(XLEN-1 downto 0);
81+
-- FPU proxy --
82+
signal fpu_csr_en, fpu_csr_we : std_ulogic;
83+
signal fpu_csr_rd : std_ulogic_vector(XLEN-1 downto 0);
8584

8685
-- CFU proxy --
8786
signal cfu_active, cfu_done, cfu_busy : std_ulogic;
8887
signal cfu_res : std_ulogic_vector(XLEN-1 downto 0);
8988

90-
-- CSR read-backs --
91-
signal csr_rdata_fpu, csr_rdata_cfu : std_ulogic_vector(XLEN-1 downto 0);
92-
9389
begin
9490

9591
-- Comparator Unit (for conditional branches) ---------------------------------------------
@@ -150,10 +146,6 @@ begin
150146
-- > "cp_result" data has to be always zero unless the specific co-processor has been actually triggered
151147
cp_res <= cp_result(0) or cp_result(1) or cp_result(2) or cp_result(3) or cp_result(4) or cp_result(5) or cp_result(6);
152148

153-
-- co-processor CSR read-back --
154-
-- > "csr_rdata_*" data has to be always zero unless the specific co-processor is actually being accessed
155-
csr_o <= csr_rdata_fpu or csr_rdata_cfu;
156-
157149
-- shift amount --
158150
cp_shamt <= opb(cp_shamt'left downto 0);
159151

@@ -270,19 +262,19 @@ begin
270262
);
271263

272264
-- CSR proxy --
273-
fpu_csr_en <= '1' when (ctrl_i.csr_addr(11 downto 2) = csr_fflags_c(11 downto 2)) else '0';
274-
fpu_csr_we <= fpu_csr_en and ctrl_i.csr_we;
275-
csr_rdata_fpu <= fpu_csr_rd when (fpu_csr_en = '1') else (others => '0');
265+
fpu_csr_en <= '1' when (ctrl_i.csr_addr(11 downto 2) = csr_fflags_c(11 downto 2)) else '0';
266+
fpu_csr_we <= fpu_csr_en and ctrl_i.csr_we;
267+
csr_o <= fpu_csr_rd when (fpu_csr_en = '1') else (others => '0');
276268
end generate;
277269

278270
neorv32_cpu_cp_fpu_inst_false:
279271
if not RISCV_ISA_Zfinx generate
280-
fpu_csr_en <= '0';
281-
fpu_csr_we <= '0';
282-
fpu_csr_rd <= (others => '0');
283-
csr_rdata_fpu <= (others => '0');
284-
cp_result(3) <= (others => '0');
285-
cp_valid(3) <= '0';
272+
fpu_csr_en <= '0';
273+
fpu_csr_we <= '0';
274+
fpu_csr_rd <= (others => '0');
275+
csr_o <= (others => '0');
276+
cp_result(3) <= (others => '0');
277+
cp_valid(3) <= '0';
286278
end generate;
287279

288280

@@ -293,33 +285,23 @@ begin
293285
neorv32_cpu_cp_cfu_inst: entity neorv32.neorv32_cpu_cp_cfu
294286
port map (
295287
-- global control --
296-
clk_i => clk_i, -- global clock, rising edge
297-
rstn_i => rstn_i, -- global reset, low-active, async
288+
clk_i => clk_i, -- global clock, rising edge
289+
rstn_i => rstn_i, -- global reset, low-active, async
298290
-- operation control --
299-
start_i => ctrl_i.alu_cp_cfu, -- operation trigger/strobe
300-
active_i => cfu_active, -- operation in progress, CPU is waiting for CFU
301-
-- CSR interface --
302-
csr_we_i => cfu_csr_we, -- write enable
303-
csr_addr_i => ctrl_i.csr_addr(1 downto 0), -- address
304-
csr_wdata_i => ctrl_i.csr_wdata, -- write data
305-
csr_rdata_o => cfu_csr_rd, -- read data
291+
start_i => ctrl_i.alu_cp_cfu, -- operation trigger/strobe
292+
active_i => cfu_active, -- operation in progress, CPU is waiting for CFU
306293
-- operands --
307-
rtype_i => ctrl_i.ir_opcode(5), -- instruction type (R3-type or R4-type)
308-
funct3_i => ctrl_i.ir_funct3, -- "funct3" bit-field from custom instruction word
309-
funct7_i => ctrl_i.ir_funct12(11 downto 5), -- "funct7" bit-field from custom instruction word
310-
rs1_i => rs1_i, -- rf source 1
311-
rs2_i => rs2_i, -- rf source 2
312-
rs3_i => rs3_i, -- rf source 3
294+
rtype_i => ctrl_i.ir_opcode(5), -- instruction type (R3-type or R4-type)
295+
funct3_i => ctrl_i.ir_funct3, -- "funct3" bit-field from custom instruction word
296+
funct7_i => ctrl_i.ir_funct12(11 downto 5), -- "funct7" bit-field from custom instruction word
297+
rs1_i => rs1_i, -- rf source 1
298+
rs2_i => rs2_i, -- rf source 2
299+
rs3_i => rs3_i, -- rf source 3
313300
-- result and status --
314-
result_o => cfu_res, -- operation result
315-
valid_o => cfu_done -- result valid, operation done; set one cycle before result_o is valid
301+
result_o => cfu_res, -- operation result
302+
valid_o => cfu_done -- result valid, operation done; set one cycle before result_o is valid
316303
);
317304

318-
-- CSR proxy --
319-
cfu_csr_en <= '1' when (ctrl_i.csr_addr(11 downto 2) = csr_cfureg0_c(11 downto 2)) else '0';
320-
cfu_csr_we <= cfu_csr_en and ctrl_i.csr_we;
321-
csr_rdata_cfu <= cfu_csr_rd when (cfu_csr_en = '1') else (others => '0');
322-
323305
-- response proxy --
324306
cfu_arbiter: process(rstn_i, clk_i)
325307
begin
@@ -346,16 +328,12 @@ begin
346328

347329
neorv32_cpu_cp_cfu_inst_false:
348330
if not RISCV_ISA_Zxcfu generate
349-
cfu_csr_en <= '0';
350-
cfu_csr_we <= '0';
351-
cfu_done <= '0';
352-
cfu_res <= (others => '0');
353-
cfu_csr_rd <= (others => '0');
354-
csr_rdata_cfu <= (others => '0');
355-
cfu_busy <= '0';
356-
cfu_active <= '0';
357-
cp_result(4) <= (others => '0');
358-
cp_valid(4) <= '0';
331+
cfu_done <= '0';
332+
cfu_res <= (others => '0');
333+
cfu_busy <= '0';
334+
cfu_active <= '0';
335+
cp_result(4) <= (others => '0');
336+
cp_valid(4) <= '0';
359337
end generate;
360338

361339

rtl/core/neorv32_cpu_control.vhd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,6 @@ begin
652652
-- ------------------------------------------------------------
653653
case csr_addr_v is
654654

655-
-- NEORV32-specific user-mode CFU CSRs --
656-
when csr_cfureg0_c | csr_cfureg1_c | csr_cfureg2_c | csr_cfureg3_c =>
657-
csr_valid(2) <= bool_to_ulogic_f(RISCV_ISA_Zxcfu); -- available if CFU implemented
658-
659655
-- floating-point-unit CSRs --
660656
when csr_fflags_c | csr_frm_c | csr_fcsr_c =>
661657
csr_valid(2) <= bool_to_ulogic_f(RISCV_ISA_Zfinx); -- available if FPU implemented

0 commit comments

Comments
 (0)