blob: 345bd6ea74f1e550e3d0904b182b4784d989dc20 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
Timothy Chen7ff53122019-09-19 15:20:43 -07005module top_earlgrey #(
6 parameter bit IbexPipeLine = 0
7) (
lowRISC Contributors802543a2019-08-31 12:12:56 +01008 // Clock and Reset
9 input clk_i,
10 input rst_ni,
11
12 // JTAG interface
13 input jtag_tck_i,
14 input jtag_tms_i,
15 input jtag_trst_ni,
16 input jtag_td_i,
17 output jtag_td_o,
18
Eunchan Kim769065e2019-10-29 17:29:26 -070019 // Multiplexed I/O
20 input [31:0] mio_in_i,
21 output logic [31:0] mio_out_o,
22 output logic [31:0] mio_oe_o,
23
24 // Dedicated I/O
25 input dio_spi_device_sck_i,
26 input dio_spi_device_csb_i,
27 input dio_spi_device_mosi_i,
28 output logic dio_spi_device_miso_o,
29 output logic dio_spi_device_miso_en_o,
30 input dio_uart_rx_i,
31 output logic dio_uart_tx_o,
32 output logic dio_uart_tx_en_o,
lowRISC Contributors802543a2019-08-31 12:12:56 +010033
34 input scanmode_i // 1 for Scan
35);
36
Philipp Wagner086b7032019-10-25 17:06:15 +010037 // JTAG IDCODE for development versions of this code.
38 // Manufacturers of OpenTitan chips must replace this code with one of their
39 // own IDs.
40 // Field structure as defined in the IEEE 1149.1 (JTAG) specification,
41 // section 12.1.1.
42 localparam JTAG_IDCODE = {
43 4'h0, // Version
44 16'h4F54, // Part Number: "OT"
Philipp Wagnerf57964e2019-11-04 17:57:06 +000045 11'h426, // Manufacturer Identity: Google
Philipp Wagner086b7032019-10-25 17:06:15 +010046 1'b1 // (fixed)
47 };
48
lowRISC Contributors802543a2019-08-31 12:12:56 +010049 import tlul_pkg::*;
50 import top_pkg::*;
51 import tl_main_pkg::*;
52 import flash_ctrl_pkg::*;
53
54 tl_h2d_t tl_corei_h_h2d;
55 tl_d2h_t tl_corei_h_d2h;
56
57 tl_h2d_t tl_cored_h_h2d;
58 tl_d2h_t tl_cored_h_d2h;
59
60 tl_h2d_t tl_dm_sba_h_h2d;
61 tl_d2h_t tl_dm_sba_h_d2h;
62
63 tl_h2d_t tl_debug_mem_d_h2d;
64 tl_d2h_t tl_debug_mem_d_d2h;
65
66 tl_h2d_t tl_uart_d_h2d;
67 tl_d2h_t tl_uart_d_d2h;
68 tl_h2d_t tl_gpio_d_h2d;
69 tl_d2h_t tl_gpio_d_d2h;
70 tl_h2d_t tl_spi_device_d_h2d;
71 tl_d2h_t tl_spi_device_d_d2h;
72 tl_h2d_t tl_flash_ctrl_d_h2d;
73 tl_d2h_t tl_flash_ctrl_d_d2h;
74 tl_h2d_t tl_rv_timer_d_h2d;
75 tl_d2h_t tl_rv_timer_d_d2h;
Pirmin Vogeld4534382019-10-17 13:18:31 +010076 tl_h2d_t tl_aes_d_h2d;
77 tl_d2h_t tl_aes_d_d2h;
lowRISC Contributors802543a2019-08-31 12:12:56 +010078 tl_h2d_t tl_hmac_d_h2d;
79 tl_d2h_t tl_hmac_d_d2h;
80 tl_h2d_t tl_rv_plic_d_h2d;
81 tl_d2h_t tl_rv_plic_d_d2h;
Eunchan Kim769065e2019-10-29 17:29:26 -070082 tl_h2d_t tl_pinmux_d_h2d;
83 tl_d2h_t tl_pinmux_d_d2h;
lowRISC Contributors802543a2019-08-31 12:12:56 +010084
85 tl_h2d_t tl_rom_d_h2d;
86 tl_d2h_t tl_rom_d_d2h;
87 tl_h2d_t tl_ram_main_d_h2d;
88 tl_d2h_t tl_ram_main_d_d2h;
89 tl_h2d_t tl_eflash_d_h2d;
90 tl_d2h_t tl_eflash_d_d2h;
Timothy Chen3193b002019-10-04 16:56:05 -070091
92 //reset wires declaration
93 logic lc_rst_n;
94 logic sys_rst_n;
95 logic spi_device_rst_n;
96
Timothy Chen80bd8aa2019-10-04 15:57:11 -070097 //clock wires declaration
98 logic main_clk;
99
Eunchan Kim769065e2019-10-29 17:29:26 -0700100 // Signals
101 logic [31:0] m2p;
102 logic [31:0] p2m;
103 logic [31:0] p2m_en;
104 // uart
105 logic cio_uart_rx_p2d;
106 logic cio_uart_tx_d2p;
107 logic cio_uart_tx_en_d2p;
108 // gpio
109 logic [31:0] cio_gpio_gpio_p2d;
110 logic [31:0] cio_gpio_gpio_d2p;
111 logic [31:0] cio_gpio_gpio_en_d2p;
112 // spi_device
113 logic cio_spi_device_sck_p2d;
114 logic cio_spi_device_csb_p2d;
115 logic cio_spi_device_mosi_p2d;
116 logic cio_spi_device_miso_d2p;
117 logic cio_spi_device_miso_en_d2p;
118 // flash_ctrl
119 // rv_timer
120 // aes
121 // hmac
122 // rv_plic
123 // pinmux
124
125
Eunchan Kim226eab62019-10-18 14:11:29 -0700126 logic [54:0] intr_vector;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100127 // Interrupt source list
128 logic intr_uart_tx_watermark;
129 logic intr_uart_rx_watermark;
130 logic intr_uart_tx_overflow;
131 logic intr_uart_rx_overflow;
132 logic intr_uart_rx_frame_err;
133 logic intr_uart_rx_break_err;
134 logic intr_uart_rx_timeout;
135 logic intr_uart_rx_parity_err;
136 logic [31:0] intr_gpio_gpio;
Eunchan Kim8c57fe32019-09-02 21:14:24 -0700137 logic intr_spi_device_rxf;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100138 logic intr_spi_device_rxlvl;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100139 logic intr_spi_device_txlvl;
140 logic intr_spi_device_rxerr;
Eunchan Kim546c0d42019-09-24 15:07:06 -0700141 logic intr_spi_device_rxoverflow;
142 logic intr_spi_device_txunderflow;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100143 logic intr_flash_ctrl_prog_empty;
144 logic intr_flash_ctrl_prog_lvl;
145 logic intr_flash_ctrl_rd_full;
146 logic intr_flash_ctrl_rd_lvl;
147 logic intr_flash_ctrl_op_done;
148 logic intr_flash_ctrl_op_error;
149 logic intr_rv_timer_timer_expired_0_0;
150 logic intr_hmac_hmac_done;
151 logic intr_hmac_fifo_full;
Eunchan Kim226eab62019-10-18 14:11:29 -0700152 logic intr_hmac_hmac_err;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100153
154
155 logic [0:0] irq_plic;
156 logic [5:0] irq_id[1];
157 logic [0:0] msip;
158
lowRISC Contributors802543a2019-08-31 12:12:56 +0100159
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700160 // clock assignments
161 assign main_clk = clk_i;
162
Timothy Chen3193b002019-10-04 16:56:05 -0700163 // Non-debug module reset == reset for everything except for the debug module
164 logic ndmreset_req;
165
166 // root resets
167 // TODO: lc_rst_n is not the true root reset. It will be differentiated once the
168 // the reset controller logic is present
169 assign lc_rst_n = rst_ni;
170 assign sys_rst_n = (scanmode_i) ? lc_rst_n : ~ndmreset_req & lc_rst_n;
171
172 //non-root reset assignments
173 assign spi_device_rst_n = sys_rst_n;
174
175 // debug request from rv_dm to core
lowRISC Contributors802543a2019-08-31 12:12:56 +0100176 logic debug_req;
177
178 // processor core
179 rv_core_ibex #(
Philipp Wagnera3ec3ba2019-10-16 14:15:50 +0100180 .PMPEnable (0),
181 .PMPGranularity (0),
182 .PMPNumRegions (4),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100183 .MHPMCounterNum (8),
184 .MHPMCounterWidth (40),
185 .RV32E (0),
186 .RV32M (1),
187 .DmHaltAddr (ADDR_SPACE_DEBUG_MEM + dm::HaltAddress),
Timothy Chen7ff53122019-09-19 15:20:43 -0700188 .DmExceptionAddr (ADDR_SPACE_DEBUG_MEM + dm::ExceptionAddress),
189 .PipeLine (IbexPipeLine)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100190 ) core (
191 // clock and reset
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700192 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700193 .rst_ni (sys_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100194 .test_en_i (1'b0),
195 // static pinning
Greg Chadwick53ef2ec2019-09-03 14:53:54 +0100196 .hart_id_i (32'b0),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100197 .boot_addr_i (ADDR_SPACE_ROM),
198 // TL-UL buses
199 .tl_i_o (tl_corei_h_h2d),
200 .tl_i_i (tl_corei_h_d2h),
201 .tl_d_o (tl_cored_h_h2d),
202 .tl_d_i (tl_cored_h_d2h),
203 // interrupts
204 .irq_software_i (msip),
205 .irq_timer_i (intr_rv_timer_timer_expired_0_0),
206 .irq_external_i (irq_plic),
207 .irq_fast_i (15'b0),// PLIC handles all peripheral interrupts
208 .irq_nm_i (1'b0),// TODO - add and connect alert responder
209 // debug interface
210 .debug_req_i (debug_req),
211 // CPU control signals
Pirmin Vogelffc9e832019-09-13 16:16:05 +0100212 .fetch_enable_i (1'b1),
213 .core_sleep_o ()
lowRISC Contributors802543a2019-08-31 12:12:56 +0100214 );
215
216 // Debug Module (RISC-V Debug Spec 0.13)
217 //
218
219 rv_dm #(
Philipp Wagner086b7032019-10-25 17:06:15 +0100220 .NrHarts (1),
221 .IdcodeValue (JTAG_IDCODE)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100222 ) u_dm_top (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700223 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700224 .rst_ni (lc_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100225 .testmode_i (1'b0),
Timothy Chen3193b002019-10-04 16:56:05 -0700226 .ndmreset_o (ndmreset_req),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100227 .dmactive_o (),
228 .debug_req_o (debug_req),
229 .unavailable_i (1'b0),
230
231 // bus device with debug memory (for execution-based debug)
232 .tl_d_i (tl_debug_mem_d_h2d),
233 .tl_d_o (tl_debug_mem_d_d2h),
234
235 // bus host (for system bus accesses, SBA)
236 .tl_h_o (tl_dm_sba_h_h2d),
237 .tl_h_i (tl_dm_sba_h_d2h),
238
239 //JTAG
240 .tck_i (jtag_tck_i),
241 .tms_i (jtag_tms_i),
242 .trst_ni (jtag_trst_ni),
243 .td_i (jtag_td_i),
244 .td_o (jtag_td_o),
245 .tdo_oe_o ( )
246 );
247
Timothy Chen44461032019-09-20 15:35:20 -0700248 // ROM device
lowRISC Contributors802543a2019-08-31 12:12:56 +0100249 logic rom_req;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100250 logic [10:0] rom_addr;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100251 logic [31:0] rom_rdata;
252 logic rom_rvalid;
253
254 tlul_adapter_sram #(
255 .SramAw(11),
256 .SramDw(32),
Timothy Chen44461032019-09-20 15:35:20 -0700257 .Outstanding(1),
258 .ErrOnWrite(1)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100259 ) tl_adapter_rom (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700260 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700261 .rst_ni (sys_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100262
263 .tl_i (tl_rom_d_h2d),
264 .tl_o (tl_rom_d_d2h),
265
266 .req_o (rom_req),
267 .gnt_i (1'b1), // Always grant as only one requester exists
Timothy Chen44461032019-09-20 15:35:20 -0700268 .we_o (),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100269 .addr_o (rom_addr),
Timothy Chen44461032019-09-20 15:35:20 -0700270 .wdata_o (),
271 .wmask_o (),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100272 .rdata_i (rom_rdata),
273 .rvalid_i (rom_rvalid),
274 .rerror_i (2'b00)
275 );
276
Timothy Chen44461032019-09-20 15:35:20 -0700277 prim_rom #(
lowRISC Contributors802543a2019-08-31 12:12:56 +0100278 .Width(32),
Timothy Chen44461032019-09-20 15:35:20 -0700279 .Depth(2048)
280 ) u_rom_rom (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700281 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700282 .rst_ni (sys_rst_n),
Timothy Chen44461032019-09-20 15:35:20 -0700283 .cs_i (rom_req),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100284 .addr_i (rom_addr),
Timothy Chen44461032019-09-20 15:35:20 -0700285 .dout_o (rom_rdata),
286 .dvalid_o (rom_rvalid)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100287 );
Timothy Chen44461032019-09-20 15:35:20 -0700288
lowRISC Contributors802543a2019-08-31 12:12:56 +0100289 // sram device
290 logic ram_main_req;
291 logic ram_main_we;
292 logic [13:0] ram_main_addr;
293 logic [31:0] ram_main_wdata;
294 logic [31:0] ram_main_wmask;
295 logic [31:0] ram_main_rdata;
296 logic ram_main_rvalid;
297
298 tlul_adapter_sram #(
299 .SramAw(14),
300 .SramDw(32),
301 .Outstanding(1)
302 ) tl_adapter_ram_main (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700303 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700304 .rst_ni (sys_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100305 .tl_i (tl_ram_main_d_h2d),
306 .tl_o (tl_ram_main_d_d2h),
307
308 .req_o (ram_main_req),
309 .gnt_i (1'b1), // Always grant as only one requester exists
310 .we_o (ram_main_we),
311 .addr_o (ram_main_addr),
312 .wdata_o (ram_main_wdata),
313 .wmask_o (ram_main_wmask),
314 .rdata_i (ram_main_rdata),
315 .rvalid_i (ram_main_rvalid),
316 .rerror_i (2'b00)
317 );
318
319 prim_ram_1p #(
320 .Width(32),
321 .Depth(16384),
322 .DataBitsPerMask(8)
323 ) u_ram1p_ram_main (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700324 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700325 .rst_ni (sys_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100326
327 .req_i (ram_main_req),
328 .write_i (ram_main_we),
329 .addr_i (ram_main_addr),
330 .wdata_i (ram_main_wdata),
331 .wmask_i (ram_main_wmask),
332 .rvalid_o (ram_main_rvalid),
333 .rdata_o (ram_main_rdata)
334 );
335
336 // flash controller to eflash communication
337 flash_c2m_t flash_c2m;
338 flash_m2c_t flash_m2c;
339
340 // host to flash communication
341 logic flash_host_req;
342 logic flash_host_req_rdy;
343 logic flash_host_req_done;
344 logic [FLASH_DW-1:0] flash_host_rdata;
345 logic [FLASH_AW-1:0] flash_host_addr;
346
Timothy Chen5aec5282019-09-10 21:10:56 -0700347 tlul_adapter_sram #(
348 .SramAw(FLASH_AW),
349 .SramDw(FLASH_DW),
350 .Outstanding(1),
351 .ByteAccess(0),
352 .ErrOnWrite(1)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100353 ) tl_adapter_eflash (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700354 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700355 .rst_ni (lc_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100356
357 .tl_i (tl_eflash_d_h2d),
358 .tl_o (tl_eflash_d_d2h),
359
Timothy Chen5aec5282019-09-10 21:10:56 -0700360 .req_o (flash_host_req),
361 .gnt_i (flash_host_req_rdy),
362 .we_o (),
363 .addr_o (flash_host_addr),
364 .wdata_o (),
365 .wmask_o (),
366 .rdata_i (flash_host_rdata),
367 .rvalid_i (flash_host_req_done),
368 .rerror_i (2'b00)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100369 );
370
371 flash_phy #(
372 .NumBanks(FLASH_BANKS),
373 .PagesPerBank(FLASH_PAGES_PER_BANK),
374 .WordsPerPage(FLASH_WORDS_PER_PAGE),
375 .DataWidth(32)
376 ) u_flash_eflash (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700377 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700378 .rst_ni (lc_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100379 .host_req_i (flash_host_req),
380 .host_addr_i (flash_host_addr),
381 .host_req_rdy_o (flash_host_req_rdy),
382 .host_req_done_o (flash_host_req_done),
383 .host_rdata_o (flash_host_rdata),
384 .flash_ctrl_i (flash_c2m),
385 .flash_ctrl_o (flash_m2c)
386 );
387
388
389 uart uart (
390 .tl_i (tl_uart_d_h2d),
391 .tl_o (tl_uart_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700392
393 // Input
394 .cio_rx_i (cio_uart_rx_p2d),
395
396 // Output
397 .cio_tx_o (cio_uart_tx_d2p),
398 .cio_tx_en_o (cio_uart_tx_en_d2p),
399
400 // Interrupt
401 .intr_tx_watermark_o (intr_uart_tx_watermark),
402 .intr_rx_watermark_o (intr_uart_rx_watermark),
403 .intr_tx_overflow_o (intr_uart_tx_overflow),
404 .intr_rx_overflow_o (intr_uart_rx_overflow),
405 .intr_rx_frame_err_o (intr_uart_rx_frame_err),
406 .intr_rx_break_err_o (intr_uart_rx_break_err),
407 .intr_rx_timeout_o (intr_uart_rx_timeout),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100408 .intr_rx_parity_err_o (intr_uart_rx_parity_err),
Timothy Chen3193b002019-10-04 16:56:05 -0700409
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700410 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700411 .rst_ni (sys_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100412 );
413
414 gpio gpio (
415 .tl_i (tl_gpio_d_h2d),
416 .tl_o (tl_gpio_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700417
418 // Input
419 .cio_gpio_i (cio_gpio_gpio_p2d),
420
421 // Output
422 .cio_gpio_o (cio_gpio_gpio_d2p),
423 .cio_gpio_en_o (cio_gpio_gpio_en_d2p),
424
425 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100426 .intr_gpio_o (intr_gpio_gpio),
Timothy Chen3193b002019-10-04 16:56:05 -0700427
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700428 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700429 .rst_ni (sys_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100430 );
431
432 spi_device spi_device (
433 .tl_i (tl_spi_device_d_h2d),
434 .tl_o (tl_spi_device_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700435
436 // Input
437 .cio_sck_i (cio_spi_device_sck_p2d),
438 .cio_csb_i (cio_spi_device_csb_p2d),
439 .cio_mosi_i (cio_spi_device_mosi_p2d),
440
441 // Output
442 .cio_miso_o (cio_spi_device_miso_d2p),
443 .cio_miso_en_o (cio_spi_device_miso_en_d2p),
444
445 // Interrupt
446 .intr_rxf_o (intr_spi_device_rxf),
447 .intr_rxlvl_o (intr_spi_device_rxlvl),
448 .intr_txlvl_o (intr_spi_device_txlvl),
449 .intr_rxerr_o (intr_spi_device_rxerr),
450 .intr_rxoverflow_o (intr_spi_device_rxoverflow),
Eunchan Kim546c0d42019-09-24 15:07:06 -0700451 .intr_txunderflow_o (intr_spi_device_txunderflow),
Timothy Chen3193b002019-10-04 16:56:05 -0700452
Eunchan Kim2cfadab2019-10-02 12:41:11 -0700453 .scanmode_i (scanmode_i),
Eunchan Kim769065e2019-10-29 17:29:26 -0700454
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700455 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700456 .rst_ni (spi_device_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100457 );
458
459 flash_ctrl flash_ctrl (
460 .tl_i (tl_flash_ctrl_d_h2d),
461 .tl_o (tl_flash_ctrl_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700462
463 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100464 .intr_prog_empty_o (intr_flash_ctrl_prog_empty),
Eunchan Kim769065e2019-10-29 17:29:26 -0700465 .intr_prog_lvl_o (intr_flash_ctrl_prog_lvl),
466 .intr_rd_full_o (intr_flash_ctrl_rd_full),
467 .intr_rd_lvl_o (intr_flash_ctrl_rd_lvl),
468 .intr_op_done_o (intr_flash_ctrl_op_done),
469 .intr_op_error_o (intr_flash_ctrl_op_error),
470
lowRISC Contributors802543a2019-08-31 12:12:56 +0100471 .flash_o(flash_c2m),
472 .flash_i(flash_m2c),
Timothy Chen3193b002019-10-04 16:56:05 -0700473
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700474 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700475 .rst_ni (lc_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100476 );
477
478 rv_timer rv_timer (
479 .tl_i (tl_rv_timer_d_h2d),
480 .tl_o (tl_rv_timer_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700481
482 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100483 .intr_timer_expired_0_0_o (intr_rv_timer_timer_expired_0_0),
Timothy Chen3193b002019-10-04 16:56:05 -0700484
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700485 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700486 .rst_ni (sys_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100487 );
488
Pirmin Vogeld4534382019-10-17 13:18:31 +0100489 aes aes (
490 .tl_i (tl_aes_d_h2d),
491 .tl_o (tl_aes_d_d2h),
492
493 .clk_i (main_clk),
494 .rst_ni (sys_rst_n)
495 );
496
lowRISC Contributors802543a2019-08-31 12:12:56 +0100497 hmac hmac (
498 .tl_i (tl_hmac_d_h2d),
499 .tl_o (tl_hmac_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700500
501 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100502 .intr_hmac_done_o (intr_hmac_hmac_done),
503 .intr_fifo_full_o (intr_hmac_fifo_full),
Eunchan Kim769065e2019-10-29 17:29:26 -0700504 .intr_hmac_err_o (intr_hmac_hmac_err),
Timothy Chen3193b002019-10-04 16:56:05 -0700505
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700506 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700507 .rst_ni (sys_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100508 );
509
510 rv_plic #(
511 .FIND_MAX("MATRIX")
512 ) rv_plic (
513 .tl_i (tl_rv_plic_d_h2d),
514 .tl_o (tl_rv_plic_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700515
lowRISC Contributors802543a2019-08-31 12:12:56 +0100516 .intr_src_i (intr_vector),
517 .irq_o (irq_plic),
518 .irq_id_o (irq_id),
519 .msip_o (msip),
Timothy Chen3193b002019-10-04 16:56:05 -0700520
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700521 .clk_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700522 .rst_ni (sys_rst_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100523 );
524
Eunchan Kim769065e2019-10-29 17:29:26 -0700525 pinmux pinmux (
526 .tl_i (tl_pinmux_d_h2d),
527 .tl_o (tl_pinmux_d_d2h),
528
529 .periph_to_mio_i (p2m ),
530 .periph_to_mio_oe_i (p2m_en ),
531 .mio_to_periph_o (m2p ),
532
533 .mio_out_o (mio_out_o),
534 .mio_oe_o (mio_oe_o ),
535 .mio_in_i (mio_in_i ),
536
537 .clk_i (main_clk),
538 .rst_ni (sys_rst_n)
539 );
540
lowRISC Contributors802543a2019-08-31 12:12:56 +0100541 // interrupt assignments
542 assign intr_vector = {
Eunchan Kim226eab62019-10-18 14:11:29 -0700543 intr_hmac_hmac_err,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100544 intr_hmac_fifo_full,
545 intr_hmac_hmac_done,
546 intr_flash_ctrl_op_error,
547 intr_flash_ctrl_op_done,
548 intr_flash_ctrl_rd_lvl,
549 intr_flash_ctrl_rd_full,
550 intr_flash_ctrl_prog_lvl,
551 intr_flash_ctrl_prog_empty,
Eunchan Kim546c0d42019-09-24 15:07:06 -0700552 intr_spi_device_txunderflow,
553 intr_spi_device_rxoverflow,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100554 intr_spi_device_rxerr,
555 intr_spi_device_txlvl,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100556 intr_spi_device_rxlvl,
Eunchan Kim8c57fe32019-09-02 21:14:24 -0700557 intr_spi_device_rxf,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100558 intr_uart_rx_parity_err,
559 intr_uart_rx_timeout,
560 intr_uart_rx_break_err,
561 intr_uart_rx_frame_err,
562 intr_uart_rx_overflow,
563 intr_uart_tx_overflow,
564 intr_uart_rx_watermark,
565 intr_uart_tx_watermark,
566 intr_gpio_gpio
567 };
568
569 // TL-UL Crossbar
lowRISC Contributors802543a2019-08-31 12:12:56 +0100570 xbar_main u_xbar_main (
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700571 .clk_main_i (main_clk),
Timothy Chen3193b002019-10-04 16:56:05 -0700572 .rst_main_ni (sys_rst_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100573 .tl_corei_i (tl_corei_h_h2d),
574 .tl_corei_o (tl_corei_h_d2h),
575 .tl_cored_i (tl_cored_h_h2d),
576 .tl_cored_o (tl_cored_h_d2h),
577 .tl_dm_sba_i (tl_dm_sba_h_h2d),
578 .tl_dm_sba_o (tl_dm_sba_h_d2h),
579 .tl_rom_o (tl_rom_d_h2d),
580 .tl_rom_i (tl_rom_d_d2h),
581 .tl_debug_mem_o (tl_debug_mem_d_h2d),
582 .tl_debug_mem_i (tl_debug_mem_d_d2h),
583 .tl_ram_main_o (tl_ram_main_d_h2d),
584 .tl_ram_main_i (tl_ram_main_d_d2h),
585 .tl_eflash_o (tl_eflash_d_h2d),
586 .tl_eflash_i (tl_eflash_d_d2h),
587 .tl_uart_o (tl_uart_d_h2d),
588 .tl_uart_i (tl_uart_d_d2h),
589 .tl_gpio_o (tl_gpio_d_h2d),
590 .tl_gpio_i (tl_gpio_d_d2h),
591 .tl_spi_device_o (tl_spi_device_d_h2d),
592 .tl_spi_device_i (tl_spi_device_d_d2h),
593 .tl_flash_ctrl_o (tl_flash_ctrl_d_h2d),
594 .tl_flash_ctrl_i (tl_flash_ctrl_d_d2h),
595 .tl_rv_timer_o (tl_rv_timer_d_h2d),
596 .tl_rv_timer_i (tl_rv_timer_d_d2h),
597 .tl_hmac_o (tl_hmac_d_h2d),
598 .tl_hmac_i (tl_hmac_d_d2h),
Pirmin Vogeld4534382019-10-17 13:18:31 +0100599 .tl_aes_o (tl_aes_d_h2d),
600 .tl_aes_i (tl_aes_d_d2h),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100601 .tl_rv_plic_o (tl_rv_plic_d_h2d),
602 .tl_rv_plic_i (tl_rv_plic_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700603 .tl_pinmux_o (tl_pinmux_d_h2d),
604 .tl_pinmux_i (tl_pinmux_d_d2h),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100605
606 .scanmode_i
607 );
608
Eunchan Kim769065e2019-10-29 17:29:26 -0700609 // Pinmux connections
610 assign p2m = {
611 cio_gpio_gpio_d2p
612 };
613 assign p2m_en = {
614 cio_gpio_gpio_en_d2p
615 };
616 assign {
617 cio_gpio_gpio_p2d
618 } = m2p;
619
620 assign cio_spi_device_sck_p2d = dio_spi_device_sck_i;
621 assign cio_spi_device_csb_p2d = dio_spi_device_csb_i;
622 assign cio_spi_device_mosi_p2d = dio_spi_device_mosi_i;
623 assign dio_spi_device_miso_o = cio_spi_device_miso_d2p;
624 assign dio_spi_device_miso_en_o = cio_spi_device_miso_en_d2p;
625 assign cio_uart_rx_p2d = dio_uart_rx_i;
626 assign dio_uart_tx_o = cio_uart_tx_d2p;
627 assign dio_uart_tx_en_o = cio_uart_tx_en_d2p;
628
Nils Graf78607aa2019-09-16 15:47:23 -0700629 // make sure scanmode_i is never X (including during reset)
630 `ASSERT_KNOWN(scanmodeKnown, scanmode_i, clk_i, 0)
631
lowRISC Contributors802543a2019-08-31 12:12:56 +0100632endmodule