1 |
60 |
zero_gravi |
<<<
|
2 |
|
|
:sectnums:
|
3 |
|
|
==== Processor-External Memory Interface (WISHBONE) (AXI4-Lite)
|
4 |
|
|
|
5 |
|
|
[cols="<3,<3,<4"]
|
6 |
|
|
[frame="topbot",grid="none"]
|
7 |
|
|
|=======================
|
8 |
61 |
zero_gravi |
| Hardware source file(s): | neorv32_wishbone.vhd |
|
9 |
60 |
zero_gravi |
| Software driver file(s): | none | _implicitly used_
|
10 |
|
|
| Top entity port: | `wb_tag_o` | request tag output (3-bit)
|
11 |
|
|
| | `wb_adr_o` | address output (32-bit)
|
12 |
|
|
| | `wb_dat_i` | data input (32-bit)
|
13 |
|
|
| | `wb_dat_o` | data output (32-bit)
|
14 |
|
|
| | `wb_we_o` | write enable (1-bit)
|
15 |
|
|
| | `wb_sel_o` | byte enable (4-bit)
|
16 |
|
|
| | `wb_stb_o` | strobe (1-bit)
|
17 |
|
|
| | `wb_cyc_o` | valid cycle (1-bit)
|
18 |
|
|
| | `wb_lock_o` | exclusive access request (1-bit)
|
19 |
|
|
| | `wb_ack_i` | acknowledge (1-bit)
|
20 |
|
|
| | `wb_err_i` | bus error (1-bit)
|
21 |
|
|
| | `fence_o` | an executed `fence` instruction
|
22 |
|
|
| | `fencei_o` | an executed `fence.i` instruction
|
23 |
62 |
zero_gravi |
| Configuration generics: | _MEM_EXT_EN_ | enable external memory interface when _true_
|
24 |
|
|
| | _MEM_EXT_TIMEOUT_ | number of clock cycles after which an unacknowledged external bus access will auto-terminate (0 = disabled)
|
25 |
|
|
| | _MEM_EXT_PIPE_MODE_ | when _false_ (default): classic/standard Wishbone protocol; when _true_: pipelined Wishbone protocol
|
26 |
|
|
| | _MEM_EXT_BIG_ENDIAN_ | byte-order (Endianness) of external memory interface; true=BIG, false=little (default)
|
27 |
|
|
| | _MEM_EXT_ASYNC_RX_ | use registered RX path when _false_ (default); use async/direct RX path when _true_
|
28 |
|
|
| CPU interrupts: | none |
|
29 |
60 |
zero_gravi |
|=======================
|
30 |
|
|
|
31 |
|
|
|
32 |
69 |
zero_gravi |
The external memory interface provides a Wishbone b4-compatible on-chip bus interface. The bus interface is
|
33 |
|
|
implemented when the _MEM_EXT_EN_ generic is _true_. This interface can be used to attach external memories,
|
34 |
|
|
custom hardware accelerators, additional IO devices or all other kinds of IP blocks.
|
35 |
|
|
|
36 |
|
|
The external interface is _not_ mapped to a _specific_ address space region. Instead, all CPU memory accesses that
|
37 |
|
|
do not target a processor-internal module are delegated to the external memory interface. In summary, a CPU load/store
|
38 |
|
|
access is delegated to the external bus interface if...
|
39 |
|
|
|
40 |
|
|
. it does not target the internal instruction memory IMEM (if implemented at all)
|
41 |
|
|
. **and** it does not target the internal data memory DMEM (if implemented at all)
|
42 |
|
|
. **and** it does not target the internal bootloader ROM or any of the IO devices - regardless if one or more of these components are
|
43 |
|
|
actually implemented or not.
|
44 |
|
|
|
45 |
70 |
zero_gravi |
[NOTE]
|
46 |
|
|
If the Execute In Place module (XIP) is implemented accesses map to this module are not forwarded to the
|
47 |
|
|
external memory interface. See section <<_execute_in_place_module_xip>> for more information.
|
48 |
|
|
|
49 |
60 |
zero_gravi |
[TIP]
|
50 |
69 |
zero_gravi |
See section <<_address_space>> for more information.
|
51 |
60 |
zero_gravi |
|
52 |
69 |
zero_gravi |
|
53 |
60 |
zero_gravi |
**Wishbone Bus Protocol**
|
54 |
|
|
|
55 |
69 |
zero_gravi |
The external memory interface either uses the **standard** ("classic") Wishbone transaction protocol (default) or
|
56 |
|
|
**pipelined** Wishbone transaction protocol. The transaction protocol is configured via the _MEM_EXT_PIPE_MODE_ generic:
|
57 |
60 |
zero_gravi |
|
58 |
69 |
zero_gravi |
When _MEM_EXT_PIPE_MODE_ is _false_, all bus control signals including _STB_ are active and remain stable until the
|
59 |
62 |
zero_gravi |
transfer is acknowledged/terminated. If _MEM_EXT_PIPE_MODE_ is _true_, all bus control except _STB_ are active
|
60 |
69 |
zero_gravi |
and remain until the transfer is acknowledged/terminated. In this case, _STB_ is asserted only during the very
|
61 |
60 |
zero_gravi |
first bus clock cycle.
|
62 |
|
|
|
63 |
|
|
.Exemplary Wishbone bus accesses using "classic" and "pipelined" protocol
|
64 |
|
|
[cols="^2,^2"]
|
65 |
|
|
[grid="none"]
|
66 |
|
|
|=======================
|
67 |
|
|
a| image::wishbone_classic_read.png[700,300]
|
68 |
|
|
a| image::wishbone_pipelined_write.png[700,300]
|
69 |
|
|
| **Classic** Wishbone read access | **Pipelined** Wishbone write access
|
70 |
|
|
|=======================
|
71 |
|
|
|
72 |
|
|
|
73 |
69 |
zero_gravi |
[TIP]
|
74 |
60 |
zero_gravi |
A detailed description of the implemented Wishbone bus protocol and the according interface signals
|
75 |
65 |
zero_gravi |
can be found in the data sheet "Wishbone B4 - WISHBONE System-on-Chip (SoC) Interconnection
|
76 |
60 |
zero_gravi |
Architecture for Portable IP Cores". A copy of this document can be found in the docs folder of this
|
77 |
|
|
project.
|
78 |
|
|
|
79 |
|
|
|
80 |
69 |
zero_gravi |
**Bus Access**
|
81 |
60 |
zero_gravi |
|
82 |
69 |
zero_gravi |
The NEORV32 Wishbone gateway does not support burst transfer yet, so there is always just one transfer in progress.
|
83 |
|
|
Hence, the Wishbone `STALL` signal is not implemented. An accessed Wishbone device does not have to respond immediately to a bus
|
84 |
|
|
request by sending an ACK. instead, there is a _time window_ where the device has to acknowledge the transfer. This time window
|
85 |
|
|
id configured by the _MEM_EXT_TIMEOUT_ top generic that defines the maximum time (in clock cycles) a bus access can be pending
|
86 |
|
|
before it is automatically terminated. If _MEM_EXT_TIMEOUT_ is set to zero, the timeout disabled an a bus access can take an
|
87 |
|
|
arbitrary number of cycles to complete.
|
88 |
61 |
zero_gravi |
|
89 |
69 |
zero_gravi |
When _MEM_EXT_TIMEOUT_ is greater than zero, the Wishbone gateway starts an internal countdown whenever the CPU
|
90 |
60 |
zero_gravi |
accesses a memory address via the external memory interface. If the accessed memory / device does not acknowledge (via `wb_ack_i`)
|
91 |
|
|
or terminate (via `wb_err_i`) the transfer within _MEM_EXT_TIMEOUT_ clock cycles, the bus access is automatically canceled
|
92 |
69 |
zero_gravi |
setting `wb_cyc_o` low again and a CPU load/store/instruction fetch bus access fault exception is raised.
|
93 |
60 |
zero_gravi |
|
94 |
69 |
zero_gravi |
[IMPORTANT]
|
95 |
|
|
Setting _MEM_EXT_TIMEOUT_ to zero will permanently stall the CPU if the targeted Wishbone device never responds. Hence,
|
96 |
|
|
_MEM_EXT_TIMEOUT_ should be always set to a value greater than zero. +
|
97 |
|
|
+
|
98 |
|
|
This feature can be used as **safety guard** if the external memory system does not check for "address space holes". That means
|
99 |
|
|
that accessing addresses, which do not belong to a certain memory or device, do not permanently stall the processor due to an
|
100 |
|
|
unacknowledged/unterminated bus access. If the external memory system can guarantee to access **any** bus access
|
101 |
|
|
(even it targets an unimplemented address) the timeout feature should be disabled (_MEM_EXT_TIMEOUT_ = 0).
|
102 |
60 |
zero_gravi |
|
103 |
69 |
zero_gravi |
|
104 |
60 |
zero_gravi |
**Wishbone Tag**
|
105 |
|
|
|
106 |
|
|
The 3-bit wishbone `wb_tag_o` signal provides additional information regarding the access type. This signal
|
107 |
|
|
is compatible to the AXI4 _AxPROT_ signal.
|
108 |
|
|
|
109 |
|
|
* `wb_tag_o(0)` 1: privileged access (CPU is in machine mode); 0: unprivileged access
|
110 |
|
|
* `wb_tag_o(1)` always zero (indicating "secure access")
|
111 |
|
|
* `wb_tag_o(2)` 1: instruction fetch access, 0: data access
|
112 |
|
|
|
113 |
69 |
zero_gravi |
|
114 |
60 |
zero_gravi |
**Exclusive / Atomic Bus Access**
|
115 |
|
|
|
116 |
|
|
If the atomic memory access CPU extension (via _CPU_EXTENSION_RISCV_A_) is enabled, the CPU can
|
117 |
|
|
request an atomic/exclusive bus access via the external memory interface.
|
118 |
|
|
|
119 |
|
|
The load-reservate instruction (`lr.w`) will set the `wb_lock_o` signal telling the bus interconnect to establish a
|
120 |
|
|
reservation for the current accessed address (start of an exclusive access). This signal will stay asserted until
|
121 |
|
|
another memory access instruction is executed (for example a `sc.w`).
|
122 |
|
|
|
123 |
|
|
The memory system has to make sure that no other entity can access the reservated address until `wb_lock_o`
|
124 |
|
|
is released again. If this attempt fails, the memory system has to assert `wb_err_i` in order to indicate that the
|
125 |
|
|
reservation was broken.
|
126 |
|
|
|
127 |
|
|
[TIP]
|
128 |
|
|
See section <<_bus_interface>> for the CPU bus interface protocol.
|
129 |
|
|
|
130 |
69 |
zero_gravi |
|
131 |
60 |
zero_gravi |
**Endianness**
|
132 |
|
|
|
133 |
|
|
The NEORV32 CPU and the Processor setup are *little-endian* architectures. To allow direct connection
|
134 |
|
|
to a big-endian memory system the external bus interface provides an _Endianness configuration_. The
|
135 |
62 |
zero_gravi |
Endianness (of the external memory interface) can be configured via the _MEM_EXT_BIG_ENDIAN_ generic.
|
136 |
|
|
By default, the external memory interface uses little-endian byte-order (like the rest of the processor / CPU).
|
137 |
60 |
zero_gravi |
|
138 |
|
|
Application software can check the Endianness configuration of the external bus interface via the
|
139 |
64 |
zero_gravi |
SYSINFO module (see section <<_system_configuration_information_memory_sysinfo>> for more information).
|
140 |
60 |
zero_gravi |
|
141 |
69 |
zero_gravi |
|
142 |
|
|
**Gateway Latency**
|
143 |
|
|
|
144 |
|
|
By default, the Wishbone gateway introduces two additional latency cycles: processor-outgoing ("TX") and
|
145 |
|
|
processor-incoming ("RX") signals are fully registered. Thus, any access from the CPU to a processor-external devices
|
146 |
|
|
via Wishbone requires 2 additional clock cycles (at least; depending on device's latency).
|
147 |
|
|
|
148 |
|
|
If the attached Wishbone network / peripheral already provides output registers or if the Wishbone network is not relevant
|
149 |
|
|
for timing closure, the default buffering of incoming ("RX") data within the gateway can be disabled by implementing an
|
150 |
|
|
"asynchronous" RX path. The configuration is done via the _MEM_EXT_ASYNC_RX_ generic.
|
151 |
|
|
|
152 |
|
|
|
153 |
60 |
zero_gravi |
**AXI4-Lite Connectivity**
|
154 |
|
|
|
155 |
63 |
zero_gravi |
The AXI4-Lite wrapper (`rtl/system_integration/neorv32_SystemTop_axi4lite.vhd`) provides a Wishbone-to-
|
156 |
60 |
zero_gravi |
AXI4-Lite bridge, compatible with Xilinx Vivado (IP packager and block design editor). All entity signals of
|
157 |
|
|
this wrapper are of type _std_logic_ or _std_logic_vector_, respectively.
|
158 |
|
|
|
159 |
|
|
The AXI Interface has been verified using Xilinx Vivado IP Packager and Block Designer. The AXI
|
160 |
|
|
interface port signals are automatically detected when packaging the core.
|
161 |
|
|
|
162 |
|
|
.Example AXI SoC using Xilinx Vivado
|
163 |
|
|
image::neorv32_axi_soc.png[]
|
164 |
|
|
|
165 |
|
|
[WARNING]
|
166 |
69 |
zero_gravi |
Using the auto-termination timeout feature (_MEM_EXT_TIMEOUT_ greater than zero) is **not AXI4 compliant** as
|
167 |
|
|
the AXI protocol does not support canceling of bus transactions. Therefore, the NEORV32 top wrapper with AXI4-Lite interface
|
168 |
|
|
(`rtl/system_integration/neorv32_SystemTop_axi4lite`) configures _MEM_EXT_TIMEOUT_ = 0 by default.
|