OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [datasheet/] [soc.adoc] - Blame information for rev 64

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 60 zero_gravi
 
2
// ####################################################################################################################
3
:sectnums:
4
== NEORV32 Processor (SoC)
5
 
6
The NEORV32 Processor is based on the NEORV32 CPU. Together with common peripheral
7
interfaces and embedded memories it provides a RISC-V-based full-scale microcontroller-like SoC platform.
8
 
9
image::neorv32_processor.png[align=center]
10
 
11
**Key Features**
12
 
13
* _optional_ processor-internal data and instruction memories (<<_data_memory_dmem,**DMEM**>>/<<_instruction_memory_imem,**IMEM**>>) + cache (<<_processor_internal_instruction_cache_icache,**iCACHE**>>)
14
* _optional_ internal bootloader (<<_bootloader_rom_bootrom,**BOOTROM**>>) with UART console & SPI flash boot option
15
* _optional_ machine system timer (<<_machine_system_timer_mtime,**MTIME**>>), RISC-V-compatible
16
* _optional_ two independent universal asynchronous receivers and transmitters (<<_primary_universal_asynchronous_receiver_and_transmitter_uart0,**UART0**>>, <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,**UART1**>>) with optional hardware flow control (RTS/CTS)
17
* _optional_ 8/16/24/32-bit serial peripheral interface controller (<<_serial_peripheral_interface_controller_spi,**SPI**>>) with 8 dedicated CS lines
18
* _optional_ two wire serial interface controller (<<_two_wire_serial_interface_controller_twi,**TWI**>>), compatible to the I²C standard
19 61 zero_gravi
* _optional_ general purpose parallel IO port (<<_general_purpose_input_and_output_port_gpio,**GPIO**>>), 64xOut, 64xIn
20 60 zero_gravi
* _optional_ 32-bit external bus interface, Wishbone b4 / AXI4-Lite compatible (<<_processor_external_memory_interface_wishbone_axi4_lite,**WISHBONE**>>)
21 61 zero_gravi
* _optional_ 32-bit stream link interface with up to 8 independent links, AXI4-Stream compatible (<<_stream_link_interface_slink,**SLINK**>>)
22 60 zero_gravi
* _optional_ watchdog timer (<<_watchdog_timer_wdt,**WDT**>>)
23
* _optional_ PWM controller with up to 60 channels & 8-bit duty cycle resolution (<<_pulse_width_modulation_controller_pwm,**PWM**>>)
24
* _optional_ ring-oscillator-based true random number generator (<<_true_random_number_generator_trng,**TRNG**>>)
25
* _optional_ custom functions subsystem for custom co-processor extensions (<<_custom_functions_subsystem_cfs,**CFS**>>)
26
* _optional_ NeoPixel(TM)/WS2812-compatible smart LED interface (<<_smart_led_interface_neoled,**NEOLED**>>)
27 61 zero_gravi
* _optional_ external interrupt controller with up to 32 channels (<<_external_interrupt_controller_xirq,**XIRQ**>>)
28 60 zero_gravi
* _optional_ on-chip debugger with JTAG TAP (<<_on_chip_debugger_ocd,**OCD**>>)
29
* system configuration information memory to check HW configuration via software (<<_system_configuration_information_memory_sysinfo,**SYSINFO**>>)
30
 
31
 
32
<<<
33
// ####################################################################################################################
34
:sectnums:
35
=== Processor Top Entity - Signals
36
 
37 62 zero_gravi
The following table shows signals of the processor top entity (`rtl/core/neorv32_top.vhd`).
38
The type of all signals is `std_ulogic` or `std_ulogic_vector`, respectively.
39 60 zero_gravi
 
40 62 zero_gravi
[IMPORTAN]
41
All _input signals_ provide default values in case they are not explicitly assigned during instantiation.
42
For control signals the value `L` (weak pull-down) is used. For serial and parallel data signals
43
the value `U` (unknown) is used. Pulled-down signals will not cause "accidental" system crashes
44
since all control signals have defined level.
45 60 zero_gravi
 
46
[cols="<3,^2,^2,<11"]
47
[options="header",grid="rows"]
48
|=======================
49
| Signal | Width | Dir. | Function
50
4+^| **Global Control**
51
| `clk_i` | 1 | in | global clock line, all registers triggering on rising edge
52
| `rstn_i` | 1 | in | global reset, asynchronous, **low-active**
53
4+^| **JTAG Access Port for <<_on_chip_debugger_ocd>>**
54
| `jtag_trst_i` | 1 | in  | TAP reset, low-active (optionalfootnote:[Pull high if not used.])
55 61 zero_gravi
| `jtag_tck_i`  | 1 | in  | serial clock
56
| `jtag_tdi_i`  | 1 | in  | serial data input
57
| `jtag_tdo_o`  | 1 | out | serial data outputfootnote:[If the on-chip debugger is not implemented (_ON_CHIP_DEBUGGER_EN_ = false) `jtag_tdi_i` is directly forwarded to `jtag_tdo_o` to maintain the JTAG chain.]
58
| `jtag_tms_i`  | 1 | in  | mode select
59 60 zero_gravi
4+^| **External Bus Interface (<<_processor_external_memory_interface_wishbone_axi4_lite,WISHBONE>>)**
60
| `wb_tag_o` | 3  | out | tag (access type identifier)
61
| `wb_adr_o` | 32 | out | destination address
62
| `wb_dat_i` | 32 | in | write data
63
| `wb_dat_o` | 32 | out | read data
64
| `wb_we_o`  | 1  | out | write enable ('0' = read transfer)
65
| `wb_sel_o` | 4  | out | byte enable
66
| `wb_stb_o` | 1  | out | strobe
67
| `wb_cyc_o` | 1  | out | valid cycle
68
| `wb_lock_o`| 1  | out | exclusive access request
69
| `wb_ack_i` | 1  | in | transfer acknowledge
70
| `wb_err_i` | 1  | in | transfer error
71
4+^| **Advanced Memory Control Signals**
72
| `fence_o`  | 1 | out | indicates an executed _fence_ instruction
73
| `fencei_o` | 1 | out | indicates an executed _fencei_ instruction
74 61 zero_gravi
4+^| **Stream Link Interface (<<_stream_link_interface_slink,SLINK>>)**
75
| `slink_tx_dat_o` | 8x32 | out | TX link _n_ data
76
| `slink_tx_val_o` |    8 | out | TX link _n_ data valid
77
| `slink_tx_rdy_i` |    8 | in  | TX link _n_ allowed to send
78
| `slink_rx_dat_i` | 8x32 | in  | RX link _n_ data
79
| `slink_rx_val_i` |    8 | in  | RX link _n_ data valid
80
| `slink_rx_rdy_o` |    8 | out | RX link _n_ ready to receive
81 60 zero_gravi
4+^| **General Purpose Inputs & Outputs (<<_general_purpose_input_and_output_port_gpio,GPIO>>)**
82 61 zero_gravi
| `gpio_o` | 64 | out | general purpose parallel output
83
| `gpio_i` | 64 | in | general purpose parallel input
84 60 zero_gravi
4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>>)**
85
| `uart0_txd_o` | 1 | out | UART0 serial transmitter
86
| `uart0_rxd_i` | 1 | in | UART0 serial receiver
87
| `uart0_rts_o` | 1 | out | UART0 RX ready to receive new char
88
| `uart0_cts_i` | 1 | in | UART0 TX allowed to start sending
89
4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>>)**
90
| `uart1_txd_o` | 1 | out | UART1 serial transmitter
91
| `uart1_rxd_i` | 1 | in | UART1 serial receiver
92
| `uart1_rts_o` | 1 | out | UART1 RX ready to receive new char
93
| `uart1_cts_i` | 1 | in | UART1 TX allowed to start sending
94
4+^| **Serial Peripheral Interface Controller (<<_serial_peripheral_interface_controller_spi,SPI>>)**
95
| `spi_sck_o` | 1 | out | SPI controller clock line
96
| `spi_sdo_o` | 1 | out | SPI serial data output
97
| `spi_sdi_i` | 1 | in | SPI serial data input
98
| `spi_csn_o` | 8 | out | SPI dedicated chip select (low-active)
99
4+^| **Two-Wire Interface Controller (<<_two_wire_serial_interface_controller_twi,TWI>>)**
100
| `twi_sda_io` | 1 | inout | TWI serial data line
101
| `twi_scl_io` | 1 | inout | TWI serial clock line
102 64 zero_gravi
4+^| **Pulse-Width Modulation Channels (<<_pulse_width_modulation_controller_pwm,PWM>>)**
103
| `pwm_o` | 0..60 | out | pulse-width modulated channels
104 60 zero_gravi
4+^| **Custom Functions Subsystem (<<_custom_functions_subsystem_cfs,CFS>>)**
105
| `cfs_in_i`  | 32 | in | custom CFS input signal conduit
106
| `cfs_out_o` | 32 | out | custom CFS output signal conduit
107
4+^| **Smart LED Interface - NeoPixel(TM) compatible (<<_smart_led_interface_neoled,NEOLED>>)**
108
| `neoled_o` | 1 | out | asynchronous serial data output
109
4+^| **System time (<<_machine_system_timer_mtime,MTIME>>)**
110
| `mtime_i` | 64 | in  | machine timer time (to `time[h]` CSRs) from _external MTIME_ unit if the processor-internal _MTIME_ unit is NOT implemented
111
| `mtime_o` | 64 | out | machine timer time from _internal MTIME_ unit if processor-internal _MTIME_ unit IS implemented
112 64 zero_gravi
4+^| **External Interrupts (<<_processor_interrupts, XIRQ>>)**
113 61 zero_gravi
| `xirq_i` | 32 | in | external interrupt requests (up to 32 channels)
114 64 zero_gravi
4+^| **RISC-V Machine-Level <<_processor_interrupts, CPU Interrupts>>**
115
| `mtime_irq_i` | 1 | in | machine timer interrupt13 (RISC-V), high-active
116
| `msw_irq_i`   | 1 | in | machine software interrupt (RISC-V), high-active
117
| `mext_irq_i`  | 1 | in | machine external interrupt (RISC-V), high-active
118 60 zero_gravi
|=======================
119
 
120
 
121
<<<
122
// ####################################################################################################################
123
:sectnums:
124
=== Processor Top Entity - Generics
125
 
126
This is a list of all configuration generics of the NEORV32 processor top entity rtl/neorv32_top.vhd.
127
The generic name is shown in orange, followed by the type in printed in black and concluded by the default
128
value printed in light gray.
129
 
130
[TIP]
131
The NEORV32 generics allow to configure the system according to your needs. The generics are
132
used to control implementation of certain CPU extensions and peripheral modules and even allow to
133 63 zero_gravi
optimize the system for certain design goals like minimal area or maximum performance. +
134
**More information can be found in the user guides' section
135
https://stnolting.github.io/neorv32/ug/#_application_specific_processor_configuration[Application-Specific Processor Configuration]**.
136 60 zero_gravi
 
137
[TIP]
138 63 zero_gravi
Privileged software can determine the actual CPU and processor configuration via the `misa` and the
139 64 zero_gravi
<<_system_configuration_information_memory_sysinfo, SYSINFO>> registers.
140 60 zero_gravi
 
141 63 zero_gravi
[NOTE]
142
If optional modules (like CPU extensions or peripheral devices) are *not enabled* the according circuitry
143
**will not be synthesized at all**. Hence, the disabled modules do not increase area and power requirements
144
and do not impact the timing.
145 60 zero_gravi
 
146 63 zero_gravi
[NOTE]
147 61 zero_gravi
Not all configuration combinations are valid. The processor RTL code provides sanity checks to inform the user
148
during synthesis/simulation if an invalid combination has been detected.
149 60 zero_gravi
 
150 61 zero_gravi
**Generic Description**
151 60 zero_gravi
 
152 61 zero_gravi
The description of each generic provides the following summary:
153
 
154 60 zero_gravi
.Generic description
155
[cols="4,4,2"]
156
[frame="all",grid="none"]
157
|======
158 61 zero_gravi
| _Generic name_ | _type_ | _default value_
159 60 zero_gravi
3+| _Description_
160
|======
161
 
162
<<<
163
// ####################################################################################################################
164
:sectnums:
165
==== General
166
 
167
See section <<_system_configuration_information_memory_sysinfo>> for more information.
168
 
169
:sectnums!:
170
===== _CLOCK_FREQUENCY_
171
 
172
[cols="4,4,2"]
173
[frame="all",grid="none"]
174
|======
175 62 zero_gravi
| **CLOCK_FREQUENCY** | _natural_ | _none_
176 63 zero_gravi
3+| The clock frequency of the processor's `clk_i` input port in Hertz (Hz). This value can be retrieved by software
177
from the <<_system_configuration_information_memory_sysinfo, SYSINFO>> module.
178 60 zero_gravi
|======
179
 
180
 
181
:sectnums!:
182 61 zero_gravi
===== _INT_BOOTLOADER_EN_
183 60 zero_gravi
 
184
[cols="4,4,2"]
185
[frame="all",grid="none"]
186
|======
187 62 zero_gravi
| **INT_BOOTLOADER_EN** | _boolean_ | false
188 61 zero_gravi
3+| Implement the processor-internal boot ROM, pre-initialized with the default bootloader image when _true_.
189
This will also change the processor's boot address from the beginning of the instruction memory address space (default =
190
0x00000000) to the base address of the boot ROM. See section <<_boot_configuration>> for more information.
191 60 zero_gravi
|======
192
 
193
 
194
:sectnums!:
195
===== _HW_THREAD_ID_
196
 
197
[cols="4,4,2"]
198
[frame="all",grid="none"]
199
|======
200
| **HW_THREAD_ID** | _natural_ | 0
201 63 zero_gravi
3+| The hart ID of the CPU. Software can retrieve this value from the `mhartid` CSR.
202
Note that hart IDs must be unique within a system.
203 60 zero_gravi
|======
204
 
205
 
206
:sectnums!:
207
===== _ON_CHIP_DEBUGGER_EN_
208
 
209
[cols="4,4,2"]
210
[frame="all",grid="none"]
211
|======
212
| **ON_CHIP_DEBUGGER_EN** | _boolean_ | false
213 63 zero_gravi
3+| Implement the on-chip debugger (OCD) and the CPU debug mode.
214
See chapter <<_on_chip_debugger_ocd>> for more information.
215 60 zero_gravi
|======
216
 
217
 
218
// ####################################################################################################################
219
:sectnums:
220
==== RISC-V CPU Extensions
221
 
222 63 zero_gravi
[TIP]
223
See section <<_instruction_sets_and_extensions>> for more information. The configuration of the RISC-V _main_ ISA extensions
224
(like `M`) can be determined via the <<_misa>> CSR. The configuration of ISA _sub-extensions_ (like `Zicsr`) and _extension options_
225
can be determined via memory-mapped registers of the <<_system_configuration_information_memory_sysinfo>> module.
226 60 zero_gravi
 
227
 
228
:sectnums!:
229
===== _CPU_EXTENSION_RISCV_A_
230
 
231
[cols="4,4,2"]
232
[frame="all",grid="none"]
233
|======
234
| **CPU_EXTENSION_RISCV_A** | _boolean_ | false
235
3+| Implement atomic memory access operations when _true_.
236 61 zero_gravi
See section <<_a_atomic_memory_access>>.
237 60 zero_gravi
|======
238
 
239
 
240
:sectnums!:
241
===== _CPU_EXTENSION_RISCV_C_
242
 
243
[cols="4,4,2"]
244
[frame="all",grid="none"]
245
|======
246
| **CPU_EXTENSION_RISCV_C** | _boolean_ | false
247 63 zero_gravi
3+| Implement compressed instructions (16-bit) when _true_. Compressed instructions can reduce program code
248
size by approx. 30%. See section <<_c_compressed_instructions>>.
249 60 zero_gravi
|======
250
 
251
 
252
:sectnums!:
253
===== _CPU_EXTENSION_RISCV_E_
254
 
255
[cols="4,4,2"]
256
[frame="all",grid="none"]
257
|======
258
| **CPU_EXTENSION_RISCV_E** | _boolean_ | false
259 63 zero_gravi
3+| Implement the embedded CPU extension (only implement the first 16 data registers) when _true_. This reduces embedded memory
260
requirements for the register file. See section <<_e_embedded_cpu>> for more information. Note that this RISC-V extensions
261
requires a different application binary interface (ABI).
262 60 zero_gravi
|======
263
 
264
 
265
:sectnums!:
266
===== _CPU_EXTENSION_RISCV_M_
267
 
268
[cols="4,4,2"]
269
[frame="all",grid="none"]
270
|======
271
| **CPU_EXTENSION_RISCV_M** | _boolean_ | false
272 63 zero_gravi
3+| Implement hardware accelerators for integer multiplication and division instructions when _true_.
273
If this extensions is not enabled, multiplication and division operations (_not_ instructions) will be computed entirely in software.
274
If only a hardware multiplier is required use the <<_cpu_extension_riscv_zmmul>> extension. Multiplication can also be mapped
275
to DSP slices via the <<_fast_mul_en>> generic.
276
See section <<_m_integer_multiplication_and_division>> for more information.
277 60 zero_gravi
|======
278
 
279
 
280
:sectnums!:
281
===== _CPU_EXTENSION_RISCV_U_
282
 
283
[cols="4,4,2"]
284
[frame="all",grid="none"]
285
|======
286
| **CPU_EXTENSION_RISCV_U** | _boolean_ | false
287
3+| Implement less-privileged user mode when _true_.
288 63 zero_gravi
See section <<_u_less_privileged_user_mode>> for more information.
289 60 zero_gravi
|======
290
 
291
 
292
:sectnums!:
293 63 zero_gravi
===== _CPU_EXTENSION_RISCV_Zbb_
294
 
295
[cols="4,4,2"]
296
[frame="all",grid="none"]
297
|======
298
| **CPU_EXTENSION_RISCV_Zbb** | _boolean_ | false
299
3+| Implement the `Zbb` _basic_ bit-manipulation sub-extension when _true_.
300
See section <<_zbb_basic_bit_manipulation_operations>> for more information.
301
|======
302
 
303
 
304
:sectnums!:
305 60 zero_gravi
===== _CPU_EXTENSION_RISCV_Zfinx_
306
 
307
[cols="4,4,2"]
308
[frame="all",grid="none"]
309
|======
310
| **CPU_EXTENSION_RISCV_Zfinx** | _boolean_ | false
311 61 zero_gravi
3+| Implement the 32-bit single-precision floating-point extension (using integer registers) when _true_.
312 63 zero_gravi
See section <<_zfinx_single_precision_floating_point_operations>> for more information.
313 60 zero_gravi
|======
314
 
315
 
316
:sectnums!:
317
===== _CPU_EXTENSION_RISCV_Zicsr_
318
 
319
[cols="4,4,2"]
320
[frame="all",grid="none"]
321
|======
322
| **CPU_EXTENSION_RISCV_Zicsr** | _boolean_ | true
323
3+| Implement the control and status register (CSR) access instructions when true. Note: When this option is
324
disabled, the complete privileged architecture / trap system will be excluded from synthesis. Hence, no interrupts, no exceptions and
325
no machine information will be available.
326 63 zero_gravi
See section <<_zicsr_control_and_status_register_access_privileged_architecture>> for more information.
327 60 zero_gravi
|======
328
 
329
 
330
:sectnums!:
331
===== _CPU_EXTENSION_RISCV_Zifencei_
332
 
333
[cols="4,4,2"]
334
[frame="all",grid="none"]
335
|======
336
| **CPU_EXTENSION_RISCV_Zifencei** | _boolean_ | false
337 61 zero_gravi
3+| Implement the instruction fetch synchronization instruction `fence.i`. For example, this option is required
338 63 zero_gravi
for self-modifying code (and/or for instruction cache and CPU prefetch buffer flushes).
339
See section <<_zifencei_instruction_stream_synchronization>> for more information.
340 60 zero_gravi
|======
341
 
342
 
343 61 zero_gravi
:sectnums!:
344
===== _CPU_EXTENSION_RISCV_Zmmul_
345
 
346
[cols="4,4,2"]
347
[frame="all",grid="none"]
348
|======
349
| **CPU_EXTENSION_RISCV_Zmmul** | _boolean_ | false
350 63 zero_gravi
3+| Implement integer multiplication-only instructions when _true_. This is a sub-extension of the `M` extension, which
351
cannot be used together with the `M` extension. See section <<_zmmul_integer_multiplication>> for more information.
352 61 zero_gravi
|======
353
 
354
 
355 60 zero_gravi
// ####################################################################################################################
356
:sectnums:
357
==== Extension Options
358
 
359
See section <<_instruction_sets_and_extensions>> for more information.
360
 
361
 
362
:sectnums!:
363
===== _FAST_MUL_EN_
364
 
365
[cols="4,4,2"]
366
[frame="all",grid="none"]
367
|======
368
| **FAST_MUL_EN** | _boolean_ | false
369 63 zero_gravi
3+| When this generic is enabled, the multiplier of the `M` extension is implemented using DSPs blocks instead of an
370
iterative bit-serial approach. Performance will be increased and LUT utilization will be reduced at the cost of DSP slice
371
utilization. This generic is only relevant when a hardware multiplier CPU extension is
372
enabled (<<_cpu_extension_riscv_m>> or <<_cpu_extension_riscv_zmmul>> is _true_). **Note that the multipliers of the
373
<<_zfinx_single_precision_floating_point_operations>> extension are always mapped to DSP block (if available).**
374 60 zero_gravi
|======
375
 
376
 
377
:sectnums!:
378
===== _FAST_SHIFT_EN_
379
 
380
[cols="4,4,2"]
381
[frame="all",grid="none"]
382
|======
383
| **FAST_SHIFT_EN** | _boolean_ | false
384 63 zero_gravi
3+| If this generic is set _true_ the shifter unit of the CPU's ALU is implemented as fast barrel shifter (requiring
385
more hardware resources but completing within two clock cycles). If it is set _false_, the CPU uses a serial shifter
386
that only performs a single bit shift per cycle (requiring less hardware resources, but requires up to 32 clock
387
cycles to complete - depending on shift amount). **Note that this option also implements barrel shifters for _all_
388
shift-related operations of the <<_zbb_basic_bit_manipulation_operations>> extension.**
389 60 zero_gravi
|======
390
 
391
 
392
:sectnums!:
393
===== _CPU_CNT_WIDTH_
394
 
395
[cols="4,4,2"]
396
[frame="all",grid="none"]
397
|======
398 62 zero_gravi
| **CPU_CNT_WIDTH** | _natural_ | 64
399 64 zero_gravi
3+| This generic configures the total size of the CPU's `[m]cycle` and `[m]instret` CSRs (low word + high word).
400 63 zero_gravi
The maximum value is 64, the minimum value is 0. See section <<_machine_counters_and_timers>> for more information.
401
Note: configurations with <<_cpu_cnt_width>> less than 64 bits do not comply to the RISC-V specs.
402 60 zero_gravi
|======
403
 
404
 
405 62 zero_gravi
:sectnums!:
406
===== _CPU_IPB_ENTRIES_
407
 
408
[cols="4,4,2"]
409
[frame="all",grid="none"]
410
|======
411
| **CPU_IPB_ENTRIES** | _natural_ | 2
412
3+| This generic configures the number of entries in the CPU's instruction prefetch buffer (a FIFO).
413
The value has to be a power of two and has to be greater than zero.
414 63 zero_gravi
Long linear sequences of code can benefit from an increased IPB size.
415 62 zero_gravi
|======
416
 
417
 
418 60 zero_gravi
// ####################################################################################################################
419
:sectnums:
420
==== Physical Memory Protection (PMP)
421
 
422
See section <<_pmp_physical_memory_protection>> for more information.
423
 
424
 
425
:sectnums!:
426
===== _PMP_NUM_REGIONS_
427
 
428
[cols="4,4,2"]
429
[frame="all",grid="none"]
430
|======
431
| **PMP_NUM_REGIONS** | _natural_ | 0
432
3+| Total number of implemented protections regions (0..64). If this generics is zero no physical memory
433 63 zero_gravi
protection logic will be implemented at all. Setting <<_pmp_num_regions>>_ > 0 will set the _SYSINFO_CPU_PMP_ flag
434 64 zero_gravi
in the `CPU` <<_system_configuration_information_memory_sysinfo, SYSINFO>> register.
435 60 zero_gravi
|======
436
 
437
 
438
:sectnums!:
439
===== _PMP_MIN_GRANULARITY_
440
 
441
[cols="4,4,2"]
442
[frame="all",grid="none"]
443
|======
444
| **PMP_MIN_GRANULARITY** | _natural_ | 64*1024
445
3+| Minimal region granularity in bytes. Has to be a power of two. Has to be at least 8 bytes.
446
|======
447
 
448
 
449
// ####################################################################################################################
450
:sectnums:
451
==== Hardware Performance Monitors (HPM)
452
 
453
See section <<_hpm_hardware_performance_monitors>> for more information.
454
 
455
 
456
:sectnums!:
457
===== _HPM_NUM_CNTS_
458
 
459
[cols="4,4,2"]
460
[frame="all",grid="none"]
461
|======
462
| **HPM_NUM_CNTS** | _natural_ | 0
463 63 zero_gravi
3+| Total number of implemented hardware performance monitor counters (0..29). If this generics is zero, no
464
hardware performance monitor logic will be implemented at all. Setting <<_hpm_num_cnts>> > 0 will set the _SYSINFO_CPU_HPM_ flag
465 64 zero_gravi
in the `CPU` <<_system_configuration_information_memory_sysinfo, SYSINFO>> register.
466 60 zero_gravi
|======
467
 
468
 
469
:sectnums!:
470
===== _HPM_CNT_WIDTH_
471
 
472
[cols="4,4,2"]
473
[frame="all",grid="none"]
474
|======
475
| **HPM_CNT_WIDTH** | _natural_ | 40
476 63 zero_gravi
3+| This generic defines the total LSB-aligned size of each HPM counter (`size([m]hpmcounter*h)` +
477
`size([m]hpmcounter*)`). The maximum value is 64, the minimal is 0. If the size is less than 64-bit, the
478 60 zero_gravi
unused MSB-aligned counter bits are hardwired to zero.
479
|======
480
 
481
 
482
// ####################################################################################################################
483
:sectnums:
484
==== Internal Instruction Memory
485
 
486
See sections <<_address_space>> and <<_instruction_memory_imem>> for more information.
487
 
488
 
489
:sectnums!:
490
===== _MEM_INT_IMEM_EN_
491
 
492
[cols="4,4,2"]
493
[frame="all",grid="none"]
494
|======
495 62 zero_gravi
| **MEM_INT_IMEM_EN** | _boolean_ | false
496 60 zero_gravi
3+| Implement processor internal instruction memory (IMEM) when _true_.
497
|======
498
 
499
 
500
:sectnums!:
501
===== _MEM_INT_IMEM_SIZE_
502
 
503
[cols="4,4,2"]
504
[frame="all",grid="none"]
505
|======
506
| **MEM_INT_IMEM_SIZE** | _natural_ | 16*1024
507 63 zero_gravi
3+| Size in bytes of the processor internal instruction memory (IMEM). Has no effect when <<_mem_int_imem_en>> is _false_.
508 60 zero_gravi
|======
509
 
510
 
511
// ####################################################################################################################
512
:sectnums:
513
==== Internal Data Memory
514
 
515
See sections <<_address_space>> and <<_data_memory_dmem>> for more information.
516
 
517
 
518
:sectnums!:
519
===== _MEM_INT_DMEM_EN_
520
 
521
[cols="4,4,2"]
522
[frame="all",grid="none"]
523
|======
524 62 zero_gravi
| **MEM_INT_DMEM_EN** | _boolean_ | false
525 60 zero_gravi
3+| Implement processor internal data memory (DMEM) when _true_.
526
|======
527
 
528
 
529
:sectnums!:
530
===== _MEM_INT_DMEM_SIZE_
531
 
532
[cols="4,4,2"]
533
[frame="all",grid="none"]
534
|======
535
| **MEM_INT_DMEM_SIZE** | _natural_ | 8*1024
536 63 zero_gravi
3+| Size in bytes of the processor-internal data memory (DMEM). Has no effect when <<_mem_int_dmem_en>> is _false_.
537 60 zero_gravi
|======
538
 
539
 
540
// ####################################################################################################################
541
:sectnums:
542
==== Internal Cache Memory
543
 
544
See section <<_processor_internal_instruction_cache_icache>> for more information.
545
 
546
 
547
:sectnums!:
548
===== _ICACHE_EN_
549
 
550
[cols="4,4,2"]
551
[frame="all",grid="none"]
552
|======
553
| **ICACHE_EN** | _boolean_ | false
554 63 zero_gravi
3+| Implement processor internal instruction cache when _true_. Note: if the setup only uses processor-internal data
555
and instruction memories there is not point of implementing the i-cache.
556 60 zero_gravi
|======
557
 
558
 
559
:sectnums!:
560
===== _ICACHE_NUM_BLOCK_
561
 
562
[cols="4,4,2"]
563
[frame="all",grid="none"]
564
|======
565
| **ICACHE_NUM_BLOCKS** | _natural_ | 4
566
3+| Number of blocks (cache "pages" or "lines") in the instruction cache. Has to be a power of two. Has no
567 63 zero_gravi
effect when <<_icache_dmem_en>> is false.
568 60 zero_gravi
|======
569
 
570
 
571
:sectnums!:
572
===== _ICACHE_BLOCK_SIZE_
573
 
574
[cols="4,4,2"]
575
[frame="all",grid="none"]
576
|======
577
| **ICACHE_BLOCK_SIZE** | _natural_ | 64
578
3+| Size in bytes of each block in the instruction cache. Has to be a power of two. Has no effect when
579 63 zero_gravi
<<_icache_dmem_en>> is _false_.
580 60 zero_gravi
|======
581
 
582
 
583
:sectnums!:
584
===== _ICACHE_ASSOCIATIVITY_
585
 
586
[cols="4,4,2"]
587
[frame="all",grid="none"]
588
|======
589
| **ICACHE_ASSOCIATIVITY** | _natural_ | 1
590
3+| Associativity (= number of sets) of the instruction cache. Has to be a power of two. Allowed configurations:
591 63 zero_gravi
`1` = 1 set, direct mapped; `2` = 2-way set-associative. Has no effect when <<_icache_dmem_en>> is _false_.
592 60 zero_gravi
|======
593
 
594
 
595
// ####################################################################################################################
596
:sectnums:
597
==== External Memory Interface
598
 
599
See sections <<_address_space>> and <<_processor_external_memory_interface_wishbone_axi4_lite>> for more information.
600
 
601
 
602
:sectnums!:
603
===== _MEM_EXT_EN_
604
 
605
[cols="4,4,2"]
606
[frame="all",grid="none"]
607
|======
608
| **MEM_EXT_EN** | _boolean_ | false
609
3+| Implement external bus interface (WISHBONE) when _true_.
610
|======
611
 
612
 
613
:sectnums!:
614
===== _MEM_EXT_TIMEOUT_
615
 
616
[cols="4,4,2"]
617
[frame="all",grid="none"]
618
|======
619
| **MEM_EXT_TIMEOUT** | _natural_ | 255
620 63 zero_gravi
3+| Clock cycles after which a pending external bus access will auto-terminate and raise a bus fault exception.
621
If set to zero, there will be no auto-timeout and no bus fault exception (might permanently stall system!).
622 60 zero_gravi
|======
623
 
624
 
625 62 zero_gravi
:sectnums!:
626
===== _MEM_EXT_PIPE_MODE_
627
 
628
[cols="4,4,2"]
629
[frame="all",grid="none"]
630
|======
631
| **MEM_EXT_PIPE_MODE** | _boolean_ | false
632 63 zero_gravi
3+| Use _standard_ ("classic") Wishbone protocol for external bus when _false_.
633
Use _pipelined_ Wishbone protocol when _true_.
634 62 zero_gravi
|======
635
 
636
 
637
:sectnums!:
638
===== _MEM_EXT_BIG_ENDIAN_
639
 
640
[cols="4,4,2"]
641
[frame="all",grid="none"]
642
|======
643
| **MEM_EXT_BIG_ENDIAN** | _boolean_ | false
644 63 zero_gravi
3+| Use BIG endian interface for external bus when _true_. Use little endian interface when _false_.
645 62 zero_gravi
|======
646
 
647
 
648
:sectnums!:
649
===== _MEM_EXT_ASYNC_RX_
650
 
651
[cols="4,4,2"]
652
[frame="all",grid="none"]
653
|======
654
| **MEM_EXT_ASYNC_RX** | _boolen_ | false
655
3+| By default, _MEM_EXT_ASYNC_RX_ = _false_ implements a registered read-back path (RX) for incoming data in the bus interface
656
in order to shorten the critical path. By setting _MEM_EXT_ASYNC_RX_ = _true_ an _asynchronous_ ("direct") read-back path is
657 63 zero_gravi
implemented reducing access latency by one cycle but eventually increasing the critical path.
658 62 zero_gravi
|======
659
 
660
 
661 60 zero_gravi
// ####################################################################################################################
662
:sectnums:
663 61 zero_gravi
==== Stream Link Interface
664
 
665
See section <<_stream_link_interface_slink>> for more information.
666
 
667
 
668
:sectnums!:
669
===== _SLINK_NUM_TX_
670
 
671
[cols="4,4,2"]
672
[frame="all",grid="none"]
673
|======
674
| **SLINK_NUM_TX** | _natural_ | 0
675
3+| Number of TX (send) links to implement. Valid values are 0..8.
676
|======
677
 
678
 
679
:sectnums!:
680
===== _SLINK_NUM_RX_
681
 
682
[cols="4,4,2"]
683
[frame="all",grid="none"]
684
|======
685
| **SLINK_NUM_RX** | _natural_ | 0
686
3+| Number of RX (receive) links to implement. Valid values are 0..8.
687
|======
688
 
689
 
690
:sectnums!:
691
===== _SLINK_TX_FIFO_
692
 
693
[cols="4,4,2"]
694
[frame="all",grid="none"]
695
|======
696
| **SLINK_TX_FIFO** | _natural_ | 1
697
3+| Internal FIFO depth for _all_ implemented TX links. Valid values are 1..32k and have to be a power of two.
698
|======
699
 
700
 
701
:sectnums!:
702
===== _SLINK_RX_FIFO_
703
 
704
[cols="4,4,2"]
705
[frame="all",grid="none"]
706
|======
707
| **SLINK_RX_FIFO** | _natural_ | 1
708
3+| Internal FIFO depth for _all_ implemented RX links. Valid values are 1..32k and have to be a power of two.
709
|======
710
 
711
 
712
// ####################################################################################################################
713
:sectnums:
714
==== External Interrupt Controller
715
 
716
See section <<_external_interrupt_controller_xirq>> for more information.
717
 
718
 
719
:sectnums!:
720
===== _XIRQ_NUM_CH_
721
 
722
[cols="4,4,2"]
723
[frame="all",grid="none"]
724
|======
725
| **XIRQ_NUM_CH** | _natural_ | 0
726
3+| Number of external interrupt channels o implement. Valid values are 0..32.
727
|======
728
 
729
 
730
:sectnums!:
731
===== _XIRQ_TRIGGER_TYPE_
732
 
733
[cols="4,4,2"]
734
[frame="all",grid="none"]
735
|======
736
| **XIRQ_TRIGGER_TYPE** | _std_ulogic_vector(31 downto 0)_ | 0xFFFFFFFF
737
3+| Interrupt trigger type configuration (one bit for each IRQ channel): `0` = level-triggered, '1' = edge triggered.
738 63 zero_gravi
<<_xirq_trigger_polarity>> generic is used to specify the actual level (high/low) or edge (falling/rising).
739 61 zero_gravi
|======
740
 
741
 
742
:sectnums!:
743
===== _XIRQ_TRIGGER_POLARITY_
744
 
745
[cols="4,4,2"]
746
[frame="all",grid="none"]
747
|======
748
| **XIRQ_TRIGGER_POLARITY** | _std_ulogic_vector(31 downto 0)_ | 0xFFFFFFFF
749
3+| Interrupt trigger polarity configuration (one bit for each IRQ channel): `0` = low-level/falling-edge,
750 63 zero_gravi
'1' = high-level/rising-edge. <<_xirq_trigger_type>> generic is used to specify the actual type (level or edge).
751 61 zero_gravi
|======
752
 
753
 
754
// ####################################################################################################################
755
:sectnums:
756 60 zero_gravi
==== Processor Peripheral/IO Modules
757
 
758
See section <<_processor_internal_modules>> for more information.
759
 
760
 
761
:sectnums!:
762
===== _IO_GPIO_EN_
763
 
764
[cols="4,4,2"]
765
[frame="all",grid="none"]
766
|======
767 62 zero_gravi
| **IO_GPIO_EN** | _boolean_ | false
768 60 zero_gravi
3+| Implement general purpose input/output port unit (GPIO) when _true_.
769
See section <<_general_purpose_input_and_output_port_gpio>> for more information.
770
|======
771
 
772
 
773
:sectnums!:
774
===== _IO_MTIME_EN_
775
 
776
[cols="4,4,2"]
777
[frame="all",grid="none"]
778
|======
779 62 zero_gravi
| **IO_MTIME_EN** | _boolean_ | false
780 60 zero_gravi
3+| Implement machine system timer (MTIME) when _true_.
781
See section <<_machine_system_timer_mtime>> for more information.
782
|======
783
 
784
 
785
:sectnums!:
786
===== _IO_UART0_EN_
787
 
788
[cols="4,4,2"]
789
[frame="all",grid="none"]
790
|======
791 62 zero_gravi
| **IO_UART0_EN** | _boolean_ | false
792 60 zero_gravi
3+| Implement primary universal asynchronous receiver/transmitter (UART0) when _true_.
793
See section <<_primary_universal_asynchronous_receiver_and_transmitter_uart0>> for
794
more information.
795
|======
796
 
797
 
798
:sectnums!:
799
===== _IO_UART1_EN_
800
 
801
[cols="4,4,2"]
802
[frame="all",grid="none"]
803
|======
804 62 zero_gravi
| **IO_UART1_EN** | _boolean_ | false
805 61 zero_gravi
3+| Implement secondary universal asynchronous receiver/transmitter (UART1) when _true_.
806 60 zero_gravi
See section <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1>> for more information.
807
|======
808
 
809
 
810
:sectnums!:
811
===== _IO_SPI_EN_
812
 
813
[cols="4,4,2"]
814
[frame="all",grid="none"]
815
|======
816 62 zero_gravi
| **IO_SPI_EN** | _boolean_ | false
817 60 zero_gravi
3+| Implement serial peripheral interface controller (SPI) when _true_.
818
See section <<_serial_peripheral_interface_controller_spi>> for more information.
819
|======
820
 
821
 
822
:sectnums!:
823
===== _IO_TWI_EN_
824
 
825
[cols="4,4,2"]
826
[frame="all",grid="none"]
827
|======
828 62 zero_gravi
| **IO_TWI_EN** | _boolean_ | false
829 60 zero_gravi
3+| Implement two-wire interface controller (TWI) when _true_.
830
See section <<_two_wire_serial_interface_controller_twi>> for
831
more information.
832
|======
833
 
834
 
835
:sectnums!:
836
===== _IO_PWM_NUM_CH_
837
 
838
[cols="4,4,2"]
839
[frame="all",grid="none"]
840
|======
841 62 zero_gravi
| **IO_PWM_NUM_CH** | _natural_ | 0
842 60 zero_gravi
3+| Number of pulse-width modulation (PWM) channels (0..60) to implement. The PWM controller is _not_ implemented if zero.
843
See section <<_pulse_width_modulation_controller_pwm>> for more information.
844
|======
845
 
846
 
847
:sectnums!:
848
===== _IO_WDT_EN_
849
 
850
[cols="4,4,2"]
851
[frame="all",grid="none"]
852
|======
853 62 zero_gravi
| **IO_WDT_EN** | _boolean_ | false
854 60 zero_gravi
3+| Implement watchdog timer (WDT) when _true_. See section <<_watchdog_timer_wdt>> for more
855
information.
856
|======
857
 
858
 
859
:sectnums!:
860
===== _IO_TRNG_EN_
861
 
862
[cols="4,4,2"]
863
[frame="all",grid="none"]
864
|======
865
| **IO_TRNG_EN** | _boolean_ | false
866
3+| Implement true-random number generator (TRNG) when _true_. See section <<_true_random_number_generator_trng>> for more information.
867
|======
868
 
869
 
870
:sectnums!:
871
===== _IO_CFS_EN_
872
 
873
[cols="4,4,2"]
874
[frame="all",grid="none"]
875
|======
876
| **IO_CFS_EN** | _boolean_ | false
877
3+| Implement custom functions subsystem (CFS) when _true_. See section <<_custom_functions_subsystem_cfs>> for more information.
878
|======
879
 
880
 
881
:sectnums!:
882
===== _IO_CFS_CONFIG_
883
 
884
[cols="4,4,2"]
885
[frame="all",grid="none"]
886
|======
887
| **IO_CFS_CONFIG** | _std_ulogic_vector(31 downto 0)_ | 0x"00000000"
888
3+| This is a "conduit" generic that can be used to pass user-defined CFS implementation flags to the custom
889
functions subsystem entity. See section <<_custom_functions_subsystem_cfs>> for more information.
890
|======
891
 
892
 
893
:sectnums!:
894
===== _IO_CFS_IN_SIZE_
895
 
896
[cols="4,4,2"]
897
[frame="all",grid="none"]
898
|======
899
| **IO_CFS_IN_SIZE** | _positive_ | 32
900
3+| Defines the size of the CFS input signal conduit (`cfs_in_i`). See section <<_custom_functions_subsystem_cfs>> for more information.
901
|======
902
 
903
 
904
:sectnums!:
905
===== _IO_CFS_OUT_SIZE_
906
 
907
[cols="4,4,2"]
908
[frame="all",grid="none"]
909
|======
910
| **IO_CFS_OUT_SIZE** | _positive_ | 32
911
3+| Defines the size of the CFS output signal conduit (`cfs_out_o`). See section <<_custom_functions_subsystem_cfs>> for more information.
912
|======
913
 
914
 
915
:sectnums!:
916
===== _IO_NEOLED_EN_
917
 
918
[cols="4,4,2"]
919
[frame="all",grid="none"]
920
|======
921 62 zero_gravi
| **IO_NEOLED_EN** | _boolean_ | false
922 60 zero_gravi
3+| Implement smart LED interface (WS2812 / NeoPixel(TM)-compatible) (NEOLED) when _true_.
923
See section <<_smart_led_interface_neoled>> for more information.
924
|======
925
 
926
 
927 62 zero_gravi
:sectnums!:
928
===== _IO_NEOLED_TX_FIFO_
929
 
930
[cols="4,4,2"]
931
[frame="all",grid="none"]
932
|======
933
| **IO_NEOLED_TX_FIFO** | _natural_ | 1
934
3+| TX FIFO depth of the the NEOLED module. Minimal value is 1, maximal value is 32k, has to be a power of two.
935
See section <<_smart_led_interface_neoled>> for more information.
936
|======
937
 
938
 
939
 
940 60 zero_gravi
<<<
941
// ####################################################################################################################
942
:sectnums:
943
=== Processor Interrupts
944
 
945 61 zero_gravi
The NEORV32 Processor provides several interrupt request signals (IRQs) for custom platform use.
946 60 zero_gravi
 
947
 
948 61 zero_gravi
:sectnums:
949
==== RISC-V Standard Interrupts
950
 
951 62 zero_gravi
The processor setup features the standard machine-level RISC-V interrupt lines for "machine timer interrupt", "machine
952 61 zero_gravi
software interrupt" and "machine external interrupt". Their usage is defined by the RISC-V privileged architecture
953
specifications. However, bare-metal system can also repurpose these interrupts. See CPU section
954
<<_traps_exceptions_and_interrupts>> for more information.
955 60 zero_gravi
 
956 61 zero_gravi
[cols="<3,^2,<11"]
957
[options="header",grid="rows"]
958
|=======================
959
| Top signal | Width | Description
960
| `mtime_irq_i` | 1 | Machine timer interrupt from _processor-external_ MTIME unit. This IRQ is only available if the processor-internal MTIME unit is not used (<<_io_mtime_en>> = false).
961
| `msw_irq_i`   | 1 | Machine software interrupt. This interrupt is used for inter-processor interrupts in multi-core systems. However, it can also be used for any custom purpose.
962
| `mext_irq_i`  | 1 | Machine external interrupt. This interrupt is used for any processor-external interrupt source (like a platform interrupt controller).
963
|=======================
964 60 zero_gravi
 
965 64 zero_gravi
.Trigger type
966 62 zero_gravi
[IMPORTANT]
967 64 zero_gravi
These IRQs trigger on **high-level** and must _stay asserted_ until explicitly acknowledged by the CPU (for example
968
by writing to a specific memory-mapped register).
969 61 zero_gravi
 
970
 
971
:sectnums:
972
==== Platform External Interrupts
973
 
974
[cols="<3,^2,<11"]
975
[options="header",grid="rows"]
976
|=======================
977
| Top signal | Width | Description
978
| `xirq_i` | up to 32 | External platform interrupts (user-defined).
979
|=======================
980
 
981
The processor provides an optional interrupt controller for up to 32 user-defined external interrupts
982
(see section <<_external_interrupt_controller_xirq>>). These external IRQs are mapped to a _single_ CPU
983
fast interrupt request so a software handler is required to differentiate / prioritize these interrupts.
984
 
985 64 zero_gravi
.Trigger type
986
[IMPORTANT]
987 62 zero_gravi
The trigger for these interrupt can be defined via generics. See section
988 64 zero_gravi
<<_external_interrupt_controller_xirq>> for more information. Depending on the trigger type, users can
989
implement custom acknowledge mechanisms.
990 61 zero_gravi
 
991
 
992
:sectnums:
993
==== NEORV32-Specific Fast Interrupt Requests
994
 
995 60 zero_gravi
As part of the custom/NEORV32-specific CPU extensions, the CPU features 16 fast interrupt request signals
996 61 zero_gravi
(`FIRQ0` – `FIRQ15`). These are used for _processor-internal_ modules only (for example for the communication
997
interfaces to signal "available incoming data" or "ready to send new data").
998 60 zero_gravi
 
999 61 zero_gravi
The mapping of the 16 FIRQ channels is shown in the following table (the channel number also corresponds to
1000
the according FIRQ priority; 0 = highest, 15 = lowest):
1001 60 zero_gravi
 
1002
.NEORV32 fast interrupt channel mapping
1003
[cols="^1,<2,<7"]
1004
[options="header",grid="rows"]
1005
|=======================
1006
| Channel | Source | Description
1007 61 zero_gravi
| 0       | <<_watchdog_timer_wdt,WDT>> | watchdog timeout interrupt
1008
| 1       | <<_custom_functions_subsystem_cfs,CFS>> | custom functions subsystem (CFS) interrupt (user-defined)
1009
| 2       | <<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>> | UART0 data received interrupt (RX complete)
1010
| 3       | <<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>> | UART0 sending done interrupt (TX complete)
1011
| 4       | <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>> | UART1 data received interrupt (RX complete)
1012
| 5       | <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>> | UART1 sending done interrupt (TX complete)
1013
| 6       | <<_serial_peripheral_interface_controller_spi,SPI>> | SPI transmission done interrupt
1014
| 7       | <<_two_wire_serial_interface_controller_twi,TWI>> | TWI transmission done interrupt
1015
| 8       | <<_external_interrupt_controller_xirq,XIRQ>> | External interrupt controller interrupt
1016
| 9       | <<_smart_led_interface_neoled,NEOLED>> | NEOLED buffer TX empty / not full interrupt
1017
| 10      | <<_stream_link_interface_slink,SLINK>> | RX data received
1018
| 11      | <<_stream_link_interface_slink,SLINK>> | TX data send
1019 62 zero_gravi
| 12:15   | - | _reserved_, will never fire
1020 60 zero_gravi
|=======================
1021
 
1022 64 zero_gravi
.Trigger type
1023
[IMPORTANT]
1024
The fast interrupt request channel trigger on a single **rising-edge** and do not require any kind of explicit
1025
acknowledgment at all.
1026 60 zero_gravi
 
1027
 
1028 64 zero_gravi
 
1029 60 zero_gravi
<<<
1030
// ####################################################################################################################
1031
:sectnums:
1032
=== Address Space
1033
 
1034 61 zero_gravi
The NEORV32 Processor provides 32-bit physical addresses accessing up to 4GB of address space.
1035
By default, this address space is divided into four main regions:
1036 60 zero_gravi
 
1037 61 zero_gravi
1. **Instruction address space** – for instructions (=code) and constants. A configurable section of this address space is used by
1038
internal and/or external _instruction memory_ (IMEM).
1039
2. **Data address space** – for application runtime data (heap, stack, etc.). A configurable section of this address space is used by
1040
internal and/or external _data memory_ (DMEM).
1041
3. **Bootloader address space**. A _fixed_ section of this address space is used by
1042
internal _bootloader memory_ (BOOTLDROM).
1043
4. **IO/peripheral address space** – for the processor-internal IO/peripheral devices (e.g., UART).
1044 60 zero_gravi
 
1045
[TIP]
1046
These four memory regions are handled by the linker when compiling a NEORV32 executable.
1047
See section <<_executable_image_format>> for more information.
1048
 
1049 61 zero_gravi
.NEORV32 processor - address space (default configuration)
1050
image::address_space.png[900]
1051 60 zero_gravi
 
1052
 
1053
:sectnums:
1054
==== CPU Data and Instruction Access
1055
 
1056
The CPU can access all of the 4GB address space from the instruction fetch interface (**I**) and also from the
1057
data access interface (**D**). These two CPU interfaces are multiplexed by a simple bus switch
1058
(`rtl/core/neorv32_busswitch.vhd`) into a _single_ processor-internal bus. All processor-internal
1059
memories, peripherals and also the external memory interface are connected to this bus. Hence, both CPU
1060
interfaces (instruction fetch & data access) have access to the same (**identical**) address space making the
1061
setup a modified von-Neumann architecture.
1062
 
1063
.Processor-internal bus architecture
1064
image::neorv32_bus.png[1300]
1065
 
1066
[NOTE]
1067
The internal processor bus might appear as bottleneck. In order to reduce traffic jam on this bus
1068
(when instruction fetch and data interface access the bus at the same time) the instruction fetch of
1069
the CPU is equipped with a prefetch buffer. Instruction fetches can be further buffered using the i-cache.
1070
Furthermore, data accesses (loads and stores) have higher priority than instruction fetch
1071
accesses.
1072
 
1073
[IMPORTANT]
1074
Please note that all processor-internal components including the peripheral/IO devices can also be
1075
accessed from programs running in less-privileged user mode. For example, if the system relies on
1076
a periodic interrupt from the _MTIME_ timer unit, user-level programs could alter the _MTIME_
1077
configuration corrupting this interrupt. This kind of security issues can be compensated using the
1078
PMP system (see <<_machine_physical_memory_protection>>).
1079
 
1080 61 zero_gravi
 
1081 60 zero_gravi
:sectnums:
1082 61 zero_gravi
==== Address Space Layout
1083
 
1084
The general address space layout consists of two main configuration constants: `ispace_base_c` defining
1085
the base address of the _instruction memory address space_ and `dspace_base_c` defining the base address of
1086
the _data memory address space_. Both constants are defined in the NEORV32 VHDL package file
1087
`rtl/core/neorv32_package.vhd`:
1088
 
1089
[source,vhdl]
1090
----
1091
-- Architecture Configuration ----------------------------------------------------
1092
-- ----------------------------------------------------------------------------------
1093
constant ispace_base_c : std_ulogic_vector(31 downto 0) := x"00000000";
1094
constant dspace_base_c : std_ulogic_vector(31 downto 0) := x"80000000";
1095
----
1096
 
1097
The default configuration assumes the _instruction memory address space_ starting at address _0x00000000_
1098
and the _data memory address space_ starting at _0x80000000_. Both values can be modified for a specific
1099
setup and the address space may overlap or can be completely identical. Make sure that both base addresses
1100
are _aligned_ to a 4-byte boundary.
1101
 
1102
[NOTE]
1103
The base address of the internal bootloader (at _0xFFFF0000_) and the internal IO region (at _0xFFFFFE00_) for
1104
peripheral devices are also defined in the package and are fixed. These address regions cannot not be used for other
1105
applications – even if the bootloader or all IO devices are not implemented - without modifying the core's
1106
hardware sources.
1107
 
1108
 
1109
:sectnums:
1110 60 zero_gravi
==== Physical Memory Attributes
1111
 
1112 61 zero_gravi
The processor setup defines fixed attributes for the four processor-internal address space regions.
1113
Accessing a memory region in a way that violates any of these attributes will raise an according
1114
access exception..
1115 60 zero_gravi
 
1116
* `r` – read access (from CPU data access interface, e.g. via "load")
1117
* `w` – write access (from CPU data access interface, e.g. via "store")
1118
* `x` – execute access (from CPU instruction fetch interface)
1119
* `a` – atomic access (from CPU data access interface)
1120
* `8` – byte (8-bit)-accessible (when writing)
1121
* `16` – half-word (16-bit)-accessible (when writing)
1122
* `32` – word (32-bit)-accessible (when writing)
1123
 
1124 61 zero_gravi
[NOTE]
1125
Read accesses (i.e. loads) can always access data in word, half-word and byte quantities (requiring an accordingly aligned address).
1126 60 zero_gravi
 
1127
[cols="^1,^2,^2,^3,^2"]
1128
[options="header",grid="rows"]
1129
|=======================
1130
| # | Region | Base address | Size | Attributes
1131
| 4 | IO/peripheral devices | 0xfffffe00 | 512 bytes | `r/w/a/32`
1132
| 3 | bootloader ROM        | 0xffff0000 | up to 32kB| `r/x/a`
1133
| 2 | DMEM                  | 0x80000000 | up to 2GB (-64kB) | `r/w/x/a/8/16/32`
1134
| 1 | IMEM                  | 0x00000000 | up to 2GB | `r/w/x/a/8/16/32`
1135
|=======================
1136
 
1137 61 zero_gravi
[TIP]
1138
The following table shows the provided physical memory attributes of each region. Additional attributes (for example
1139
controlling certain right for specific address space regions) can be provided using the RISC-V <<_machine_physical_memory_protection>> extension.
1140 60 zero_gravi
 
1141
 
1142
:sectnums:
1143 61 zero_gravi
==== Memory Configuration
1144 60 zero_gravi
 
1145 61 zero_gravi
The NEORV32 Processor was designed to provide maximum flexibility for the memory configuration.
1146
The processor can populate the _instruction address space_ and/or the _data address space_ with **internal memories**
1147
for instructions (IMEM) and data (DMEM). Processor **external memories** can be used as an _alternative_ or even _in combination_ with
1148
the internal ones. The figure below show some exemplary memory configurations.
1149 60 zero_gravi
 
1150 61 zero_gravi
.Exemplary memory configurations
1151
image::neorv32_memory_configurations.png[800]
1152 60 zero_gravi
 
1153 61 zero_gravi
:sectnums!:
1154
===== Internal Memories
1155
 
1156
The processor-internal memories (<<_instruction_memory_imem>> and <<_data_memory_dmem>>) are enabled (=implemented)
1157
via the <<_mem_int_imem_en>> and <<_mem_int_dmem_en>> generics. Their sizes are configures via the according
1158
<<_mem_int_imem_size>> and <<_mem_int_dmem_size>> generics.
1159
 
1160 60 zero_gravi
If the processor-internal IMEM is implemented, it is located right at the base address of the instruction
1161
address space (default `ispace_base_c` = _0x00000000_). Vice versa, the processor-internal data memory is
1162
located right at the beginning of the data address space (default `dspace_base_c` = _0x80000000_) when
1163
implemented.
1164
 
1165 61 zero_gravi
[TIP]
1166
The default processor setup uses only _internal_ memories.
1167 60 zero_gravi
 
1168 61 zero_gravi
[NOTE]
1169
If the IMEM (internal or external) is less than the (default) maximum size (2GB), there is
1170
a "dead address space" between it and the DMEM. This provides an additional safety feature
1171
since data corrupting scenarios like stack overflow cannot directly corrupt the content of the IMEM:
1172
any access to the "dead address space" in between will raise an exception that can be caught
1173
by the runtime environment.
1174 60 zero_gravi
 
1175 61 zero_gravi
:sectnums!:
1176
===== External Memories
1177
 
1178
If external memories (or further IP modules) shall be connected via the _processor's external bus interface_,
1179
the interface has to be enabled via <<_mem_ext_en>> generic (=_true_). More information regarding this interface can be
1180
found in section <<_processor_external_memory_interface_wishbone_axi4_lite>>.
1181
 
1182
Any CPU access (data or instructions), which does not fulfill _at least one_ of the following conditions, is forwarded
1183
via the processor's bus interface to external components:
1184
 
1185 60 zero_gravi
* access to the processor-internal IMEM and processor-internal IMEM is implemented
1186
* access to the processor-internal DMEM and processor-internal DMEM is implemented
1187
* access to the bootloader ROM and beyond → addresses >= _BOOTROM_BASE_ (default 0xFFFF0000) will never be forwarded to the external memory interface
1188
 
1189 61 zero_gravi
If no (or not all) processor-internal memories are implemented, the according base addresses are mapped to external memories.
1190
For example, if the processor-internal IMEM is not implemented (<<_mem_int_imem_en>> = _false_), the processor will forward
1191
any access to the instruction address space (starting at `ispace_base_c`) via the external bus interface to the external
1192
memory system.
1193 60 zero_gravi
 
1194 61 zero_gravi
[NOTE]
1195
If the external interface is deactivated, any access exceeding the internal memory address space (instruction, data, bootloader) or
1196
the internal peripheral address space will trigger a bus access fault exception.
1197 60 zero_gravi
 
1198
 
1199 61 zero_gravi
:sectnums:
1200
==== Boot Configuration
1201
 
1202
Due to the flexible memory configuration concept, the NEORV32 Processor provides several different boot concepts.
1203
The figure below shows the exemplary concepts for the two most common boot scenarios.
1204
 
1205
.NEORV32 boot configurations
1206
image::neorv32_boot_configurations.png[800]
1207
 
1208
[NOTE]
1209
The configuration of internal or external data memory (DMEM; <<_mem_int_dmem_en>> = _true_ / _false_) is not further
1210
relevant for the boot configuration itself. Hence, it is not further illustrated here.
1211
 
1212
There are two general boot scenarios: _Indirect Boot_ (1a and 1b) and _Direct Boot_ (2a and 2b) configured via the
1213
<<_int_bootloader_en>> generic  If this generic is set **true** the _indirect_ boot scenario is used. This is also the
1214
default boot configuration of the processor. If <<_int_bootloader_en>> is set **false** the _direct_ boot scenario is used.
1215
 
1216
[NOTE]
1217
Please note that the provided boot scenarios are just exemplary setups that (should) fit most common requirements.
1218
Much more sophisticated boot scenarios are possible by combining internal and external memories. For example, the default
1219
internal bootloader could be used as first-level bootloader that loads (from extern SPI flash) a second-level bootloader
1220
that is placed and execute in internal IMEM. This second-level bootloader could then fetch the actual application and
1221
store it to external _data_ memory and transfers CPU control to that.
1222
 
1223
:sectnums!:
1224
===== Indirect Boot
1225
 
1226
The _indirect_ boot scenarios **1a** and **1b** use the processor-internal <<_bootloader>>. This general setup is enabled
1227
by setting the <<_int_bootloader_en>> generic to true, which will implement the processor-internal <<_bootloader_rom_bootrom>>.
1228
This read-only memory is pre-initialized during synthesis with the default bootloader firmware.
1229
 
1230
The bootloader provides several options to upload an executable (via UART or from external SPI flash) and store it to
1231
the _instruction address space_ so the CPU can execute it. Boot scenario **1a** uses the processor-internal IMEM
1232
(<<_mem_int_imem_en>> = _true_). This scenario implements the internal <<_instruction_memory_imem>> as non-initialized
1233
RAM so the bootloader can write the actual executable to it.
1234
 
1235
Boot scenario **1b** uses a processor-external IMEM (<<_mem_int_imem_en>> = _false_) that is connected via the processor's
1236
bus interface. In this scenario the internal <<_instruction_memory_imem>> is not implemented at all and the bootloader will
1237
write the executable to the processor-external memory.
1238
 
1239
:sectnums!:
1240
===== Direct Boot
1241
 
1242
The _direct_ boot scenarios **2a** and **2b** do not use the processor-internal bootloader. Hence, the <<_int_bootloader_en>>
1243
generic is set _false_. In this configuration the <<_bootloader_rom_bootrom>> is not implemented at all and the CPU will
1244
directly begin executing code from the instruction address space after reset. A "pre-initialization mechanism is required
1245
in order to provide an executable _in_ memory.
1246
 
1247
Boot scenario **2a** uses the processor-internal IMEM (<<_mem_int_imem_en>> = _true_) that is implemented as _read-only memory_
1248
in this scenario. It is pre-initialized (by the bitstream) with the actual application executable.
1249
 
1250
In contrast, boot scenario **2b** uses a processor-external IMEM (<<_mem_int_imem_en>> = _false_). In this scenario the
1251
system designer is responsible for providing a initialized external memory that contains the actual application to be executed.
1252
 
1253
 
1254
 
1255 60 zero_gravi
<<<
1256
// ####################################################################################################################
1257
:sectnums:
1258
=== Processor-Internal Modules
1259
 
1260
Basically, the processor is a SoC consisting of the NEORV32 CPU, peripheral/IO devices, embedded
1261
memories, an external memory interface and a bus infrastructure to interconnect all units. Additionally, the
1262
system implements an internal reset generator and a global clock generator/divider.
1263
 
1264
**Internal Reset Generator**
1265
 
1266
Most processor-internal modules – except for the CPU and the watchdog timer – do not have a dedicated
1267
reset signal. However, all devices can be reset by software by clearing the corresponding unit's control
1268
register. The automatically included application start-up code (`crt0.S`) will perform a software-reset of all
1269
modules to ensure a clean system reset state.
1270
 
1271
The hardware reset signal of the processor can either be
1272
triggered via the external reset pin (`rstn_i`, low-active) or by the internal watchdog timer (if implemented).
1273
Before the external reset signal is applied to the system, it is extended to have a minimal duration of eight
1274
clock cycles.
1275
 
1276
**Internal Clock Divider**
1277
 
1278
An internal clock divider generates 8 clock signals derived from the processor's main clock input `clk_i`.
1279
These derived clock signals are not actual _clock signals_. Instead, they are derived from a simple counter and
1280
are used as "clock enable" signal by the different processor modules. Thus, the whole design operates using
1281
only the main clock signal (single clock domain). Some of the processor peripherals like the Watchdog or the
1282
UARTs can select one of the derived clock enabled signals for their internal operation. If none of the
1283
connected modules require a clock signal from the divider, it is automatically deactivated to reduce dynamic
1284
power.
1285
 
1286
The peripheral devices, which feature a time-based configuration, provide a three-bit prescaler select in their
1287
according control register to select one out of the eight available clocks. The mapping of the prescaler select
1288
bits to the actually obtained clock are shown in the table below. Here, f represents the processor main clock
1289
from the top entity's `clk_i` signal.
1290
 
1291
[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1"]
1292
[grid="rows"]
1293
|=======================
1294
| Prescaler bits:  | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`
1295
| Resulting clock: | _f/2_   | _f/4_   | _f/8_   | _f/64_  | _f/128_ | _f/1024_| _f/2048_| _f/4096_
1296
|=======================
1297
 
1298
**Peripheral / IO Devices**
1299
 
1300
The processor-internal peripheral/IO devices are located at the end of the 32-bit address space at base
1301
address _0xFFFFFE00_. A region of 512 bytes is reserved for this devices. Hence, all peripheral/IO devices are
1302
accessed using a memory-mapped scheme. A special linker script as well as the NEORV32 core software
1303
library abstract the specific memory layout for the user.
1304
 
1305
[IMPORTANT]
1306 64 zero_gravi
The base address of each component/module has to be aligned to the
1307
total size of the module's occupied address space! The occupied address space
1308
has to be a power of two (minimum 4 bytes)! Address spaces must not overlap!
1309
 
1310
[IMPORTANT]
1311 60 zero_gravi
When accessing an IO device that hast not been implemented (via the according _IO_x_EN_ generic), a
1312
load/store access fault exception is triggered.
1313
 
1314
[IMPORTANT]
1315
The peripheral/IO devices can only be written in full-word mode (i.e. 32-bit). Byte or half-word
1316
(8/16-bit) writes will trigger a store access fault exception. Read accesses are not size constrained.
1317
Processor-internal memories as well as modules connected to the external memory interface can still
1318
be written with a byte-wide granularity.
1319
 
1320
[TIP]
1321
You should use the provided core software library to interact with the peripheral devices. This
1322
prevents incompatibilities with future versions, since the hardware driver functions handle all the
1323
register and register bit accesses.
1324
 
1325
[TIP]
1326
Most of the IO devices do not have a hardware reset. Instead, the devices are reset via software by
1327
writing zero to the unit's control register. A general software-based reset of all devices is done by the
1328
application start-up code `crt0.S`.
1329
 
1330 64 zero_gravi
**Interrupts of Processor-Internal Modules**
1331
 
1332
Most peripheral/IO devices provide some kind of interrupt (for example to signal available incoming data). These
1333
interrupts are entirely mapped to the CPU's <<_custom_fast_interrupt_request_lines>>. Note that all these
1334
interrupt lines are triggered by a "one-shot" signal (hich for exactly one cycle) and _do not_ require any
1335
explicit acknowledgment.
1336
 
1337 60 zero_gravi
**Nomenclature for the Peripheral / IO Devices Listing**
1338
 
1339
Each peripheral device chapter features a register map showing accessible control and data registers of the
1340 64 zero_gravi
according device including the implemented control and status bits. C-language code can directly interact with these
1341
registers via pre-defined `struct`. Each IO/peripheral module provides a unique `struct`. All accessible
1342
interface registers of this module are defined as members of this `struct`. The pre-defined `struct` are defined int the
1343
main processor core library include file `sw/lib/include/neorv32.h`.
1344 60 zero_gravi
 
1345 64 zero_gravi
The naming scheme of these low-level hardware access structs is `NEORV32_.`.
1346
 
1347
.Low-level hardware access example in C using the pre-defined `struct`
1348
[source,c]
1349
----
1350
// Read from SYSINFO "CLK" register
1351
uint32_t temp = NEORV32_SYSINFO.CLK;
1352
----
1353
 
1354
The registers and/or register bits, which can be accessed directly using plain C-code, are marked with a "[C]".
1355 60 zero_gravi
Not all registers or register bits can be arbitrarily read/written. The following read/write access types are
1356
available:
1357
 
1358
* `r/w` registers / bits can be read and written
1359
* `r/-` registers / bits are read-only; any write access to them has no effect
1360
* `-/w` these registers / bits are write-only; they auto-clear in the next cycle and are always read as zero
1361
 
1362
[TIP]
1363
Bits / registers that are not listed in the register map tables are not (yet) implemented. These registers
1364
/ bits are always read as zero. A write access to them has no effect, but user programs should only
1365
write zero to them to keep compatible with future extension.
1366
 
1367
[TIP]
1368
When writing to read-only registers, the access is nevertheless acknowledged, but no actual data is
1369
written. When reading data from a write-only register the result is undefined.
1370
 
1371
 
1372
include::soc_imem.adoc[]
1373
 
1374
include::soc_dmem.adoc[]
1375
 
1376
include::soc_bootrom.adoc[]
1377
 
1378
include::soc_icache.adoc[]
1379
 
1380
include::soc_wishbone.adoc[]
1381
 
1382 61 zero_gravi
include::soc_slink.adoc[]
1383
 
1384 60 zero_gravi
include::soc_gpio.adoc[]
1385
 
1386
include::soc_wdt.adoc[]
1387
 
1388
include::soc_mtime.adoc[]
1389
 
1390
include::soc_uart.adoc[]
1391
 
1392
include::soc_spi.adoc[]
1393
 
1394
include::soc_twi.adoc[]
1395
 
1396
include::soc_pwm.adoc[]
1397
 
1398
include::soc_trng.adoc[]
1399
 
1400
include::soc_cfs.adoc[]
1401
 
1402
include::soc_neoled.adoc[]
1403
 
1404 61 zero_gravi
include::soc_xirq.adoc[]
1405
 
1406 60 zero_gravi
include::soc_sysinfo.adoc[]
1407
 
1408
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.