1 |
64 |
zero_gravi |
-- #################################################################################################
|
2 |
|
|
-- # << NEORV32 - Processor Top Entity with AvalonMM Compatible Master Interface >> #
|
3 |
|
|
-- # ********************************************************************************************* #
|
4 |
|
|
-- # (c) "AvalonMM", "NIOS-2", "Qsys", "MegaWizard" and "Platform Designer" #
|
5 |
|
|
-- # are trademarks of Intel #
|
6 |
|
|
-- # ********************************************************************************************* #
|
7 |
|
|
-- # BSD 3-Clause License #
|
8 |
|
|
-- # #
|
9 |
|
|
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
10 |
|
|
-- # #
|
11 |
|
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
12 |
|
|
-- # permitted provided that the following conditions are met: #
|
13 |
|
|
-- # #
|
14 |
|
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
15 |
|
|
-- # conditions and the following disclaimer. #
|
16 |
|
|
-- # #
|
17 |
|
|
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
18 |
|
|
-- # conditions and the following disclaimer in the documentation and/or other materials #
|
19 |
|
|
-- # provided with the distribution. #
|
20 |
|
|
-- # #
|
21 |
|
|
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
22 |
|
|
-- # endorse or promote products derived from this software without specific prior written #
|
23 |
|
|
-- # permission. #
|
24 |
|
|
-- # #
|
25 |
|
|
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
26 |
|
|
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
27 |
|
|
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
28 |
|
|
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
29 |
|
|
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
30 |
|
|
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
31 |
|
|
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
32 |
|
|
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
33 |
|
|
-- # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
34 |
|
|
-- # ********************************************************************************************* #
|
35 |
|
|
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
36 |
|
|
-- #################################################################################################
|
37 |
|
|
|
38 |
|
|
library ieee;
|
39 |
|
|
use ieee.std_logic_1164.all;
|
40 |
|
|
use ieee.numeric_std.all;
|
41 |
|
|
|
42 |
|
|
library neorv32;
|
43 |
|
|
use neorv32.neorv32_package.all;
|
44 |
|
|
|
45 |
|
|
entity neorv32_top_avalonmm is
|
46 |
|
|
generic (
|
47 |
|
|
-- General --
|
48 |
|
|
CLOCK_FREQUENCY : natural; -- clock frequency of clk_i in Hz
|
49 |
|
|
HW_THREAD_ID : natural := 0; -- hardware thread id (32-bit)
|
50 |
|
|
INT_BOOTLOADER_EN : boolean := false; -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
|
51 |
|
|
|
52 |
|
|
-- On-Chip Debugger (OCD) --
|
53 |
|
|
ON_CHIP_DEBUGGER_EN : boolean := false; -- implement on-chip debugger
|
54 |
|
|
|
55 |
|
|
-- RISC-V CPU Extensions --
|
56 |
|
|
CPU_EXTENSION_RISCV_A : boolean := false; -- implement atomic extension?
|
57 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B : boolean := false; -- implement bit-manipulation extension?
|
58 |
64 |
zero_gravi |
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
59 |
|
|
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
60 |
|
|
CPU_EXTENSION_RISCV_M : boolean := false; -- implement mul/div extension?
|
61 |
|
|
CPU_EXTENSION_RISCV_U : boolean := false; -- implement user mode extension?
|
62 |
|
|
CPU_EXTENSION_RISCV_Zfinx : boolean := false; -- implement 32-bit floating-point extension (using INT regs!)
|
63 |
|
|
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
64 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr : boolean := true; -- implement base counters?
|
65 |
|
|
CPU_EXTENSION_RISCV_Zihpm : boolean := false; -- implement hardware performance monitors?
|
66 |
64 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei : boolean := false; -- implement instruction stream sync.?
|
67 |
|
|
CPU_EXTENSION_RISCV_Zmmul : boolean := false; -- implement multiply-only M sub-extension?
|
68 |
|
|
|
69 |
|
|
-- Extension Options --
|
70 |
|
|
FAST_MUL_EN : boolean := false; -- use DSPs for M extension's multiplier
|
71 |
|
|
FAST_SHIFT_EN : boolean := false; -- use barrel shifter for shift operations
|
72 |
|
|
CPU_CNT_WIDTH : natural := 64; -- total width of CPU cycle and instret counters (0..64)
|
73 |
|
|
CPU_IPB_ENTRIES : natural := 2; -- entries is instruction prefetch buffer, has to be a power of 2
|
74 |
|
|
|
75 |
|
|
-- Physical Memory Protection (PMP) --
|
76 |
|
|
PMP_NUM_REGIONS : natural := 0; -- number of regions (0..64)
|
77 |
|
|
PMP_MIN_GRANULARITY : natural := 64*1024; -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
78 |
|
|
|
79 |
|
|
-- Hardware Performance Monitors (HPM) --
|
80 |
|
|
HPM_NUM_CNTS : natural := 0; -- number of implemented HPM counters (0..29)
|
81 |
|
|
HPM_CNT_WIDTH : natural := 40; -- total size of HPM counters (0..64)
|
82 |
|
|
|
83 |
|
|
-- Internal Instruction memory (IMEM) --
|
84 |
|
|
MEM_INT_IMEM_EN : boolean := false; -- implement processor-internal instruction memory
|
85 |
|
|
MEM_INT_IMEM_SIZE : natural := 16*1024; -- size of processor-internal instruction memory in bytes
|
86 |
|
|
|
87 |
|
|
-- Internal Data memory (DMEM) --
|
88 |
|
|
MEM_INT_DMEM_EN : boolean := false; -- implement processor-internal data memory
|
89 |
|
|
MEM_INT_DMEM_SIZE : natural := 8*1024; -- size of processor-internal data memory in bytes
|
90 |
|
|
|
91 |
|
|
-- Internal Cache memory (iCACHE) --
|
92 |
|
|
ICACHE_EN : boolean := false; -- implement instruction cache
|
93 |
|
|
ICACHE_NUM_BLOCKS : natural := 4; -- i-cache: number of blocks (min 1), has to be a power of 2
|
94 |
|
|
ICACHE_BLOCK_SIZE : natural := 64; -- i-cache: block size in bytes (min 4), has to be a power of 2
|
95 |
|
|
ICACHE_ASSOCIATIVITY : natural := 1; -- i-cache: associativity / number of sets (1=direct_mapped), has to be a power of 2
|
96 |
|
|
|
97 |
|
|
-- Stream link interface (SLINK) --
|
98 |
|
|
SLINK_NUM_TX : natural := 0; -- number of TX links (0..8)
|
99 |
|
|
SLINK_NUM_RX : natural := 0; -- number of TX links (0..8)
|
100 |
|
|
SLINK_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two
|
101 |
|
|
SLINK_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two
|
102 |
|
|
|
103 |
|
|
-- External Interrupts Controller (XIRQ) --
|
104 |
|
|
XIRQ_NUM_CH : natural := 0; -- number of external IRQ channels (0..32)
|
105 |
|
|
XIRQ_TRIGGER_TYPE : std_ulogic_vector(31 downto 0) := x"ffffffff"; -- trigger type: 0=level, 1=edge
|
106 |
|
|
XIRQ_TRIGGER_POLARITY : std_ulogic_vector(31 downto 0) := x"ffffffff"; -- trigger polarity: 0=low-level/falling-edge, 1=high-level/rising-edge
|
107 |
|
|
|
108 |
|
|
-- Processor peripherals --
|
109 |
|
|
IO_GPIO_EN : boolean := false; -- implement general purpose input/output port unit (GPIO)?
|
110 |
|
|
IO_MTIME_EN : boolean := false; -- implement machine system timer (MTIME)?
|
111 |
|
|
IO_UART0_EN : boolean := false; -- implement primary universal asynchronous receiver/transmitter (UART0)?
|
112 |
65 |
zero_gravi |
IO_UART0_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two, min 1
|
113 |
|
|
IO_UART0_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two, min 1
|
114 |
64 |
zero_gravi |
IO_UART1_EN : boolean := false; -- implement secondary universal asynchronous receiver/transmitter (UART1)?
|
115 |
65 |
zero_gravi |
IO_UART1_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two, min 1
|
116 |
|
|
IO_UART1_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two, min 1
|
117 |
64 |
zero_gravi |
IO_SPI_EN : boolean := false; -- implement serial peripheral interface (SPI)?
|
118 |
|
|
IO_TWI_EN : boolean := false; -- implement two-wire interface (TWI)?
|
119 |
|
|
IO_PWM_NUM_CH : natural := 0; -- number of PWM channels to implement (0..60); 0 = disabled
|
120 |
|
|
IO_WDT_EN : boolean := false; -- implement watch dog timer (WDT)?
|
121 |
|
|
IO_TRNG_EN : boolean := false; -- implement true random number generator (TRNG)?
|
122 |
|
|
IO_CFS_EN : boolean := false; -- implement custom functions subsystem (CFS)?
|
123 |
|
|
IO_CFS_CONFIG : std_ulogic_vector(31 downto 0) := x"00000000"; -- custom CFS configuration generic
|
124 |
|
|
IO_CFS_IN_SIZE : positive := 32; -- size of CFS input conduit in bits
|
125 |
|
|
IO_CFS_OUT_SIZE : positive := 32; -- size of CFS output conduit in bits
|
126 |
|
|
IO_NEOLED_EN : boolean := false; -- implement NeoPixel-compatible smart LED interface (NEOLED)?
|
127 |
|
|
IO_NEOLED_TX_FIFO : natural := 1 -- NEOLED TX FIFO depth, 1..32k, has to be a power of two
|
128 |
|
|
);
|
129 |
|
|
port (
|
130 |
|
|
-- Global control --
|
131 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
132 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
133 |
|
|
|
134 |
|
|
-- JTAG on-chip debugger interface (available if ON_CHIP_DEBUGGER_EN = true) --
|
135 |
|
|
jtag_trst_i : in std_ulogic := 'U'; -- low-active TAP reset (optional)
|
136 |
|
|
jtag_tck_i : in std_ulogic := 'U'; -- serial clock
|
137 |
|
|
jtag_tdi_i : in std_ulogic := 'U'; -- serial data input
|
138 |
|
|
jtag_tdo_o : out std_ulogic; -- serial data output
|
139 |
|
|
jtag_tms_i : in std_ulogic := 'U'; -- mode select
|
140 |
|
|
|
141 |
|
|
-- AvalonMM interface
|
142 |
|
|
read_o : out std_logic;
|
143 |
|
|
write_o : out std_logic;
|
144 |
|
|
waitrequest_i : in std_logic := '0';
|
145 |
|
|
byteenable_o : out std_logic_vector(3 downto 0);
|
146 |
|
|
address_o : out std_logic_vector(31 downto 0);
|
147 |
|
|
writedata_o : out std_logic_vector(31 downto 0);
|
148 |
|
|
readdata_i : in std_logic_vector(31 downto 0) := (others => '0');
|
149 |
|
|
|
150 |
|
|
-- Advanced memory control signals (available if MEM_EXT_EN = true) --
|
151 |
|
|
fence_o : out std_ulogic; -- indicates an executed FENCE operation
|
152 |
|
|
fencei_o : out std_ulogic; -- indicates an executed FENCEI operation
|
153 |
|
|
|
154 |
|
|
-- TX stream interfaces (available if SLINK_NUM_TX > 0) --
|
155 |
|
|
slink_tx_dat_o : out sdata_8x32_t; -- output data
|
156 |
|
|
slink_tx_val_o : out std_ulogic_vector(7 downto 0); -- valid output
|
157 |
|
|
slink_tx_rdy_i : in std_ulogic_vector(7 downto 0) := (others => 'L'); -- ready to send
|
158 |
|
|
|
159 |
|
|
-- RX stream interfaces (available if SLINK_NUM_RX > 0) --
|
160 |
|
|
slink_rx_dat_i : in sdata_8x32_t := (others => (others => 'U')); -- input data
|
161 |
|
|
slink_rx_val_i : in std_ulogic_vector(7 downto 0) := (others => 'L'); -- valid input
|
162 |
|
|
slink_rx_rdy_o : out std_ulogic_vector(7 downto 0); -- ready to receive
|
163 |
|
|
|
164 |
|
|
-- GPIO (available if IO_GPIO_EN = true) --
|
165 |
|
|
gpio_o : out std_ulogic_vector(63 downto 0); -- parallel output
|
166 |
|
|
gpio_i : in std_ulogic_vector(63 downto 0) := (others => 'U'); -- parallel input
|
167 |
|
|
|
168 |
|
|
-- primary UART0 (available if IO_UART0_EN = true) --
|
169 |
|
|
uart0_txd_o : out std_ulogic; -- UART0 send data
|
170 |
|
|
uart0_rxd_i : in std_ulogic := 'U'; -- UART0 receive data
|
171 |
|
|
uart0_rts_o : out std_ulogic; -- hw flow control: UART0.RX ready to receive ("RTR"), low-active, optional
|
172 |
|
|
uart0_cts_i : in std_ulogic := 'L'; -- hw flow control: UART0.TX allowed to transmit, low-active, optional
|
173 |
|
|
|
174 |
|
|
-- secondary UART1 (available if IO_UART1_EN = true) --
|
175 |
|
|
uart1_txd_o : out std_ulogic; -- UART1 send data
|
176 |
|
|
uart1_rxd_i : in std_ulogic := 'U'; -- UART1 receive data
|
177 |
|
|
uart1_rts_o : out std_ulogic; -- hw flow control: UART1.RX ready to receive ("RTR"), low-active, optional
|
178 |
|
|
uart1_cts_i : in std_ulogic := 'L'; -- hw flow control: UART1.TX allowed to transmit, low-active, optional
|
179 |
|
|
|
180 |
|
|
-- SPI (available if IO_SPI_EN = true) --
|
181 |
|
|
spi_sck_o : out std_ulogic; -- SPI serial clock
|
182 |
|
|
spi_sdo_o : out std_ulogic; -- controller data out, peripheral data in
|
183 |
|
|
spi_sdi_i : in std_ulogic := 'U'; -- controller data in, peripheral data out
|
184 |
|
|
spi_csn_o : out std_ulogic_vector(07 downto 0); -- chip-select
|
185 |
|
|
|
186 |
|
|
-- TWI (available if IO_TWI_EN = true) --
|
187 |
|
|
twi_sda_io : inout std_logic := 'U'; -- twi serial data line
|
188 |
|
|
twi_scl_io : inout std_logic := 'U'; -- twi serial clock line
|
189 |
|
|
|
190 |
|
|
-- PWM (available if IO_PWM_NUM_CH > 0) --
|
191 |
|
|
pwm_o : out std_ulogic_vector(IO_PWM_NUM_CH-1 downto 0); -- pwm channels
|
192 |
|
|
|
193 |
|
|
-- Custom Functions Subsystem IO (available if IO_CFS_EN = true) --
|
194 |
|
|
cfs_in_i : in std_ulogic_vector(IO_CFS_IN_SIZE-1 downto 0) := (others => 'U'); -- custom CFS inputs conduit
|
195 |
|
|
cfs_out_o : out std_ulogic_vector(IO_CFS_OUT_SIZE-1 downto 0); -- custom CFS outputs conduit
|
196 |
|
|
|
197 |
|
|
-- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
|
198 |
|
|
neoled_o : out std_ulogic; -- async serial data line
|
199 |
|
|
|
200 |
|
|
-- System time --
|
201 |
|
|
mtime_i : in std_ulogic_vector(63 downto 0) := (others => 'U'); -- current system time from ext. MTIME (if IO_MTIME_EN = false)
|
202 |
|
|
mtime_o : out std_ulogic_vector(63 downto 0); -- current system time from int. MTIME (if IO_MTIME_EN = true)
|
203 |
|
|
|
204 |
|
|
-- External platform interrupts (available if XIRQ_NUM_CH > 0) --
|
205 |
|
|
xirq_i : in std_ulogic_vector(XIRQ_NUM_CH-1 downto 0) := (others => 'L'); -- IRQ channels
|
206 |
|
|
|
207 |
|
|
-- CPU interrupts --
|
208 |
|
|
mtime_irq_i : in std_ulogic := 'L'; -- machine timer interrupt, available if IO_MTIME_EN = false
|
209 |
|
|
msw_irq_i : in std_ulogic := 'L'; -- machine software interrupt
|
210 |
|
|
mext_irq_i : in std_ulogic := 'L' -- machine external interrupt
|
211 |
|
|
);
|
212 |
|
|
end neorv32_top_avalonmm;
|
213 |
|
|
|
214 |
|
|
architecture neorv32_top_avalonmm_rtl of neorv32_top_avalonmm is
|
215 |
|
|
|
216 |
65 |
zero_gravi |
-- Wishbone bus interface (available if MEM_EXT_EN = true) --
|
217 |
|
|
signal wb_tag_o : std_ulogic_vector(02 downto 0); -- request tag
|
218 |
|
|
signal wb_adr_o : std_ulogic_vector(31 downto 0); -- address
|
219 |
|
|
signal wb_dat_i : std_ulogic_vector(31 downto 0) := (others => 'U'); -- read data
|
220 |
|
|
signal wb_dat_o : std_ulogic_vector(31 downto 0); -- write data
|
221 |
|
|
signal wb_we_o : std_ulogic; -- read/write
|
222 |
|
|
signal wb_sel_o : std_ulogic_vector(03 downto 0); -- byte enable
|
223 |
|
|
signal wb_stb_o : std_ulogic; -- strobe
|
224 |
|
|
signal wb_cyc_o : std_ulogic; -- valid cycle
|
225 |
|
|
signal wb_lock_o : std_ulogic; -- exclusive access request
|
226 |
|
|
signal wb_ack_i : std_ulogic := 'L'; -- transfer acknowledge
|
227 |
|
|
signal wb_err_i : std_ulogic := 'L'; -- transfer error
|
228 |
64 |
zero_gravi |
|
229 |
|
|
begin
|
230 |
|
|
|
231 |
|
|
neorv32_top_map : neorv32_top
|
232 |
|
|
generic map (
|
233 |
|
|
-- General --
|
234 |
|
|
CLOCK_FREQUENCY => CLOCK_FREQUENCY,
|
235 |
|
|
HW_THREAD_ID => HW_THREAD_ID,
|
236 |
|
|
INT_BOOTLOADER_EN => INT_BOOTLOADER_EN,
|
237 |
|
|
|
238 |
|
|
-- On-Chip Debugger (OCD) --
|
239 |
|
|
ON_CHIP_DEBUGGER_EN => ON_CHIP_DEBUGGER_EN,
|
240 |
|
|
|
241 |
|
|
-- RISC-V CPU Extensions --
|
242 |
|
|
CPU_EXTENSION_RISCV_A => CPU_EXTENSION_RISCV_A,
|
243 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B => CPU_EXTENSION_RISCV_B,
|
244 |
64 |
zero_gravi |
CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C,
|
245 |
|
|
CPU_EXTENSION_RISCV_E => CPU_EXTENSION_RISCV_E,
|
246 |
|
|
CPU_EXTENSION_RISCV_M => CPU_EXTENSION_RISCV_M,
|
247 |
|
|
CPU_EXTENSION_RISCV_U => CPU_EXTENSION_RISCV_U,
|
248 |
|
|
CPU_EXTENSION_RISCV_Zfinx => CPU_EXTENSION_RISCV_Zfinx,
|
249 |
|
|
CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr,
|
250 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr => CPU_EXTENSION_RISCV_Zicntr,
|
251 |
|
|
CPU_EXTENSION_RISCV_Zihpm => CPU_EXTENSION_RISCV_Zihpm,
|
252 |
64 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei => CPU_EXTENSION_RISCV_Zifencei,
|
253 |
|
|
CPU_EXTENSION_RISCV_Zmmul => CPU_EXTENSION_RISCV_Zmmul,
|
254 |
|
|
|
255 |
|
|
-- Extension Options --
|
256 |
|
|
FAST_MUL_EN => FAST_MUL_EN,
|
257 |
|
|
FAST_SHIFT_EN => FAST_SHIFT_EN,
|
258 |
|
|
CPU_CNT_WIDTH => CPU_CNT_WIDTH,
|
259 |
|
|
CPU_IPB_ENTRIES => CPU_IPB_ENTRIES,
|
260 |
|
|
|
261 |
|
|
-- Physical Memory Protection (PMP) --
|
262 |
|
|
PMP_NUM_REGIONS => PMP_NUM_REGIONS,
|
263 |
|
|
PMP_MIN_GRANULARITY => PMP_MIN_GRANULARITY,
|
264 |
|
|
|
265 |
|
|
-- Hardware Performance Monitors (HPM) --
|
266 |
|
|
HPM_NUM_CNTS => HPM_NUM_CNTS,
|
267 |
|
|
HPM_CNT_WIDTH => HPM_CNT_WIDTH,
|
268 |
|
|
|
269 |
|
|
-- Internal Instruction memory (IMEM) --
|
270 |
|
|
MEM_INT_IMEM_EN => MEM_INT_IMEM_EN,
|
271 |
|
|
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE,
|
272 |
|
|
|
273 |
|
|
-- Internal Data memory (DMEM) --
|
274 |
|
|
MEM_INT_DMEM_EN => MEM_INT_IMEM_EN,
|
275 |
|
|
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE,
|
276 |
|
|
|
277 |
|
|
-- Internal Cache memory (iCACHE) --
|
278 |
|
|
ICACHE_EN => ICACHE_EN,
|
279 |
|
|
ICACHE_NUM_BLOCKS => ICACHE_NUM_BLOCKS,
|
280 |
|
|
ICACHE_BLOCK_SIZE => ICACHE_BLOCK_SIZE,
|
281 |
|
|
ICACHE_ASSOCIATIVITY => ICACHE_ASSOCIATIVITY,
|
282 |
|
|
|
283 |
|
|
-- External memory interface (WISHBONE) --
|
284 |
|
|
MEM_EXT_EN => true,
|
285 |
|
|
MEM_EXT_TIMEOUT => 0,
|
286 |
|
|
MEM_EXT_PIPE_MODE => false,
|
287 |
|
|
MEM_EXT_BIG_ENDIAN => false,
|
288 |
|
|
MEM_EXT_ASYNC_RX => false,
|
289 |
|
|
|
290 |
|
|
-- Stream link interface (SLINK) --
|
291 |
|
|
SLINK_NUM_TX => SLINK_NUM_TX,
|
292 |
|
|
SLINK_NUM_RX => SLINK_NUM_RX,
|
293 |
|
|
SLINK_TX_FIFO => SLINK_TX_FIFO,
|
294 |
|
|
SLINK_RX_FIFO => SLINK_RX_FIFO,
|
295 |
|
|
|
296 |
|
|
-- External Interrupts Controller (XIRQ) --
|
297 |
|
|
XIRQ_NUM_CH => XIRQ_NUM_CH,
|
298 |
|
|
XIRQ_TRIGGER_TYPE => XIRQ_TRIGGER_TYPE,
|
299 |
|
|
XIRQ_TRIGGER_POLARITY => XIRQ_TRIGGER_POLARITY,
|
300 |
|
|
|
301 |
|
|
-- Processor peripherals --
|
302 |
|
|
IO_GPIO_EN => IO_GPIO_EN,
|
303 |
|
|
IO_MTIME_EN => IO_MTIME_EN,
|
304 |
|
|
IO_UART0_EN => IO_UART0_EN,
|
305 |
65 |
zero_gravi |
IO_UART0_RX_FIFO => IO_UART0_RX_FIFO,
|
306 |
|
|
IO_UART0_TX_FIFO => IO_UART0_TX_FIFO,
|
307 |
64 |
zero_gravi |
IO_UART1_EN => IO_UART1_EN,
|
308 |
65 |
zero_gravi |
IO_UART1_RX_FIFO => IO_UART1_RX_FIFO,
|
309 |
|
|
IO_UART1_TX_FIFO => IO_UART1_TX_FIFO,
|
310 |
64 |
zero_gravi |
IO_SPI_EN => IO_SPI_EN,
|
311 |
|
|
IO_TWI_EN => IO_TWI_EN,
|
312 |
|
|
IO_PWM_NUM_CH => IO_PWM_NUM_CH,
|
313 |
|
|
IO_WDT_EN => IO_WDT_EN,
|
314 |
|
|
IO_TRNG_EN => IO_TRNG_EN,
|
315 |
|
|
IO_CFS_EN => IO_CFS_EN,
|
316 |
|
|
IO_CFS_CONFIG => IO_CFS_CONFIG,
|
317 |
|
|
IO_CFS_IN_SIZE => IO_CFS_IN_SIZE,
|
318 |
|
|
IO_CFS_OUT_SIZE => IO_CFS_OUT_SIZE,
|
319 |
|
|
IO_NEOLED_EN => IO_NEOLED_EN,
|
320 |
|
|
IO_NEOLED_TX_FIFO => IO_NEOLED_TX_FIFO)
|
321 |
|
|
port map (
|
322 |
|
|
-- Global control --
|
323 |
|
|
clk_i => clk_i,
|
324 |
|
|
rstn_i => rstn_i,
|
325 |
|
|
|
326 |
|
|
-- JTAG on-chip debugger interface (available if ON_CHIP_DEBUGGER_EN = true) --
|
327 |
|
|
jtag_trst_i => jtag_trst_i,
|
328 |
|
|
jtag_tck_i => jtag_tck_i,
|
329 |
|
|
jtag_tdi_i => jtag_tdi_i,
|
330 |
|
|
jtag_tdo_o => jtag_tdo_o,
|
331 |
|
|
jtag_tms_i => jtag_tms_i,
|
332 |
|
|
|
333 |
|
|
-- Wishbone bus interface (available if MEM_EXT_EN = true) --
|
334 |
|
|
wb_tag_o => wb_tag_o,
|
335 |
|
|
wb_adr_o => wb_adr_o,
|
336 |
|
|
wb_dat_i => wb_dat_i,
|
337 |
|
|
wb_dat_o => wb_dat_o,
|
338 |
|
|
wb_we_o => wb_we_o,
|
339 |
|
|
wb_sel_o => wb_sel_o,
|
340 |
|
|
wb_stb_o => wb_stb_o,
|
341 |
|
|
wb_cyc_o => wb_cyc_o,
|
342 |
|
|
wb_lock_o => wb_lock_o,
|
343 |
|
|
wb_ack_i => wb_ack_i,
|
344 |
|
|
wb_err_i => wb_err_i,
|
345 |
|
|
|
346 |
|
|
-- Advanced memory control signals (available if MEM_EXT_EN = true) --
|
347 |
|
|
fence_o => fence_o,
|
348 |
|
|
fencei_o => fencei_o,
|
349 |
|
|
|
350 |
|
|
-- TX stream interfaces (available if SLINK_NUM_TX > 0) --
|
351 |
|
|
slink_tx_dat_o => slink_tx_dat_o,
|
352 |
|
|
slink_tx_val_o => slink_tx_val_o,
|
353 |
|
|
slink_tx_rdy_i => slink_tx_rdy_i,
|
354 |
|
|
|
355 |
|
|
-- RX stream interfaces (available if SLINK_NUM_RX > 0) --
|
356 |
|
|
slink_rx_dat_i => slink_rx_dat_i,
|
357 |
|
|
slink_rx_val_i => slink_rx_val_i,
|
358 |
|
|
slink_rx_rdy_o => slink_rx_rdy_o,
|
359 |
|
|
|
360 |
|
|
-- GPIO (available if IO_GPIO_EN = true) --
|
361 |
|
|
gpio_o => gpio_o,
|
362 |
|
|
gpio_i => gpio_i,
|
363 |
|
|
|
364 |
|
|
-- primary UART0 (available if IO_UART0_EN = true) --
|
365 |
|
|
uart0_txd_o => uart0_txd_o,
|
366 |
|
|
uart0_rxd_i => uart0_rxd_i,
|
367 |
|
|
uart0_rts_o => uart0_rts_o,
|
368 |
|
|
uart0_cts_i => uart0_cts_i,
|
369 |
|
|
|
370 |
|
|
-- secondary UART1 (available if IO_UART1_EN = true) --
|
371 |
|
|
uart1_txd_o => uart1_txd_o,
|
372 |
|
|
uart1_rxd_i => uart1_rxd_i,
|
373 |
|
|
uart1_rts_o => uart1_rts_o,
|
374 |
|
|
uart1_cts_i => uart1_cts_i,
|
375 |
|
|
|
376 |
|
|
-- SPI (available if IO_SPI_EN = true) --
|
377 |
|
|
spi_sck_o => spi_sck_o,
|
378 |
|
|
spi_sdo_o => spi_sdo_o,
|
379 |
|
|
spi_sdi_i => spi_sdi_i,
|
380 |
|
|
spi_csn_o => spi_csn_o,
|
381 |
|
|
|
382 |
|
|
-- TWI (available if IO_TWI_EN = true) --
|
383 |
|
|
twi_sda_io => twi_sda_io,
|
384 |
|
|
twi_scl_io => twi_scl_io,
|
385 |
|
|
|
386 |
|
|
-- PWM (available if IO_PWM_NUM_CH > 0) --
|
387 |
|
|
pwm_o => pwm_o,
|
388 |
|
|
|
389 |
|
|
-- Custom Functions Subsystem IO (available if IO_CFS_EN = true) --
|
390 |
|
|
cfs_in_i => cfs_in_i,
|
391 |
|
|
cfs_out_o => cfs_out_o,
|
392 |
|
|
|
393 |
|
|
-- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
|
394 |
|
|
neoled_o => neoled_o,
|
395 |
|
|
|
396 |
|
|
-- System time --
|
397 |
|
|
mtime_i => mtime_i,
|
398 |
|
|
mtime_o => mtime_o,
|
399 |
|
|
|
400 |
|
|
-- External platform interrupts (available if XIRQ_NUM_CH > 0) --
|
401 |
|
|
xirq_i => xirq_i,
|
402 |
|
|
|
403 |
|
|
-- CPU interrupts --
|
404 |
|
|
mtime_irq_i => mtime_irq_i,
|
405 |
|
|
msw_irq_i => msw_irq_i,
|
406 |
65 |
zero_gravi |
mext_irq_i => mext_irq_i
|
407 |
|
|
);
|
408 |
64 |
zero_gravi |
|
409 |
65 |
zero_gravi |
-- Wishbone to AvalonMM bridge
|
410 |
64 |
zero_gravi |
read_o <= '1' when (wb_stb_o = '1' and wb_we_o = '0') else '0';
|
411 |
|
|
write_o <= '1' when (wb_stb_o = '1' and wb_we_o = '1') else '0';
|
412 |
|
|
address_o <= std_logic_vector(wb_adr_o);
|
413 |
|
|
writedata_o <= std_logic_vector(wb_dat_o);
|
414 |
|
|
byteenable_o <= std_logic_vector(wb_sel_o);
|
415 |
|
|
|
416 |
|
|
wb_dat_i <= std_ulogic_vector(readdata_i);
|
417 |
|
|
wb_ack_i <= not(waitrequest_i);
|
418 |
|
|
wb_err_i <= '0';
|
419 |
|
|
|
420 |
|
|
end neorv32_top_avalonmm_rtl;
|