Skip to content

Commit 0fb51a3

Browse files
committed
rtl: improve core_wrap documentation
1 parent 1d07956 commit 0fb51a3

File tree

2 files changed

+68
-26
lines changed

2 files changed

+68
-26
lines changed

rtl/core_wrap.sv

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,61 @@
44
//
55
// Authors:
66
// - Philippe Sauter <phsauter@iis.ee.ethz.ch>
7+
//
8+
// This module wraps the processor core and adapts it to the Croc SoC interface.
9+
// The default core is CVE2 (https://github.com/openhwgroup/cve2).
10+
// For other cores, modify the internal instantiation and the port connections as needed.
11+
//
12+
// Replacing the core:
13+
// The SoC provides two separate OBI master ports (instruction fetch and data access).
14+
// Cores with a single shared memory bus can tie off one of the two and only use the other.
15+
//
16+
// Key interface signals to adapt for other cores:
17+
// fetch_enable_i - Allows the SoC to gate instruction fetch (e.g. hold core until
18+
// software is loaded). Cores without this signal should ignore it.
19+
// core_busy_o - Activity hint; drive 1'b0 if the core does not expose it.
20+
// irqs_i [15:0] - Fast interrupts (RISC-V IRQ 16..31). Mapping to a core's interrupt
21+
// input depends on the core:
22+
// CVE2/Ibex: irq_fast_i[15:0] directly
23+
// cv32e40p: irq_i[31:16]
24+
// timer_irq_i and software_irq_i correspond to the standard RISC-V
25+
// CLINT timer (IRQ 7) and software (IRQ 3) interrupts.
26+
// debug_req_i - Debug module request. Cores without a debug interface should leave
27+
// this unconnected and remove the debug module from the address map.
28+
// Attention! Think carefully how it will be programmed and started.
29+
// CVE2 receives the debug halt/exception addresses as runtime inputs
30+
// (dm_halt_addr_i / dm_exception_addr_i). Some cores hardcode these
31+
// addresses instead; in that case adjust PeriphDebug's start_addr in
32+
// croc_pkg.sv so the debug module ROM base matches what the core
33+
// expects to jump to on halt.
34+
// CV-X-IF co-processors: CVE2 supports instruction offloading via the Core-V Extension Interface.
35+
// If you want to attach a custom accelerator using CV-X-IF,
36+
// instantiate it directly inside this wrapper (enable XInterface and connect x_* ports here).
37+
// Do not route CV-X-IF through the SoC hierarchy; the types are CVE2-specific and the tight
38+
// coupling belongs at the core boundary, not in user_domain.
739

840
module core_wrap import croc_pkg::*; #() (
941
input logic clk_i,
1042
input logic rst_ni,
11-
input logic ref_clk_i,
1243
input logic test_enable_i,
1344

45+
// Interrupts
46+
// irqs_i maps to RISC-V fast interrupts (IRQ 16..31); see header comment for remapping
1447
input logic [15:0] irqs_i,
1548
input logic timer_irq_i,
1649
input logic software_irq_i,
1750

1851
input logic [31:0] boot_addr_i,
1952

20-
// Instruction memory interface
53+
// Instruction memory interface (OBI)
2154
output logic instr_req_o,
2255
input logic instr_gnt_i,
2356
input logic instr_rvalid_i,
2457
output logic [31:0] instr_addr_o,
2558
input logic [31:0] instr_rdata_i,
2659
input logic instr_err_i,
2760

28-
// Data memory interface
61+
// Data memory interface (OBI)
2962
output logic data_req_o,
3063
input logic data_gnt_i,
3164
input logic data_rvalid_i,
@@ -40,28 +73,36 @@ module core_wrap import croc_pkg::*; #() (
4073
input logic debug_req_i,
4174

4275
// CPU Control Signals
76+
// fetch_enable_i: gates instruction fetch; ignore if core has no such signal
4377
input logic fetch_enable_i,
4478

79+
// core_busy_o: power-management hint to the SoC; drive 1'b0 if not available
4580
output logic core_busy_o
4681
);
4782

48-
// Base address of the debug module in the memory map.
83+
// CVE2: debug halt/exception vectors are provided as runtime inputs.
84+
// Cores that hardcode these addresses internally do not need these params.
85+
// Remove the localparams and connections below when replacing with such a core.
86+
// Make sure to check PeriphDebug's start_addr in croc_pkg and adjust if necesary.
4987
localparam bit [31:0] DebugAddrOffset = get_periph_start_addr(PeriphDebug);
5088
localparam bit [31:0] DebugHaltAddress = DebugAddrOffset + dm::HaltAddress[31:0];
5189
localparam bit [31:0] DebugExceptionAddress = DebugAddrOffset + dm::ExceptionAddress[31:0];
5290

53-
// lowest 8 bits are ignored internally
54-
logic[31:0] ibex_boot_addr;
55-
assign ibex_boot_addr = boot_addr_i & 32'hFFFFFF00;
91+
// CVE2 ignores the lowest 8 bits of boot_addr internally; mask here to avoid confusion.
92+
// You may want to remove this masking when using a core that uses the full boot address.
93+
logic [31:0] boot_addr_masked;
94+
assign boot_addr_masked = boot_addr_i & 32'hFFFFFF00;
5695

57-
// CV-X-IF tie-offs (extension disabled)
96+
// CV-X-IF tie-offs: CVE2-specific co-processor extension interface, disabled here.
97+
// Remove this block entirely when replacing CVE2 with another core.
98+
// If you want to use CV-X-IF, instantiate your accelerator here and connect the x_* signals.
5899
cve2_pkg::x_issue_resp_t x_issue_resp;
59100
cve2_pkg::x_result_t x_result;
60101
always_comb begin
61102
x_issue_resp = '0;
62103
x_result = '0;
63104
end
64-
// ifdef ordered according to priority
105+
65106
`ifdef TRACE_EXECUTION
66107
cve2_core_tracing #(
67108
`else
@@ -78,22 +119,22 @@ module core_wrap import croc_pkg::*; #() (
78119
.DbgTriggerEn ( 1'b1 ),
79120
.DbgHwBreakNum ( 1 ),
80121
.XInterface ( 1'b0 )
81-
) i_ibex (
122+
) i_core (
82123
.clk_i,
83124
.rst_ni,
84-
.test_en_i ( test_enable_i ),
85-
.hart_id_i ( 32'd0 ),
86-
.boot_addr_i ( ibex_boot_addr ),
125+
.test_en_i ( test_enable_i ),
126+
.hart_id_i ( 32'd0 ),
127+
.boot_addr_i ( boot_addr_masked ),
87128

88-
// Instruction Memory Interface:
129+
// Instruction Memory Interface (OBI):
89130
.instr_req_o,
90131
.instr_gnt_i,
91132
.instr_rdata_i,
92133
.instr_rvalid_i,
93134
.instr_addr_o,
94135
.instr_err_i,
95136

96-
// Data memory interface:
137+
// Data memory interface (OBI):
97138
.data_req_o,
98139
.data_gnt_i,
99140
.data_rvalid_i,
@@ -104,16 +145,16 @@ module core_wrap import croc_pkg::*; #() (
104145
.data_rdata_i,
105146
.data_err_i,
106147

107-
// Core-V Extension Interface (disabled)
108-
.x_issue_valid_o ( ),
148+
// Core-V Extension Interface (CV-X-IF):
149+
.x_issue_valid_o (),
109150
.x_issue_ready_i ( 1'b1 ),
110-
.x_issue_req_o ( ),
151+
.x_issue_req_o (),
111152
.x_issue_resp_i ( x_issue_resp ),
112-
.x_register_o ( ),
113-
.x_commit_valid_o ( ),
114-
.x_commit_o ( ),
153+
.x_register_o (),
154+
.x_commit_valid_o (),
155+
.x_commit_o (),
115156
.x_result_valid_i ( 1'b0 ),
116-
.x_result_ready_o ( ),
157+
.x_result_ready_o (),
117158
.x_result_i ( x_result ),
118159

119160
// Interrupts
@@ -122,14 +163,16 @@ module core_wrap import croc_pkg::*; #() (
122163
.irq_external_i ( 1'b0 ),
123164
.irq_fast_i ( irqs_i ),
124165
.irq_nm_i ( 1'b0 ),
125-
.irq_pending_o ( ),
166+
.irq_pending_o (),
126167

168+
// Debug Interface
127169
.debug_req_i,
128-
.debug_halted_o ( ),
170+
.debug_halted_o (),
129171
.dm_halt_addr_i ( DebugHaltAddress ),
130172
.dm_exception_addr_i ( DebugExceptionAddress ),
131-
.crash_dump_o ( ),
173+
.crash_dump_o (),
132174

175+
// CPU Control Signals
133176
.fetch_enable_i,
134177
.core_busy_o
135178
);

rtl/croc_domain.sv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ module croc_domain import croc_pkg::*; #(
221221
) i_core_wrap (
222222
.clk_i,
223223
.rst_ni,
224-
.ref_clk_i,
225224
.test_enable_i ( testmode_i ),
226225

227226
.irqs_i ( interrupts ),

0 commit comments

Comments
 (0)