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

Subversion Repositories neorv32

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

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
* _optional_ general purpose parallel IO port (<<_general_purpose_input_and_output_port_gpio,**GPIO**>>), 32xOut, 32xIn
20
* _optional_ 32-bit external bus interface, Wishbone b4 / AXI4-Lite compatible (<<_processor_external_memory_interface_wishbone_axi4_lite,**WISHBONE**>>)
21
* _optional_ watchdog timer (<<_watchdog_timer_wdt,**WDT**>>)
22
* _optional_ PWM controller with up to 60 channels & 8-bit duty cycle resolution (<<_pulse_width_modulation_controller_pwm,**PWM**>>)
23
* _optional_ ring-oscillator-based true random number generator (<<_true_random_number_generator_trng,**TRNG**>>)
24
* _optional_ custom functions subsystem for custom co-processor extensions (<<_custom_functions_subsystem_cfs,**CFS**>>)
25
* _optional_ numerically-controlled oscillator (<<_numerically_controlled_oscillator_nco,**NCO**>>) with 3 independent channels
26
* _optional_ NeoPixel(TM)/WS2812-compatible smart LED interface (<<_smart_led_interface_neoled,**NEOLED**>>)
27
* _optional_ on-chip debugger with JTAG TAP (<<_on_chip_debugger_ocd,**OCD**>>)
28
* system configuration information memory to check HW configuration via software (<<_system_configuration_information_memory_sysinfo,**SYSINFO**>>)
29
 
30
 
31
<<<
32
// ####################################################################################################################
33
:sectnums:
34
=== Processor Top Entity - Signals
35
 
36
The following table shows all interface ports of the processor top entity (`rtl/core/neorv32_top.vhd`).
37
The type of all signals is _std_ulogic_ or _std_ulogic_vector_, respectively.
38
 
39
[TIP]
40
A wrapper for the NEORV32 Processor setup providing resolved port signals can be found in
41
`rtl/top_templates/neorv32_top_stdlogic.vhd`.
42
 
43
[cols="<3,^2,^2,<11"]
44
[options="header",grid="rows"]
45
|=======================
46
| Signal | Width | Dir. | Function
47
4+^| **Global Control**
48
| `clk_i` | 1 | in | global clock line, all registers triggering on rising edge
49
| `rstn_i` | 1 | in | global reset, asynchronous, **low-active**
50
4+^| **JTAG Access Port for <<_on_chip_debugger_ocd>>**
51
| `jtag_trst_i` | 1 | in  | TAP reset, low-active (optionalfootnote:[Pull high if not used.])
52
| `jtag_tck_i ` | 1 | in  | serial clock
53
| `jtag_tdi_i ` | 1 | in  | serial data input
54
| `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.]
55
| `jtag_tms_i ` | 1 | in  | mode select
56
4+^| **External Bus Interface (<<_processor_external_memory_interface_wishbone_axi4_lite,WISHBONE>>)**
57
| `wb_tag_o` | 3  | out | tag (access type identifier)
58
| `wb_adr_o` | 32 | out | destination address
59
| `wb_dat_i` | 32 | in | write data
60
| `wb_dat_o` | 32 | out | read data
61
| `wb_we_o`  | 1  | out | write enable ('0' = read transfer)
62
| `wb_sel_o` | 4  | out | byte enable
63
| `wb_stb_o` | 1  | out | strobe
64
| `wb_cyc_o` | 1  | out | valid cycle
65
| `wb_lock_o`| 1  | out | exclusive access request
66
| `wb_ack_i` | 1  | in | transfer acknowledge
67
| `wb_err_i` | 1  | in | transfer error
68
4+^| **Advanced Memory Control Signals**
69
| `fence_o`  | 1 | out | indicates an executed _fence_ instruction
70
| `fencei_o` | 1 | out | indicates an executed _fencei_ instruction
71
4+^| **General Purpose Inputs & Outputs (<<_general_purpose_input_and_output_port_gpio,GPIO>>)**
72
| `gpio_o` | 32 | out | general purpose parallel output
73
| `gpio_i` | 32 | in | general purpose parallel input
74
4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>>)**
75
| `uart0_txd_o` | 1 | out | UART0 serial transmitter
76
| `uart0_rxd_i` | 1 | in | UART0 serial receiver
77
| `uart0_rts_o` | 1 | out | UART0 RX ready to receive new char
78
| `uart0_cts_i` | 1 | in | UART0 TX allowed to start sending
79
4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>>)**
80
| `uart1_txd_o` | 1 | out | UART1 serial transmitter
81
| `uart1_rxd_i` | 1 | in | UART1 serial receiver
82
| `uart1_rts_o` | 1 | out | UART1 RX ready to receive new char
83
| `uart1_cts_i` | 1 | in | UART1 TX allowed to start sending
84
4+^| **Serial Peripheral Interface Controller (<<_serial_peripheral_interface_controller_spi,SPI>>)**
85
| `spi_sck_o` | 1 | out | SPI controller clock line
86
| `spi_sdo_o` | 1 | out | SPI serial data output
87
| `spi_sdi_i` | 1 | in | SPI serial data input
88
| `spi_csn_o` | 8 | out | SPI dedicated chip select (low-active)
89
4+^| **Two-Wire Interface Controller (<<_two_wire_serial_interface_controller_twi,TWI>>)**
90
| `twi_sda_io` | 1 | inout | TWI serial data line
91
| `twi_scl_io` | 1 | inout | TWI serial clock line
92
4+^| **Custom Functions Subsystem (<<_custom_functions_subsystem_cfs,CFS>>)**
93
| `cfs_in_i`  | 32 | in | custom CFS input signal conduit
94
| `cfs_out_o` | 32 | out | custom CFS output signal conduit
95
4+^| **Pulse-Width Modulation Channels (<<_pulse_width_modulation_controller_pwm,PWM>>)**
96
| `pwm_o` | 4 | out | pulse-width modulated channels
97
4+^| **Numerically-Controller Oscillator (<<_numerically_controlled_oscillator_nco,NCO>>)**
98
| `nco_o` | 3 | out | NCO output channels
99
4+^| **Smart LED Interface - NeoPixel(TM) compatible (<<_smart_led_interface_neoled,NEOLED>>)**
100
| `neoled_o` | 1 | out | asynchronous serial data output
101
4+^| **System time (<<_machine_system_timer_mtime,MTIME>>)**
102
| `mtime_i` | 64 | in  | machine timer time (to `time[h]` CSRs) from _external MTIME_ unit if the processor-internal _MTIME_ unit is NOT implemented
103
| `mtime_o` | 64 | out | machine timer time from _internal MTIME_ unit if processor-internal _MTIME_ unit IS implemented
104
4+^| **<<_processor_interrupts>>**
105
| `nm_irq_i`    | 1 | in | non-maskable interrupt
106
| `soc_firq_i`  | 6 | in | platform fast interrupt channels (custom)
107
| `mtime_irq_i` | 1 | in | machine timer interrupt13 (RISC-V)
108
| `msw_irq_i`   | 1 | in | machine software interrupt (RISC-V)
109
| `mext_irq_i`  | 1 | in | machine external interrupt (RISC-V)
110
|=======================
111
 
112
 
113
<<<
114
// ####################################################################################################################
115
:sectnums:
116
=== Processor Top Entity - Generics
117
 
118
This is a list of all configuration generics of the NEORV32 processor top entity rtl/neorv32_top.vhd.
119
The generic name is shown in orange, followed by the type in printed in black and concluded by the default
120
value printed in light gray.
121
 
122
[TIP]
123
The NEORV32 generics allow to configure the system according to your needs. The generics are
124
used to control implementation of certain CPU extensions and peripheral modules and even allow to
125
optimize the system for certain design goals like minimal area or maximum performance.
126
 
127
[TIP]
128
Privileged software can determine the actual CPU and processor configuration via the `misa` and
129
`mzext` (see <<_machine_trap_setup>> and <<_neorv32_specific_custom_csrs>>) CSRs and via the memory-mapped _SYSINFO_ module (see <<_system_configuration_information_memory_sysinfo>>),
130
respectively.
131
 
132
[TIP]
133
If optional modules (like CPU extensions or peripheral devices) are *not enabled* the according circuitry **will not be synthesized at all**.
134
Hence, the disabled modules do not increase area and power requirements and do not impact the timing.
135
 
136
**CSR Description**
137
 
138
The description of each CSR provides the following summary:
139
 
140
.Generic description
141
[cols="4,4,2"]
142
[frame="all",grid="none"]
143
|======
144
| _Generic_ | _type_ | _default value_
145
3+| _Description_
146
|======
147
 
148
<<<
149
// ####################################################################################################################
150
:sectnums:
151
==== General
152
 
153
See section <<_system_configuration_information_memory_sysinfo>> for more information.
154
 
155
:sectnums!:
156
===== _CLOCK_FREQUENCY_
157
 
158
[cols="4,4,2"]
159
[frame="all",grid="none"]
160
|======
161
| **CLOCK_FREQUENCY** | _natural_ | 0
162
3+| The clock frequency of the processor's `clk_i` input port in Hertz (Hz).
163
|======
164
 
165
 
166
:sectnums!:
167
===== _BOOTLOADER_EN_
168
 
169
[cols="4,4,2"]
170
[frame="all",grid="none"]
171
|======
172
| **BOOTLOADER_EN** | _boolean_ | true
173
3+| Implement the boot ROM, pre-initialized with the bootloader image when true. This will also change the
174
processor's boot address from the beginning of the instruction memory address space (default =
175
0x00000000) to the base address of the boot ROM. See section <<_bootloader>> for more information.
176
|======
177
 
178
 
179
:sectnums!:
180
===== _USER_CODE_
181
 
182
[cols="4,4,2"]
183
[frame="all",grid="none"]
184
|======
185
| **USER_CODE** | _std_ulogic_vector(31 downto 0)_ | x"00000000"
186
3+| Custom user code that can be read by software via the _SYSINFO_ module.
187
|======
188
 
189
 
190
:sectnums!:
191
===== _HW_THREAD_ID_
192
 
193
[cols="4,4,2"]
194
[frame="all",grid="none"]
195
|======
196
| **HW_THREAD_ID** | _natural_ | 0
197
3+| The hart ID of the CPU. Can be read via the `mhartid` CSR. Hart IDs must be unique within a system.
198
|======
199
 
200
 
201
:sectnums!:
202
===== _ON_CHIP_DEBUGGER_EN_
203
 
204
[cols="4,4,2"]
205
[frame="all",grid="none"]
206
|======
207
| **ON_CHIP_DEBUGGER_EN** | _boolean_ | false
208
3+| Implement on-chip debugger (OCD). See chapter <<_on_chip_debugger_ocd>>.
209
|======
210
 
211
 
212
// ####################################################################################################################
213
:sectnums:
214
==== RISC-V CPU Extensions
215
 
216
See section <<_instruction_sets_and_extensions>> for more information.
217
 
218
 
219
:sectnums!:
220
===== _CPU_EXTENSION_RISCV_A_
221
 
222
[cols="4,4,2"]
223
[frame="all",grid="none"]
224
|======
225
| **CPU_EXTENSION_RISCV_A** | _boolean_ | false
226
3+| Implement atomic memory access operations when _true_.
227
|======
228
 
229
 
230
:sectnums!:
231
===== _CPU_EXTENSION_RISCV_C_
232
 
233
[cols="4,4,2"]
234
[frame="all",grid="none"]
235
|======
236
| **CPU_EXTENSION_RISCV_C** | _boolean_ | false
237
3+| Implement compressed instructions (16-bit) when _true_.
238
|======
239
 
240
 
241
:sectnums!:
242
===== _CPU_EXTENSION_RISCV_E_
243
 
244
[cols="4,4,2"]
245
[frame="all",grid="none"]
246
|======
247
| **CPU_EXTENSION_RISCV_E** | _boolean_ | false
248
3+| Implement the embedded CPU extension (only implement the first 16 data registers) when _true_.
249
|======
250
 
251
 
252
:sectnums!:
253
===== _CPU_EXTENSION_RISCV_M_
254
 
255
[cols="4,4,2"]
256
[frame="all",grid="none"]
257
|======
258
| **CPU_EXTENSION_RISCV_M** | _boolean_ | false
259
3+| Implement integer multiplication and division instructions when _true_.
260
|======
261
 
262
 
263
:sectnums!:
264
===== _CPU_EXTENSION_RISCV_U_
265
 
266
[cols="4,4,2"]
267
[frame="all",grid="none"]
268
|======
269
| **CPU_EXTENSION_RISCV_U** | _boolean_ | false
270
3+| Implement less-privileged user mode when _true_.
271
|======
272
 
273
 
274
:sectnums!:
275
===== _CPU_EXTENSION_RISCV_Zfinx_
276
 
277
[cols="4,4,2"]
278
[frame="all",grid="none"]
279
|======
280
| **CPU_EXTENSION_RISCV_Zfinx** | _boolean_ | false
281
3+| Implement the 32-bit single-precision floating-point extension (using integer registers) when _true_. For
282
more information see section <<_zfinx_single_precision_floating_point_operations>>.
283
|======
284
 
285
 
286
:sectnums!:
287
===== _CPU_EXTENSION_RISCV_Zicsr_
288
 
289
[cols="4,4,2"]
290
[frame="all",grid="none"]
291
|======
292
| **CPU_EXTENSION_RISCV_Zicsr** | _boolean_ | true
293
3+| Implement the control and status register (CSR) access instructions when true. Note: When this option is
294
disabled, the complete privileged architecture / trap system will be excluded from synthesis. Hence, no interrupts, no exceptions and
295
no machine information will be available.
296
|======
297
 
298
 
299
:sectnums!:
300
===== _CPU_EXTENSION_RISCV_Zifencei_
301
 
302
[cols="4,4,2"]
303
[frame="all",grid="none"]
304
|======
305
| **CPU_EXTENSION_RISCV_Zifencei** | _boolean_ | false
306
3+| Implement the instruction fetch synchronization instruction _fence.i_. For example, this option is required
307
for self-modifying code (and/or for i-cache flushes).
308
|======
309
 
310
 
311
// ####################################################################################################################
312
:sectnums:
313
==== Extension Options
314
 
315
See section <<_instruction_sets_and_extensions>> for more information.
316
 
317
 
318
:sectnums!:
319
===== _FAST_MUL_EN_
320
 
321
[cols="4,4,2"]
322
[frame="all",grid="none"]
323
|======
324
| **FAST_MUL_EN** | _boolean_ | false
325
3+| When this generic is enabled, the multiplier of the `M` extension is realized using DSPs blocks instead of an
326
iterative bit-serial approach. This generic is only relevant when the multiplier and divider CPU extension is
327
enabled (<<_cpu_extension_riscv_m>> is _true_).
328
|======
329
 
330
 
331
:sectnums!:
332
===== _FAST_SHIFT_EN_
333
 
334
[cols="4,4,2"]
335
[frame="all",grid="none"]
336
|======
337
| **FAST_SHIFT_EN** | _boolean_ | false
338
3+| When this generic is enabled the shifter unit of the CPU's ALU is implement as fast barrel shifter (requiring
339
more hardware resources).
340
|======
341
 
342
 
343
:sectnums!:
344
===== _TINY_SHIFT_EN_
345
 
346
[cols="4,4,2"]
347
[frame="all",grid="none"]
348
|======
349
| **TINY_SHIFT_EN** | _boolean_ | false
350
3+| If this generic is enabled the shifter unit of the CPU's ALU is implemented as (slow but tiny) single-bit iterative shifter
351
(requires up to 32 clock cycles for a shift operations, but reducing hardware footprint). The configuration of
352
this generic is ignored if <<_fast_shift_en>> is _true_.
353
|======
354
 
355
 
356
:sectnums!:
357
===== _CPU_CNT_WIDTH_
358
 
359
[cols="4,4,2"]
360
[frame="all",grid="none"]
361
|======
362
| **CPU_CNT_WIDTH** | _natural_ | 0
363
3+| This generic configures the total size of the CPU's `cycle` and `instret` CSRs (low word + high word).
364
The maximum value is 64, the minimal is 0. See
365
section <<_machine_counters_and_timers>> for more information. Note: Configurations with <<_cpu_cnt_width>>
366
less than 64 are not RISC-V compliant.
367
|======
368
 
369
 
370
// ####################################################################################################################
371
:sectnums:
372
==== Physical Memory Protection (PMP)
373
 
374
See section <<_pmp_physical_memory_protection>> for more information.
375
 
376
 
377
:sectnums!:
378
===== _PMP_NUM_REGIONS_
379
 
380
[cols="4,4,2"]
381
[frame="all",grid="none"]
382
|======
383
| **PMP_NUM_REGIONS** | _natural_ | 0
384
3+| Total number of implemented protections regions (0..64). If this generics is zero no physical memory
385
protection logic will be implemented at all. Setting <<_pmp_num_regions>>_ > 0 will set the _CSR_MZEXT_PMP_ flag
386
in the <<_mzext>> CSR.
387
|======
388
 
389
 
390
:sectnums!:
391
===== _PMP_MIN_GRANULARITY_
392
 
393
[cols="4,4,2"]
394
[frame="all",grid="none"]
395
|======
396
| **PMP_MIN_GRANULARITY** | _natural_ | 64*1024
397
3+| Minimal region granularity in bytes. Has to be a power of two. Has to be at least 8 bytes.
398
|======
399
 
400
 
401
// ####################################################################################################################
402
:sectnums:
403
==== Hardware Performance Monitors (HPM)
404
 
405
See section <<_hpm_hardware_performance_monitors>> for more information.
406
 
407
 
408
:sectnums!:
409
===== _HPM_NUM_CNTS_
410
 
411
[cols="4,4,2"]
412
[frame="all",grid="none"]
413
|======
414
| **HPM_NUM_CNTS** | _natural_ | 0
415
3+| Total number of implemented hardware performance monitor counters (0..29). If this generics is zero no
416
hardware performance monitor logic will be implemented at all. Setting <<_hpm_num_cnts>> > 0 will set the _CSR_MZEXT_HPM_ flag
417
in the <<_mzext>> CSR.
418
|======
419
 
420
 
421
:sectnums!:
422
===== _HPM_CNT_WIDTH_
423
 
424
[cols="4,4,2"]
425
[frame="all",grid="none"]
426
|======
427
| **HPM_CNT_WIDTH** | _natural_ | 40
428
3+| This generic defines the total LSB-aligned size of each HPM counter (size(`[m]hpmcounter*h`) +
429
size(`[m]hpmcounter*`)). The maximum value is 64, the minimal is 0. If the size is less than 64-bit, the
430
unused MSB-aligned counter bits are hardwired to zero.
431
|======
432
 
433
 
434
// ####################################################################################################################
435
:sectnums:
436
==== Internal Instruction Memory
437
 
438
See sections <<_address_space>> and <<_instruction_memory_imem>> for more information.
439
 
440
 
441
:sectnums!:
442
===== _MEM_INT_IMEM_EN_
443
 
444
[cols="4,4,2"]
445
[frame="all",grid="none"]
446
|======
447
| **MEM_INT_IMEM_EN** | _boolean_ | true
448
3+| Implement processor internal instruction memory (IMEM) when _true_.
449
|======
450
 
451
 
452
:sectnums!:
453
===== _MEM_INT_IMEM_SIZE_
454
 
455
[cols="4,4,2"]
456
[frame="all",grid="none"]
457
|======
458
| **MEM_INT_IMEM_SIZE** | _natural_ | 16*1024
459
3+| Size in bytes of the processor internal instruction memory (IMEM). Has no effect when _MEM_INT_IMEM_EN_ is _false_.
460
|======
461
 
462
 
463
:sectnums!:
464
===== _MEM_INT_IMEM_ROM_
465
 
466
[cols="4,4,2"]
467
[frame="all",grid="none"]
468
|======
469
| **MEM_INT_IMEM_ROM** | _boolean_ | false
470
3+| Implement processor-internal instruction memory as read-only memory, which will be initialized with the
471
application image at synthesis time. Has no effect when _MEM_INT_IMEM_EN_ is _false_.
472
|======
473
 
474
 
475
// ####################################################################################################################
476
:sectnums:
477
==== Internal Data Memory
478
 
479
See sections <<_address_space>> and <<_data_memory_dmem>> for more information.
480
 
481
 
482
:sectnums!:
483
===== _MEM_INT_DMEM_EN_
484
 
485
[cols="4,4,2"]
486
[frame="all",grid="none"]
487
|======
488
| **MEM_INT_DMEM_EN** | _boolean_ | true
489
3+| Implement processor internal data memory (DMEM) when _true_.
490
|======
491
 
492
 
493
:sectnums!:
494
===== _MEM_INT_DMEM_SIZE_
495
 
496
[cols="4,4,2"]
497
[frame="all",grid="none"]
498
|======
499
| **MEM_INT_DMEM_SIZE** | _natural_ | 8*1024
500
3+| Size in bytes of the processor-internal data memory (DMEM). Has no effect when _MEM_INT_DMEM_EN_ is _false_.
501
|======
502
 
503
 
504
// ####################################################################################################################
505
:sectnums:
506
==== Internal Cache Memory
507
 
508
See section <<_processor_internal_instruction_cache_icache>> for more information.
509
 
510
 
511
:sectnums!:
512
===== _ICACHE_EN_
513
 
514
[cols="4,4,2"]
515
[frame="all",grid="none"]
516
|======
517
| **ICACHE_EN** | _boolean_ | false
518
3+| Implement processor internal instruction cache when _true_.
519
|======
520
 
521
 
522
:sectnums!:
523
===== _ICACHE_NUM_BLOCK_
524
 
525
[cols="4,4,2"]
526
[frame="all",grid="none"]
527
|======
528
| **ICACHE_NUM_BLOCKS** | _natural_ | 4
529
3+| Number of blocks (cache "pages" or "lines") in the instruction cache. Has to be a power of two. Has no
530
effect when _ICACHE_DMEM_EN_ is false.
531
|======
532
 
533
 
534
:sectnums!:
535
===== _ICACHE_BLOCK_SIZE_
536
 
537
[cols="4,4,2"]
538
[frame="all",grid="none"]
539
|======
540
| **ICACHE_BLOCK_SIZE** | _natural_ | 64
541
3+| Size in bytes of each block in the instruction cache. Has to be a power of two. Has no effect when
542
_ICACHE_EN_ is _false_.
543
|======
544
 
545
 
546
:sectnums!:
547
===== _ICACHE_ASSOCIATIVITY_
548
 
549
[cols="4,4,2"]
550
[frame="all",grid="none"]
551
|======
552
| **ICACHE_ASSOCIATIVITY** | _natural_ | 1
553
3+| Associativity (= number of sets) of the instruction cache. Has to be a power of two. Allowed configurations:
554
`1` = 1 set, direct mapped; `2` = 2-way set-associative. Has no effect when _ICACHE_EN_ is _false_.
555
|======
556
 
557
 
558
// ####################################################################################################################
559
:sectnums:
560
==== External Memory Interface
561
 
562
See sections <<_address_space>> and <<_processor_external_memory_interface_wishbone_axi4_lite>> for more information.
563
 
564
 
565
:sectnums!:
566
===== _MEM_EXT_EN_
567
 
568
[cols="4,4,2"]
569
[frame="all",grid="none"]
570
|======
571
| **MEM_EXT_EN** | _boolean_ | false
572
3+| Implement external bus interface (WISHBONE) when _true_.
573
|======
574
 
575
 
576
:sectnums!:
577
===== _MEM_EXT_TIMEOUT_
578
 
579
[cols="4,4,2"]
580
[frame="all",grid="none"]
581
|======
582
| **MEM_EXT_TIMEOUT** | _natural_ | 255
583
3+| Clock cycles after which a pending external bus access will auto-terminate and raise a bus fault exception. Set to 0 to disable auto-timeout.
584
|======
585
 
586
 
587
// ####################################################################################################################
588
:sectnums:
589
==== Processor Peripheral/IO Modules
590
 
591
See section <<_processor_internal_modules>> for more information.
592
 
593
 
594
:sectnums!:
595
===== _IO_GPIO_EN_
596
 
597
[cols="4,4,2"]
598
[frame="all",grid="none"]
599
|======
600
| **IO_GPIO_EN** | _boolean_ | true
601
3+| Implement general purpose input/output port unit (GPIO) when _true_.
602
See section <<_general_purpose_input_and_output_port_gpio>> for more information.
603
|======
604
 
605
 
606
:sectnums!:
607
===== _IO_MTIME_EN_
608
 
609
[cols="4,4,2"]
610
[frame="all",grid="none"]
611
|======
612
| **IO_MTIME_EN** | _boolean_ | true
613
3+| Implement machine system timer (MTIME) when _true_.
614
See section <<_machine_system_timer_mtime>> for more information.
615
|======
616
 
617
 
618
:sectnums!:
619
===== _IO_UART0_EN_
620
 
621
[cols="4,4,2"]
622
[frame="all",grid="none"]
623
|======
624
| **IO_UART0_EN** | _boolean_ | true
625
3+| Implement primary universal asynchronous receiver/transmitter (UART0) when _true_.
626
See section <<_primary_universal_asynchronous_receiver_and_transmitter_uart0>> for
627
more information.
628
|======
629
 
630
 
631
:sectnums!:
632
===== _IO_UART1_EN_
633
 
634
[cols="4,4,2"]
635
[frame="all",grid="none"]
636
|======
637
| **IO_UART1_EN** | _boolean_ | true
638
3+| Implement secondary universal asynchronous receiver/transmitter (UART1) when _true_.
639
See section <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1>> for more information.
640
|======
641
 
642
 
643
:sectnums!:
644
===== _IO_SPI_EN_
645
 
646
[cols="4,4,2"]
647
[frame="all",grid="none"]
648
|======
649
| **IO_SPI_EN** | _boolean_ | true
650
3+| Implement serial peripheral interface controller (SPI) when _true_.
651
See section <<_serial_peripheral_interface_controller_spi>> for more information.
652
|======
653
 
654
 
655
:sectnums!:
656
===== _IO_TWI_EN_
657
 
658
[cols="4,4,2"]
659
[frame="all",grid="none"]
660
|======
661
| **IO_TWI_EN** | _boolean_ | true
662
3+| Implement two-wire interface controller (TWI) when _true_.
663
See section <<_two_wire_serial_interface_controller_twi>> for
664
more information.
665
|======
666
 
667
 
668
:sectnums!:
669
===== _IO_PWM_NUM_CH_
670
 
671
[cols="4,4,2"]
672
[frame="all",grid="none"]
673
|======
674
| **IO_PWM_NUM_CH** | _natural_ | 4
675
3+| Number of pulse-width modulation (PWM) channels (0..60) to implement. The PWM controller is _not_ implemented if zero.
676
See section <<_pulse_width_modulation_controller_pwm>> for more information.
677
|======
678
 
679
 
680
:sectnums!:
681
===== _IO_WDT_EN_
682
 
683
[cols="4,4,2"]
684
[frame="all",grid="none"]
685
|======
686
| **IO_WDT_EN** | _boolean_ | true
687
3+| Implement watchdog timer (WDT) when _true_. See section <<_watchdog_timer_wdt>> for more
688
information.
689
|======
690
 
691
 
692
:sectnums!:
693
===== _IO_TRNG_EN_
694
 
695
[cols="4,4,2"]
696
[frame="all",grid="none"]
697
|======
698
| **IO_TRNG_EN** | _boolean_ | false
699
3+| Implement true-random number generator (TRNG) when _true_. See section <<_true_random_number_generator_trng>> for more information.
700
|======
701
 
702
 
703
:sectnums!:
704
===== _IO_CFS_EN_
705
 
706
[cols="4,4,2"]
707
[frame="all",grid="none"]
708
|======
709
| **IO_CFS_EN** | _boolean_ | false
710
3+| Implement custom functions subsystem (CFS) when _true_. See section <<_custom_functions_subsystem_cfs>> for more information.
711
|======
712
 
713
 
714
:sectnums!:
715
===== _IO_CFS_CONFIG_
716
 
717
[cols="4,4,2"]
718
[frame="all",grid="none"]
719
|======
720
| **IO_CFS_CONFIG** | _std_ulogic_vector(31 downto 0)_ | 0x"00000000"
721
3+| This is a "conduit" generic that can be used to pass user-defined CFS implementation flags to the custom
722
functions subsystem entity. See section <<_custom_functions_subsystem_cfs>> for more information.
723
|======
724
 
725
 
726
:sectnums!:
727
===== _IO_CFS_IN_SIZE_
728
 
729
[cols="4,4,2"]
730
[frame="all",grid="none"]
731
|======
732
| **IO_CFS_IN_SIZE** | _positive_ | 32
733
3+| Defines the size of the CFS input signal conduit (`cfs_in_i`). See section <<_custom_functions_subsystem_cfs>> for more information.
734
|======
735
 
736
 
737
:sectnums!:
738
===== _IO_CFS_OUT_SIZE_
739
 
740
[cols="4,4,2"]
741
[frame="all",grid="none"]
742
|======
743
| **IO_CFS_OUT_SIZE** | _positive_ | 32
744
3+| Defines the size of the CFS output signal conduit (`cfs_out_o`). See section <<_custom_functions_subsystem_cfs>> for more information.
745
|======
746
 
747
 
748
:sectnums!:
749
===== _IO_NCO_EN_
750
 
751
[cols="4,4,2"]
752
[frame="all",grid="none"]
753
|======
754
| **IO_NCO_EN** | _boolean_ | true
755
3+| Implement numerically-controlled oscillator (NCO) when _true_.
756
See section <<_numerically_controlled_oscillator_nco>> for more information.
757
|======
758
 
759
 
760
:sectnums!:
761
===== _IO_NEOLED_EN_
762
 
763
[cols="4,4,2"]
764
[frame="all",grid="none"]
765
|======
766
| **IO_NEOLED_EN** | _boolean_ | true
767
3+| Implement smart LED interface (WS2812 / NeoPixel(TM)-compatible) (NEOLED) when _true_.
768
See section <<_smart_led_interface_neoled>> for more information.
769
|======
770
 
771
 
772
<<<
773
// ####################################################################################################################
774
:sectnums:
775
=== Processor Interrupts
776
 
777
[TIP]
778
The interrupt request signals have specific `mip` CSR bits (see <<_machine_trap_setup>>), specifc
779
`mie` CSR bits (see <<_machine_trap_handling>>) and specifc `mcause` CSR trap codes and trap
780
priorities. For more information (also regarding the signaling protocol) see section <<_traps_exceptions_and_interrupts>>.
781
 
782
**RISC-V Standard Interrupts**
783
 
784
The processor setup features the standard RISC-V interrupt lines for "machine timer interrupt", "machine
785
software interrupt" and "machine external interrupt". The software and external interrupt lines are available
786
via the processor's top entity. By default, the timer interrupt is connected to the internal machine timer
787
MTIME timer unit (<<_machine_system_timer_mtime>>). If this module has not been enabled for
788
synthesis, the machine timer interrupt is also available via the processor's top entity.
789
 
790
**NEORV32-Specific Fast Interrupt Requests**
791
 
792
As part of the custom/NEORV32-specific CPU extensions, the CPU features 16 fast interrupt request signals
793
(`FIRQ0` – `FIRQ15`).
794
 
795
The fast interrupt request signals are divided into two groups. The FIRQs with higher priority (FIRQ0 –
796
FIRQ9) are dedicated for processor-internal usage. The FIRQs with lower priority (FIRQ10 – FIRQ15) are
797
available for custom usage via the processor's top entity signal `soc_firq_i`.
798
 
799
The mapping of the 16 FIRQ channels is shown in the following table (the channel number corresponds to the FIRQ priority):
800
 
801
.NEORV32 fast interrupt channel mapping
802
[cols="^1,<2,<7"]
803
[options="header",grid="rows"]
804
|=======================
805
| Channel | Source | Description
806
| 0       | _WDT_ | watchdog timeout interrupt
807
| 1       | _CFS_ | custom functions subsystem (CFS) interrupt (user-defined)
808
| 2       | _UART0_ (RXD) | UART0 data received interrupt (RX complete)
809
| 3       | _UART0_ (TXD) | UART0 sending done interrupt (TX complete)
810
| 4       | _UART1_ (RXD) | UART1 data received interrupt (RX complete)
811
| 5       | _UART1_ (TXD) | UART1 sending done interrupt (TX complete)
812
| 6       | _SPI_ | SPI transmission done interrupt
813
| 7       | _TWI_ | TWI transmission done interrupt
814
| 8       | _GPIO_ | GPIO input pin-change interrupt
815
| 9       | _NEOLED_ | NEOLED buffer TX empty / not full interrupt
816
| 10:15   | `soc_firq_i(5:0)` | Custom platform use; available via processor's top signal
817
|=======================
818
 
819
**Non-Maskable Interrupt**
820
 
821
The NEORV32 features a single non-maskable interrupt source via the `nm_irq_i` top
822
entity signal that can be used to signal critical system conditions. This interrupt source _cannot_ be disabled. Hence, it does _not_ provide
823
configuration/status flags in the `mie` and `mip` CSRs. The RISC-V-compatible `mcause` value `0x80000000` is used to indicate the non-maskable interrupt.
824
 
825
<<<
826
// ####################################################################################################################
827
:sectnums:
828
=== Address Space
829
 
830
By default, the total 32-bit (4GB) address space of the NEORV32 Processor is divided into four main regions:
831
 
832
1. Instruction memory (IMEM) space – for instructions and constants.
833
2. Data memory (DMEM) space – for application runtime data (heap, stack, etc.).
834
3. Bootloader ROM address space – for the processor-internal bootloader.
835
4. IO/peripheral address space – for the processor-internal IO/peripheral devices (e.g., UART).
836
 
837
.NEORV32 processor - address space (default configuration)
838
image::address_space.png[900]
839
 
840
[TIP]
841
These four memory regions are handled by the linker when compiling a NEORV32 executable.
842
See section <<_executable_image_format>> for more information.
843
 
844
**Address Space Layout**
845
 
846
The general address space layout consists of two main configuration constants: `ispace_base_c` defining
847
the base address of the instruction memory address space and `dspace_base_c` defining the base address of
848
the data memory address space. Both constants are defined in the NEORV32 VHDL package file
849
`rtl/core/neorv32_package.vhd`:
850
 
851
[source,vhdl]
852
----
853
-- Architecture Configuration ----------------------------------------------------
854
-- ----------------------------------------------------------------------------------
855
constant ispace_base_c : std_ulogic_vector(31 downto 0) := x"00000000";
856
constant dspace_base_c : std_ulogic_vector(31 downto 0) := x"80000000";
857
----
858
 
859
The default configuration assumes the instruction memory address space starting at address _0x00000000_
860
and the data memory address space starting at _0x80000000_. Both values can be modified for a specific
861
setup and the address space may overlap or can be completely identical.
862
 
863
The base address of the bootloader (at _0xFFFF0000_) and the IO region (at _0xFFFFFF00_) for the peripheral
864
devices are also defined in the package and are fixed. These address regions cannot be used for other
865
applications – even if the bootloader or all IO devices are not implemented.
866
 
867
[WARNING]
868
When using the processor-internal data and/or instruction memories (DMEM/IMEM) and using a non-default
869
configuration for the `dspace_base_c` and/or `ispace_base_c` base addresses, the
870
following requirements have to be fulfilled:
871
**1.** Both base addresses have to be aligned to a 4-byte boundary.
872
**2.** Both base addresses have to be aligned to the according internal memory sizes.
873
 
874
:sectnums:
875
==== CPU Data and Instruction Access
876
 
877
The CPU can access all of the 4GB address space from the instruction fetch interface (**I**) and also from the
878
data access interface (**D**). These two CPU interfaces are multiplexed by a simple bus switch
879
(`rtl/core/neorv32_busswitch.vhd`) into a _single_ processor-internal bus. All processor-internal
880
memories, peripherals and also the external memory interface are connected to this bus. Hence, both CPU
881
interfaces (instruction fetch & data access) have access to the same (**identical**) address space making the
882
setup a modified von-Neumann architecture.
883
 
884
.Processor-internal bus architecture
885
image::neorv32_bus.png[1300]
886
 
887
[NOTE]
888
The internal processor bus might appear as bottleneck. In order to reduce traffic jam on this bus
889
(when instruction fetch and data interface access the bus at the same time) the instruction fetch of
890
the CPU is equipped with a prefetch buffer. Instruction fetches can be further buffered using the i-cache.
891
Furthermore, data accesses (loads and stores) have higher priority than instruction fetch
892
accesses.
893
 
894
[IMPORTANT]
895
Please note that all processor-internal components including the peripheral/IO devices can also be
896
accessed from programs running in less-privileged user mode. For example, if the system relies on
897
a periodic interrupt from the _MTIME_ timer unit, user-level programs could alter the _MTIME_
898
configuration corrupting this interrupt. This kind of security issues can be compensated using the
899
PMP system (see <<_machine_physical_memory_protection>>).
900
 
901
:sectnums:
902
==== Physical Memory Attributes
903
 
904
The processor setup defines four simple attributes for the four processor-internal address space regions:
905
 
906
* `r` – read access (from CPU data access interface, e.g. via "load")
907
* `w` – write access (from CPU data access interface, e.g. via "store")
908
* `x` – execute access (from CPU instruction fetch interface)
909
* `a` – atomic access (from CPU data access interface)
910
* `8` – byte (8-bit)-accessible (when writing)
911
* `16` – half-word (16-bit)-accessible (when writing)
912
* `32` – word (32-bit)-accessible (when writing)
913
 
914
The following table shows the provided physical memory attributes of each region. Additional attributes (like
915
denying execute right for certain region of the IMEM) can be provided using the RISC-V <<_machine_physical_memory_protection>> extension.
916
 
917
[cols="^1,^2,^2,^3,^2"]
918
[options="header",grid="rows"]
919
|=======================
920
| # | Region | Base address | Size | Attributes
921
| 4 | IO/peripheral devices | 0xfffffe00 | 512 bytes | `r/w/a/32`
922
| 3 | bootloader ROM        | 0xffff0000 | up to 32kB| `r/x/a`
923
| 2 | DMEM                  | 0x80000000 | up to 2GB (-64kB) | `r/w/x/a/8/16/32`
924
| 1 | IMEM                  | 0x00000000 | up to 2GB | `r/w/x/a/8/16/32`
925
|=======================
926
 
927
Only the CPU of the processor has access to the internal memories and IO devices, hence all accesses are
928
always exclusive. Accessing a memory region in a way that violates the provided attributes will trigger a
929
load/store/instruction fetch access exception or will return a failed atomic access result, respectively.
930
 
931
The physical memory attributes of memories and/or devices connected via the external bus interface have to
932
defined by those components or the interconnection fabric.
933
 
934
:sectnums:
935
==== Internal Memories
936
 
937
The processor can implement internal memories for instructions (IMEM) and data (DMEM), which will be
938
mapped to FPGA block RAMs. The implementation of these memories is controlled via the boolean
939
<<_mem_int_imem_en>> and <<_mem_int_dmem_en>> generics.
940
 
941
The size of these memories are configured via the _MEM_INT_IMEM_SIZE_ and _MEM_INT_DMEM_SIZE_
942
generics (in bytes), respectively. The processor-internal instruction memory (IMEM) can optionally be
943
implemented as true ROM (<<_mem_int_imem_rom>>), which is initialized with the application code during
944
synthesis.
945
 
946
If the processor-internal IMEM is implemented, it is located right at the base address of the instruction
947
address space (default `ispace_base_c` = _0x00000000_). Vice versa, the processor-internal data memory is
948
located right at the beginning of the data address space (default `dspace_base_c` = _0x80000000_) when
949
implemented.
950
 
951
:sectnums:
952
==== External Memory/Bus Interface
953
 
954
Any CPU access (data or instructions), which does not fulfill one of the following conditions, is forwarded
955
to the <<_processor_external_memory_interface_wishbone_axi4_lite>>:
956
 
957
* access to the processor-internal IMEM and processor-internal IMEM is implemented
958
* access to the processor-internal DMEM and processor-internal DMEM is implemented
959
* access to the bootloader ROM and beyond → addresses >= _BOOTROM_BASE_ (default 0xFFFF0000) will never be forwarded to the external memory interface
960
 
961
The external bus interface is available when the <<_mem_ext_en>> generic is _true_. If this interface is
962
deactivated, any access exceeding the internal memories or peripheral devices will trigger a bus access fault
963
exception. If <<_mem_ext_timeout>> is greater than zero any external bus access that is not acknowledged or terminated
964
within <<_mem_ext_timeout>> clock cycles will auto-timeout and raise the according bus fault exception.
965
 
966
 
967
 
968
<<<
969
// ####################################################################################################################
970
:sectnums:
971
=== Processor-Internal Modules
972
 
973
Basically, the processor is a SoC consisting of the NEORV32 CPU, peripheral/IO devices, embedded
974
memories, an external memory interface and a bus infrastructure to interconnect all units. Additionally, the
975
system implements an internal reset generator and a global clock generator/divider.
976
 
977
**Internal Reset Generator**
978
 
979
Most processor-internal modules – except for the CPU and the watchdog timer – do not have a dedicated
980
reset signal. However, all devices can be reset by software by clearing the corresponding unit's control
981
register. The automatically included application start-up code (`crt0.S`) will perform a software-reset of all
982
modules to ensure a clean system reset state.
983
 
984
The hardware reset signal of the processor can either be
985
triggered via the external reset pin (`rstn_i`, low-active) or by the internal watchdog timer (if implemented).
986
Before the external reset signal is applied to the system, it is extended to have a minimal duration of eight
987
clock cycles.
988
 
989
**Internal Clock Divider**
990
 
991
An internal clock divider generates 8 clock signals derived from the processor's main clock input `clk_i`.
992
These derived clock signals are not actual _clock signals_. Instead, they are derived from a simple counter and
993
are used as "clock enable" signal by the different processor modules. Thus, the whole design operates using
994
only the main clock signal (single clock domain). Some of the processor peripherals like the Watchdog or the
995
UARTs can select one of the derived clock enabled signals for their internal operation. If none of the
996
connected modules require a clock signal from the divider, it is automatically deactivated to reduce dynamic
997
power.
998
 
999
The peripheral devices, which feature a time-based configuration, provide a three-bit prescaler select in their
1000
according control register to select one out of the eight available clocks. The mapping of the prescaler select
1001
bits to the actually obtained clock are shown in the table below. Here, f represents the processor main clock
1002
from the top entity's `clk_i` signal.
1003
 
1004
[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1"]
1005
[grid="rows"]
1006
|=======================
1007
| Prescaler bits:  | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`
1008
| Resulting clock: | _f/2_   | _f/4_   | _f/8_   | _f/64_  | _f/128_ | _f/1024_| _f/2048_| _f/4096_
1009
|=======================
1010
 
1011
**Peripheral / IO Devices**
1012
 
1013
The processor-internal peripheral/IO devices are located at the end of the 32-bit address space at base
1014
address _0xFFFFFE00_. A region of 512 bytes is reserved for this devices. Hence, all peripheral/IO devices are
1015
accessed using a memory-mapped scheme. A special linker script as well as the NEORV32 core software
1016
library abstract the specific memory layout for the user.
1017
 
1018
[IMPORTANT]
1019
When accessing an IO device that hast not been implemented (via the according _IO_x_EN_ generic), a
1020
load/store access fault exception is triggered.
1021
 
1022
[IMPORTANT]
1023
The peripheral/IO devices can only be written in full-word mode (i.e. 32-bit). Byte or half-word
1024
(8/16-bit) writes will trigger a store access fault exception. Read accesses are not size constrained.
1025
Processor-internal memories as well as modules connected to the external memory interface can still
1026
be written with a byte-wide granularity.
1027
 
1028
[TIP]
1029
You should use the provided core software library to interact with the peripheral devices. This
1030
prevents incompatibilities with future versions, since the hardware driver functions handle all the
1031
register and register bit accesses.
1032
 
1033
[TIP]
1034
Most of the IO devices do not have a hardware reset. Instead, the devices are reset via software by
1035
writing zero to the unit's control register. A general software-based reset of all devices is done by the
1036
application start-up code `crt0.S`.
1037
 
1038
**Nomenclature for the Peripheral / IO Devices Listing**
1039
 
1040
Each peripheral device chapter features a register map showing accessible control and data registers of the
1041
according device including the implemented control and status bits. You can directly interact with these
1042
registers/bits via the provided _C-code defines_. These defines are set in the main processor core library
1043
include file `sw/lib/include/neorv32.h`. The registers and/or register bits, which can be accessed
1044
directly using plain C-code, are marked with a "[C]".
1045
 
1046
Not all registers or register bits can be arbitrarily read/written. The following read/write access types are
1047
available:
1048
 
1049
* `r/w` registers / bits can be read and written
1050
* `r/-` registers / bits are read-only; any write access to them has no effect
1051
* `-/w` these registers / bits are write-only; they auto-clear in the next cycle and are always read as zero
1052
 
1053
[TIP]
1054
Bits / registers that are not listed in the register map tables are not (yet) implemented. These registers
1055
/ bits are always read as zero. A write access to them has no effect, but user programs should only
1056
write zero to them to keep compatible with future extension.
1057
 
1058
[TIP]
1059
When writing to read-only registers, the access is nevertheless acknowledged, but no actual data is
1060
written. When reading data from a write-only register the result is undefined.
1061
 
1062
 
1063
include::soc_imem.adoc[]
1064
 
1065
include::soc_dmem.adoc[]
1066
 
1067
include::soc_bootrom.adoc[]
1068
 
1069
include::soc_icache.adoc[]
1070
 
1071
include::soc_wishbone.adoc[]
1072
 
1073
include::soc_gpio.adoc[]
1074
 
1075
include::soc_wdt.adoc[]
1076
 
1077
include::soc_mtime.adoc[]
1078
 
1079
include::soc_uart.adoc[]
1080
 
1081
include::soc_spi.adoc[]
1082
 
1083
include::soc_twi.adoc[]
1084
 
1085
include::soc_pwm.adoc[]
1086
 
1087
include::soc_trng.adoc[]
1088
 
1089
include::soc_cfs.adoc[]
1090
 
1091
include::soc_nco.adoc[]
1092
 
1093
include::soc_neoled.adoc[]
1094
 
1095
include::soc_sysinfo.adoc[]
1096
 
1097
 

powered by: WebSVN 2.1.0

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