blob: 2acc14e861e97946e967ad4a7df22bac363fa59a [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 #(
Philipp Wagnera37bcfa2020-05-19 22:46:41 +01006 parameter bit IbexPipeLine = 0,
7 parameter BootRomInitFile = ""
Timothy Chen7ff53122019-09-19 15:20:43 -07008) (
Timothy Chen371c94d2020-06-30 17:18:14 -07009 // Reset, clocks defined as part of intermodule
lowRISC Contributors802543a2019-08-31 12:12:56 +010010 input rst_ni,
11
12 // JTAG interface
13 input jtag_tck_i,
14 input jtag_tms_i,
15 input jtag_trst_ni,
Michael Schaffner79eb65f2020-05-01 19:12:47 -070016 input jtag_tdi_i,
17 output jtag_tdo_o,
lowRISC Contributors802543a2019-08-31 12:12:56 +010018
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,
Eunchan Kim769065e2019-10-29 17:29:26 -070023 // Dedicated I/O
Pirmin Vogelfe6863b2020-05-11 17:30:54 +020024 input [14:0] dio_in_i,
25 output logic [14:0] dio_out_o,
26 output logic [14:0] dio_oe_o,
lowRISC Contributors802543a2019-08-31 12:12:56 +010027
Michael Schaffner79eb65f2020-05-01 19:12:47 -070028 // pad attributes to padring
29 output logic[padctrl_reg_pkg::NMioPads-1:0]
30 [padctrl_reg_pkg::AttrDw-1:0] mio_attr_o,
31 output logic[padctrl_reg_pkg::NDioPads-1:0]
32 [padctrl_reg_pkg::AttrDw-1:0] dio_attr_o,
33
Timothy Chen371c94d2020-06-30 17:18:14 -070034
35 // Inter-module Signal External type
36 input logic clkmgr_clk_main,
37 input logic clkmgr_clk_io,
38 input logic clkmgr_clk_usb,
39 input logic clkmgr_clk_aon,
Timothy Chenac3a8c92020-06-29 20:17:07 -070040 input scan_rst_ni, // reset used for test mode
41 input scanmode_i // 1 for Scan
lowRISC Contributors802543a2019-08-31 12:12:56 +010042);
43
Philipp Wagner086b7032019-10-25 17:06:15 +010044 // JTAG IDCODE for development versions of this code.
45 // Manufacturers of OpenTitan chips must replace this code with one of their
46 // own IDs.
47 // Field structure as defined in the IEEE 1149.1 (JTAG) specification,
48 // section 12.1.1.
Michael Schaffnerd4d5d2f2020-04-17 15:45:55 -070049 localparam logic [31:0] JTAG_IDCODE = {
Philipp Wagner086b7032019-10-25 17:06:15 +010050 4'h0, // Version
51 16'h4F54, // Part Number: "OT"
Philipp Wagnerf57964e2019-11-04 17:57:06 +000052 11'h426, // Manufacturer Identity: Google
Philipp Wagner086b7032019-10-25 17:06:15 +010053 1'b1 // (fixed)
54 };
55
lowRISC Contributors802543a2019-08-31 12:12:56 +010056 import tlul_pkg::*;
57 import top_pkg::*;
58 import tl_main_pkg::*;
lowRISC Contributors802543a2019-08-31 12:12:56 +010059
60 tl_h2d_t tl_corei_h_h2d;
61 tl_d2h_t tl_corei_h_d2h;
62
63 tl_h2d_t tl_cored_h_h2d;
64 tl_d2h_t tl_cored_h_d2h;
65
66 tl_h2d_t tl_dm_sba_h_h2d;
67 tl_d2h_t tl_dm_sba_h_d2h;
68
69 tl_h2d_t tl_debug_mem_d_h2d;
70 tl_d2h_t tl_debug_mem_d_d2h;
71
72 tl_h2d_t tl_uart_d_h2d;
73 tl_d2h_t tl_uart_d_d2h;
74 tl_h2d_t tl_gpio_d_h2d;
75 tl_d2h_t tl_gpio_d_d2h;
76 tl_h2d_t tl_spi_device_d_h2d;
77 tl_d2h_t tl_spi_device_d_d2h;
78 tl_h2d_t tl_flash_ctrl_d_h2d;
79 tl_d2h_t tl_flash_ctrl_d_d2h;
80 tl_h2d_t tl_rv_timer_d_h2d;
81 tl_d2h_t tl_rv_timer_d_d2h;
Pirmin Vogeld4534382019-10-17 13:18:31 +010082 tl_h2d_t tl_aes_d_h2d;
83 tl_d2h_t tl_aes_d_d2h;
lowRISC Contributors802543a2019-08-31 12:12:56 +010084 tl_h2d_t tl_hmac_d_h2d;
85 tl_d2h_t tl_hmac_d_d2h;
86 tl_h2d_t tl_rv_plic_d_h2d;
87 tl_d2h_t tl_rv_plic_d_d2h;
Eunchan Kim769065e2019-10-29 17:29:26 -070088 tl_h2d_t tl_pinmux_d_h2d;
89 tl_d2h_t tl_pinmux_d_d2h;
Michael Schaffner79eb65f2020-05-01 19:12:47 -070090 tl_h2d_t tl_padctrl_d_h2d;
91 tl_d2h_t tl_padctrl_d_d2h;
Michael Schaffner666dde12019-10-25 11:57:54 -070092 tl_h2d_t tl_alert_handler_d_h2d;
93 tl_d2h_t tl_alert_handler_d_d2h;
Timothy Chen163050b2020-04-13 23:29:29 -070094 tl_h2d_t tl_pwrmgr_d_h2d;
95 tl_d2h_t tl_pwrmgr_d_d2h;
Timothy Chenc59f7012020-04-16 19:11:42 -070096 tl_h2d_t tl_rstmgr_d_h2d;
97 tl_d2h_t tl_rstmgr_d_d2h;
Timothy Chenf56c1b52020-04-28 17:00:43 -070098 tl_h2d_t tl_clkmgr_d_h2d;
99 tl_d2h_t tl_clkmgr_d_d2h;
Michael Schaffner666dde12019-10-25 11:57:54 -0700100 tl_h2d_t tl_nmi_gen_d_h2d;
101 tl_d2h_t tl_nmi_gen_d_d2h;
Pirmin Vogelea91b302020-01-14 18:53:01 +0000102 tl_h2d_t tl_usbdev_d_h2d;
103 tl_d2h_t tl_usbdev_d_d2h;
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100104 tl_h2d_t tl_otbn_d_h2d;
105 tl_d2h_t tl_otbn_d_d2h;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100106
107 tl_h2d_t tl_rom_d_h2d;
108 tl_d2h_t tl_rom_d_d2h;
109 tl_h2d_t tl_ram_main_d_h2d;
110 tl_d2h_t tl_ram_main_d_d2h;
Timothy Chen6e2ba842020-06-29 15:04:13 -0700111 tl_h2d_t tl_ram_ret_d_h2d;
112 tl_d2h_t tl_ram_ret_d_d2h;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100113 tl_h2d_t tl_eflash_d_h2d;
114 tl_d2h_t tl_eflash_d_d2h;
Timothy Chen3193b002019-10-04 16:56:05 -0700115
Eunchan Kim009f6e92020-06-03 17:56:52 -0700116 tl_h2d_t tl_main_peri_h2d;
117 tl_d2h_t tl_main_peri_d2h;
Eunchan Kim55d7ae82019-12-19 17:08:35 -0800118
Eunchan Kim769065e2019-10-29 17:29:26 -0700119 // Signals
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700120 logic [31:0] mio_p2d;
121 logic [31:0] mio_d2p;
122 logic [31:0] mio_d2p_en;
Pirmin Vogelfe6863b2020-05-11 17:30:54 +0200123 logic [14:0] dio_p2d;
124 logic [14:0] dio_d2p;
125 logic [14:0] dio_d2p_en;
Eunchan Kim769065e2019-10-29 17:29:26 -0700126 // uart
127 logic cio_uart_rx_p2d;
128 logic cio_uart_tx_d2p;
129 logic cio_uart_tx_en_d2p;
130 // gpio
131 logic [31:0] cio_gpio_gpio_p2d;
132 logic [31:0] cio_gpio_gpio_d2p;
133 logic [31:0] cio_gpio_gpio_en_d2p;
134 // spi_device
135 logic cio_spi_device_sck_p2d;
136 logic cio_spi_device_csb_p2d;
Scott Johnsonfe79c4b2020-07-08 10:31:08 -0700137 logic cio_spi_device_sdi_p2d;
138 logic cio_spi_device_sdo_d2p;
139 logic cio_spi_device_sdo_en_d2p;
Eunchan Kim769065e2019-10-29 17:29:26 -0700140 // flash_ctrl
141 // rv_timer
142 // aes
143 // hmac
144 // rv_plic
145 // pinmux
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700146 // padctrl
Michael Schaffner666dde12019-10-25 11:57:54 -0700147 // alert_handler
Timothy Chen163050b2020-04-13 23:29:29 -0700148 // pwrmgr
Timothy Chenc59f7012020-04-16 19:11:42 -0700149 // rstmgr
Timothy Chenf56c1b52020-04-28 17:00:43 -0700150 // clkmgr
Michael Schaffner666dde12019-10-25 11:57:54 -0700151 // nmi_gen
Pirmin Vogelea91b302020-01-14 18:53:01 +0000152 // usbdev
153 logic cio_usbdev_sense_p2d;
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100154 logic cio_usbdev_d_p2d;
Pirmin Vogelea91b302020-01-14 18:53:01 +0000155 logic cio_usbdev_dp_p2d;
156 logic cio_usbdev_dn_p2d;
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100157 logic cio_usbdev_se0_d2p;
158 logic cio_usbdev_se0_en_d2p;
Pirmin Vogelfe6863b2020-05-11 17:30:54 +0200159 logic cio_usbdev_dp_pullup_d2p;
160 logic cio_usbdev_dp_pullup_en_d2p;
161 logic cio_usbdev_dn_pullup_d2p;
162 logic cio_usbdev_dn_pullup_en_d2p;
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100163 logic cio_usbdev_tx_mode_se_d2p;
164 logic cio_usbdev_tx_mode_se_en_d2p;
165 logic cio_usbdev_suspend_d2p;
166 logic cio_usbdev_suspend_en_d2p;
167 logic cio_usbdev_d_d2p;
168 logic cio_usbdev_d_en_d2p;
Pirmin Vogelea91b302020-01-14 18:53:01 +0000169 logic cio_usbdev_dp_d2p;
170 logic cio_usbdev_dp_en_d2p;
171 logic cio_usbdev_dn_d2p;
172 logic cio_usbdev_dn_en_d2p;
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100173 // otbn
Eunchan Kim769065e2019-10-29 17:29:26 -0700174
175
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100176 logic [82:0] intr_vector;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100177 // Interrupt source list
178 logic intr_uart_tx_watermark;
179 logic intr_uart_rx_watermark;
Timothy Chen087d4f42019-12-27 16:04:46 -0800180 logic intr_uart_tx_empty;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100181 logic intr_uart_rx_overflow;
182 logic intr_uart_rx_frame_err;
183 logic intr_uart_rx_break_err;
184 logic intr_uart_rx_timeout;
185 logic intr_uart_rx_parity_err;
186 logic [31:0] intr_gpio_gpio;
Eunchan Kim8c57fe32019-09-02 21:14:24 -0700187 logic intr_spi_device_rxf;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100188 logic intr_spi_device_rxlvl;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100189 logic intr_spi_device_txlvl;
190 logic intr_spi_device_rxerr;
Eunchan Kim546c0d42019-09-24 15:07:06 -0700191 logic intr_spi_device_rxoverflow;
192 logic intr_spi_device_txunderflow;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100193 logic intr_flash_ctrl_prog_empty;
194 logic intr_flash_ctrl_prog_lvl;
195 logic intr_flash_ctrl_rd_full;
196 logic intr_flash_ctrl_rd_lvl;
197 logic intr_flash_ctrl_op_done;
198 logic intr_flash_ctrl_op_error;
199 logic intr_rv_timer_timer_expired_0_0;
200 logic intr_hmac_hmac_done;
Eunchan Kimd9d69aa2020-03-20 10:21:11 -0700201 logic intr_hmac_fifo_empty;
Eunchan Kim226eab62019-10-18 14:11:29 -0700202 logic intr_hmac_hmac_err;
Michael Schaffner666dde12019-10-25 11:57:54 -0700203 logic intr_alert_handler_classa;
204 logic intr_alert_handler_classb;
205 logic intr_alert_handler_classc;
206 logic intr_alert_handler_classd;
Timothy Chen163050b2020-04-13 23:29:29 -0700207 logic intr_pwrmgr_wakeup;
Michael Schaffner666dde12019-10-25 11:57:54 -0700208 logic intr_nmi_gen_esc0;
209 logic intr_nmi_gen_esc1;
210 logic intr_nmi_gen_esc2;
211 logic intr_nmi_gen_esc3;
Pirmin Vogelea91b302020-01-14 18:53:01 +0000212 logic intr_usbdev_pkt_received;
213 logic intr_usbdev_pkt_sent;
214 logic intr_usbdev_disconnected;
215 logic intr_usbdev_host_lost;
216 logic intr_usbdev_link_reset;
217 logic intr_usbdev_link_suspend;
218 logic intr_usbdev_link_resume;
219 logic intr_usbdev_av_empty;
220 logic intr_usbdev_rx_full;
221 logic intr_usbdev_av_overflow;
222 logic intr_usbdev_link_in_err;
223 logic intr_usbdev_rx_crc_err;
224 logic intr_usbdev_rx_pid_err;
225 logic intr_usbdev_rx_bitstuff_err;
226 logic intr_usbdev_frame;
227 logic intr_usbdev_connected;
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100228 logic intr_otbn_done;
229 logic intr_otbn_err;
Michael Schaffner666dde12019-10-25 11:57:54 -0700230
lowRISC Contributors802543a2019-08-31 12:12:56 +0100231
Michael Schaffnerd4d5d2f2020-04-17 15:45:55 -0700232
Michael Schaffner1ba89b82019-11-03 14:25:54 -0800233 logic [0:0] irq_plic;
234 logic [0:0] msip;
Pirmin Vogelea91b302020-01-14 18:53:01 +0000235 logic [6:0] irq_id[1];
236 logic [6:0] unused_irq_id[1];
lowRISC Contributors802543a2019-08-31 12:12:56 +0100237
Michael Schaffner1ba89b82019-11-03 14:25:54 -0800238 // this avoids lint errors
239 assign unused_irq_id = irq_id;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100240
Michael Schaffner666dde12019-10-25 11:57:54 -0700241 // Alert list
Philipp Wagner79725e12020-03-03 23:34:38 +0000242 prim_alert_pkg::alert_tx_t [alert_pkg::NAlerts-1:0] alert_tx;
243 prim_alert_pkg::alert_rx_t [alert_pkg::NAlerts-1:0] alert_rx;
Michael Schaffner666dde12019-10-25 11:57:54 -0700244 // Escalation outputs
Philipp Wagner79725e12020-03-03 23:34:38 +0000245 prim_esc_pkg::esc_tx_t [alert_pkg::N_ESC_SEV-1:0] esc_tx;
246 prim_esc_pkg::esc_rx_t [alert_pkg::N_ESC_SEV-1:0] esc_rx;
Michael Schaffner666dde12019-10-25 11:57:54 -0700247
248
Eunchan Kim40098a92020-04-17 12:22:36 -0700249 // define inter-module signals
250 flash_ctrl_pkg::flash_req_t flash_ctrl_flash_req;
251 flash_ctrl_pkg::flash_rsp_t flash_ctrl_flash_rsp;
Timothy Chenc59f7012020-04-16 19:11:42 -0700252 pwrmgr_pkg::pwr_rst_req_t pwrmgr_pwr_rst_req;
253 pwrmgr_pkg::pwr_rst_rsp_t pwrmgr_pwr_rst_rsp;
Timothy Chenf56c1b52020-04-28 17:00:43 -0700254 pwrmgr_pkg::pwr_clk_req_t pwrmgr_pwr_clk_req;
255 pwrmgr_pkg::pwr_clk_rsp_t pwrmgr_pwr_clk_rsp;
Timothy Chen4ba25312020-06-17 13:08:57 -0700256 logic pwrmgr_wakeups;
Timothy Chenc59f7012020-04-16 19:11:42 -0700257 rstmgr_pkg::rstmgr_out_t rstmgr_resets;
258 rstmgr_pkg::rstmgr_cpu_t rstmgr_cpu;
259 pwrmgr_pkg::pwr_cpu_t pwrmgr_pwr_cpu;
Timothy Chenf56c1b52020-04-28 17:00:43 -0700260 clkmgr_pkg::clkmgr_out_t clkmgr_clocks;
Pirmin Vogela2d411d2020-07-13 17:33:42 +0200261 logic aes_idle;
262 clkmgr_pkg::clk_hint_status_t clkmgr_status;
263
264 always_comb begin
265 // TODO: So far just aes is connected
266 clkmgr_status.idle = clkmgr_pkg::CLK_HINT_STATUS_DEFAULT;
267 clkmgr_status.idle[0] = aes_idle;
268 end
Timothy Chen80bd8aa2019-10-04 15:57:11 -0700269
Timothy Chen3193b002019-10-04 16:56:05 -0700270 // Non-debug module reset == reset for everything except for the debug module
271 logic ndmreset_req;
272
Timothy Chen3193b002019-10-04 16:56:05 -0700273 // debug request from rv_dm to core
lowRISC Contributors802543a2019-08-31 12:12:56 +0100274 logic debug_req;
275
276 // processor core
277 rv_core_ibex #(
Philipp Wagner25d889222020-04-03 11:52:41 +0100278 .PMPEnable (1),
279 .PMPGranularity (0), // 2^(PMPGranularity+2) == 4 byte granularity
280 .PMPNumRegions (16),
Greg Chadwickdadb1af2020-04-16 17:10:23 +0100281 .MHPMCounterNum (8),
282 .MHPMCounterWidth (40),
283 .RV32E (0),
284 .RV32M (1),
285 .BranchTargetALU (1),
286 .WritebackStage (1),
287 .MultiplierImplementation ("single-cycle"),
Tom Roberts78bb2ae2020-06-03 15:24:22 +0100288 .ICache (0),
289 .ICacheECC (0),
Greg Chadwickdadb1af2020-04-16 17:10:23 +0100290 .DbgTriggerEn (1),
Tom Roberts78bb2ae2020-06-03 15:24:22 +0100291 .SecureIbex (0),
Greg Chadwickdadb1af2020-04-16 17:10:23 +0100292 .DmHaltAddr (ADDR_SPACE_DEBUG_MEM + dm::HaltAddress),
293 .DmExceptionAddr (ADDR_SPACE_DEBUG_MEM + dm::ExceptionAddress),
294 .PipeLine (IbexPipeLine)
Michael Schaffnera39557e2020-03-17 18:30:21 -0700295 ) u_rv_core_ibex (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100296 // clock and reset
Timothy Chenf56c1b52020-04-28 17:00:43 -0700297 .clk_i (clkmgr_clocks.clk_proc_main),
Timothy Chenc59f7012020-04-16 19:11:42 -0700298 .rst_ni (rstmgr_resets.rst_sys_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100299 .test_en_i (1'b0),
300 // static pinning
Greg Chadwick53ef2ec2019-09-03 14:53:54 +0100301 .hart_id_i (32'b0),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100302 .boot_addr_i (ADDR_SPACE_ROM),
303 // TL-UL buses
304 .tl_i_o (tl_corei_h_h2d),
305 .tl_i_i (tl_corei_h_d2h),
306 .tl_d_o (tl_cored_h_h2d),
307 .tl_d_i (tl_cored_h_d2h),
308 // interrupts
309 .irq_software_i (msip),
310 .irq_timer_i (intr_rv_timer_timer_expired_0_0),
311 .irq_external_i (irq_plic),
312 .irq_fast_i (15'b0),// PLIC handles all peripheral interrupts
313 .irq_nm_i (1'b0),// TODO - add and connect alert responder
314 // debug interface
315 .debug_req_i (debug_req),
316 // CPU control signals
Pirmin Vogelffc9e832019-09-13 16:16:05 +0100317 .fetch_enable_i (1'b1),
Timothy Chenc59f7012020-04-16 19:11:42 -0700318 .core_sleep_o (pwrmgr_pwr_cpu.core_sleeping)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100319 );
320
321 // Debug Module (RISC-V Debug Spec 0.13)
322 //
323
324 rv_dm #(
Philipp Wagner086b7032019-10-25 17:06:15 +0100325 .NrHarts (1),
326 .IdcodeValue (JTAG_IDCODE)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100327 ) u_dm_top (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700328 .clk_i (clkmgr_clocks.clk_proc_main),
Timothy Chenc59f7012020-04-16 19:11:42 -0700329 .rst_ni (rstmgr_resets.rst_lc_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100330 .testmode_i (1'b0),
Timothy Chen3193b002019-10-04 16:56:05 -0700331 .ndmreset_o (ndmreset_req),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100332 .dmactive_o (),
333 .debug_req_o (debug_req),
334 .unavailable_i (1'b0),
335
336 // bus device with debug memory (for execution-based debug)
337 .tl_d_i (tl_debug_mem_d_h2d),
338 .tl_d_o (tl_debug_mem_d_d2h),
339
340 // bus host (for system bus accesses, SBA)
341 .tl_h_o (tl_dm_sba_h_h2d),
342 .tl_h_i (tl_dm_sba_h_d2h),
343
344 //JTAG
345 .tck_i (jtag_tck_i),
346 .tms_i (jtag_tms_i),
347 .trst_ni (jtag_trst_ni),
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700348 .td_i (jtag_tdi_i),
349 .td_o (jtag_tdo_o),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100350 .tdo_oe_o ( )
351 );
352
Timothy Chenc59f7012020-04-16 19:11:42 -0700353 assign rstmgr_cpu.ndmreset_req = ndmreset_req;
354 assign rstmgr_cpu.rst_cpu_n = rstmgr_resets.rst_sys_n;
355
Timothy Chen44461032019-09-20 15:35:20 -0700356 // ROM device
lowRISC Contributors802543a2019-08-31 12:12:56 +0100357 logic rom_req;
Timothy Chenda2e3442020-02-24 21:37:47 -0800358 logic [11:0] rom_addr;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100359 logic [31:0] rom_rdata;
360 logic rom_rvalid;
361
362 tlul_adapter_sram #(
Timothy Chenda2e3442020-02-24 21:37:47 -0800363 .SramAw(12),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100364 .SramDw(32),
Eunchan Kim6c731a82020-03-04 14:48:52 -0800365 .Outstanding(2),
Timothy Chen44461032019-09-20 15:35:20 -0700366 .ErrOnWrite(1)
Michael Schaffnera39557e2020-03-17 18:30:21 -0700367 ) u_tl_adapter_rom (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700368 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700369 .rst_ni (rstmgr_resets.rst_sys_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100370
371 .tl_i (tl_rom_d_h2d),
372 .tl_o (tl_rom_d_d2h),
373
374 .req_o (rom_req),
375 .gnt_i (1'b1), // Always grant as only one requester exists
Timothy Chen44461032019-09-20 15:35:20 -0700376 .we_o (),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100377 .addr_o (rom_addr),
Timothy Chen44461032019-09-20 15:35:20 -0700378 .wdata_o (),
379 .wmask_o (),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100380 .rdata_i (rom_rdata),
381 .rvalid_i (rom_rvalid),
382 .rerror_i (2'b00)
383 );
384
Michael Schaffner0beb8a42020-06-05 23:17:40 -0700385 prim_rom_adv #(
lowRISC Contributors802543a2019-08-31 12:12:56 +0100386 .Width(32),
Philipp Wagnera37bcfa2020-05-19 22:46:41 +0100387 .Depth(4096),
388 .MemInitFile(BootRomInitFile)
Timothy Chen44461032019-09-20 15:35:20 -0700389 ) u_rom_rom (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700390 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700391 .rst_ni (rstmgr_resets.rst_sys_n),
Michael Schaffner0beb8a42020-06-05 23:17:40 -0700392 .req_i (rom_req),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100393 .addr_i (rom_addr),
Michael Schaffner0beb8a42020-06-05 23:17:40 -0700394 .rdata_o (rom_rdata),
395 .rvalid_o (rom_rvalid),
396 .cfg_i ('0) // tied off for now
lowRISC Contributors802543a2019-08-31 12:12:56 +0100397 );
Timothy Chen44461032019-09-20 15:35:20 -0700398
lowRISC Contributors802543a2019-08-31 12:12:56 +0100399 // sram device
400 logic ram_main_req;
401 logic ram_main_we;
402 logic [13:0] ram_main_addr;
403 logic [31:0] ram_main_wdata;
404 logic [31:0] ram_main_wmask;
405 logic [31:0] ram_main_rdata;
406 logic ram_main_rvalid;
Philipp Wagnere1efc182020-05-21 18:26:17 +0100407 logic [1:0] ram_main_rerror;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100408
409 tlul_adapter_sram #(
410 .SramAw(14),
411 .SramDw(32),
Eunchan Kim6c731a82020-03-04 14:48:52 -0800412 .Outstanding(2)
Michael Schaffnera39557e2020-03-17 18:30:21 -0700413 ) u_tl_adapter_ram_main (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700414 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700415 .rst_ni (rstmgr_resets.rst_sys_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100416 .tl_i (tl_ram_main_d_h2d),
417 .tl_o (tl_ram_main_d_d2h),
418
419 .req_o (ram_main_req),
420 .gnt_i (1'b1), // Always grant as only one requester exists
421 .we_o (ram_main_we),
422 .addr_o (ram_main_addr),
423 .wdata_o (ram_main_wdata),
424 .wmask_o (ram_main_wmask),
425 .rdata_i (ram_main_rdata),
426 .rvalid_i (ram_main_rvalid),
Philipp Wagnere1efc182020-05-21 18:26:17 +0100427 .rerror_i (ram_main_rerror)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100428 );
429
Philipp Wagnere1efc182020-05-21 18:26:17 +0100430 prim_ram_1p_adv #(
lowRISC Contributors802543a2019-08-31 12:12:56 +0100431 .Width(32),
432 .Depth(16384),
Philipp Wagnere1efc182020-05-21 18:26:17 +0100433 .DataBitsPerMask(8),
Michael Schaffner25d73cf2020-06-10 22:31:40 -0700434 .CfgW(8),
435 // TODO: enable parity once supported by the simulation infrastructure
436 .EnableParity(0)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100437 ) u_ram1p_ram_main (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700438 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700439 .rst_ni (rstmgr_resets.rst_sys_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100440
441 .req_i (ram_main_req),
442 .write_i (ram_main_we),
443 .addr_i (ram_main_addr),
444 .wdata_i (ram_main_wdata),
445 .wmask_i (ram_main_wmask),
Philipp Wagnere1efc182020-05-21 18:26:17 +0100446 .rdata_o (ram_main_rdata),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100447 .rvalid_o (ram_main_rvalid),
Philipp Wagnere1efc182020-05-21 18:26:17 +0100448 .rerror_o (ram_main_rerror),
449 .cfg_i ('0)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100450 );
Timothy Chen6e2ba842020-06-29 15:04:13 -0700451 // sram device
452 logic ram_ret_req;
453 logic ram_ret_we;
454 logic [9:0] ram_ret_addr;
455 logic [31:0] ram_ret_wdata;
456 logic [31:0] ram_ret_wmask;
457 logic [31:0] ram_ret_rdata;
458 logic ram_ret_rvalid;
459 logic [1:0] ram_ret_rerror;
460
461 tlul_adapter_sram #(
462 .SramAw(10),
463 .SramDw(32),
464 .Outstanding(2)
465 ) u_tl_adapter_ram_ret (
466 .clk_i (clkmgr_clocks.clk_io_infra),
467 .rst_ni (rstmgr_resets.rst_sys_io_n),
468 .tl_i (tl_ram_ret_d_h2d),
469 .tl_o (tl_ram_ret_d_d2h),
470
471 .req_o (ram_ret_req),
472 .gnt_i (1'b1), // Always grant as only one requester exists
473 .we_o (ram_ret_we),
474 .addr_o (ram_ret_addr),
475 .wdata_o (ram_ret_wdata),
476 .wmask_o (ram_ret_wmask),
477 .rdata_i (ram_ret_rdata),
478 .rvalid_i (ram_ret_rvalid),
479 .rerror_i (ram_ret_rerror)
480 );
481
482 prim_ram_1p_adv #(
483 .Width(32),
484 .Depth(1024),
485 .DataBitsPerMask(8),
486 .CfgW(8),
487 // TODO: enable parity once supported by the simulation infrastructure
488 .EnableParity(0)
489 ) u_ram1p_ram_ret (
490 .clk_i (clkmgr_clocks.clk_io_infra),
491 .rst_ni (rstmgr_resets.rst_sys_io_n),
492
493 .req_i (ram_ret_req),
494 .write_i (ram_ret_we),
495 .addr_i (ram_ret_addr),
496 .wdata_i (ram_ret_wdata),
497 .wmask_i (ram_ret_wmask),
498 .rdata_o (ram_ret_rdata),
499 .rvalid_o (ram_ret_rvalid),
500 .rerror_o (ram_ret_rerror),
501 .cfg_i ('0)
502 );
lowRISC Contributors802543a2019-08-31 12:12:56 +0100503
lowRISC Contributors802543a2019-08-31 12:12:56 +0100504 // host to flash communication
505 logic flash_host_req;
506 logic flash_host_req_rdy;
507 logic flash_host_req_done;
Timothy Chen14518402020-04-13 15:25:22 -0700508 logic [flash_ctrl_pkg::BusWidth-1:0] flash_host_rdata;
Timothy Chenb35a3402020-06-23 00:14:11 -0700509 logic [flash_ctrl_pkg::BusAddrW-1:0] flash_host_addr;
lowRISC Contributors802543a2019-08-31 12:12:56 +0100510
Timothy Chen5aec5282019-09-10 21:10:56 -0700511 tlul_adapter_sram #(
Timothy Chenb35a3402020-06-23 00:14:11 -0700512 .SramAw(flash_ctrl_pkg::BusAddrW),
Timothy Chen14518402020-04-13 15:25:22 -0700513 .SramDw(flash_ctrl_pkg::BusWidth),
Eunchan Kim6c731a82020-03-04 14:48:52 -0800514 .Outstanding(2),
Timothy Chen5aec5282019-09-10 21:10:56 -0700515 .ByteAccess(0),
516 .ErrOnWrite(1)
Michael Schaffnera39557e2020-03-17 18:30:21 -0700517 ) u_tl_adapter_eflash (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700518 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700519 .rst_ni (rstmgr_resets.rst_lc_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100520
521 .tl_i (tl_eflash_d_h2d),
522 .tl_o (tl_eflash_d_d2h),
523
Timothy Chen5aec5282019-09-10 21:10:56 -0700524 .req_o (flash_host_req),
525 .gnt_i (flash_host_req_rdy),
526 .we_o (),
527 .addr_o (flash_host_addr),
528 .wdata_o (),
529 .wmask_o (),
530 .rdata_i (flash_host_rdata),
531 .rvalid_i (flash_host_req_done),
532 .rerror_i (2'b00)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100533 );
534
Timothy Chen14518402020-04-13 15:25:22 -0700535 flash_phy u_flash_eflash (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700536 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700537 .rst_ni (rstmgr_resets.rst_lc_n),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100538 .host_req_i (flash_host_req),
539 .host_addr_i (flash_host_addr),
540 .host_req_rdy_o (flash_host_req_rdy),
541 .host_req_done_o (flash_host_req_done),
542 .host_rdata_o (flash_host_rdata),
Eunchan Kim6599ba92020-04-13 15:27:16 -0700543 .flash_ctrl_i (flash_ctrl_flash_req),
544 .flash_ctrl_o (flash_ctrl_flash_rsp)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100545 );
546
547
Michael Schaffner666dde12019-10-25 11:57:54 -0700548
Michael Schaffnera39557e2020-03-17 18:30:21 -0700549 uart u_uart (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100550 .tl_i (tl_uart_d_h2d),
551 .tl_o (tl_uart_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700552
553 // Input
554 .cio_rx_i (cio_uart_rx_p2d),
555
556 // Output
557 .cio_tx_o (cio_uart_tx_d2p),
558 .cio_tx_en_o (cio_uart_tx_en_d2p),
559
560 // Interrupt
561 .intr_tx_watermark_o (intr_uart_tx_watermark),
562 .intr_rx_watermark_o (intr_uart_rx_watermark),
Timothy Chen087d4f42019-12-27 16:04:46 -0800563 .intr_tx_empty_o (intr_uart_tx_empty),
Eunchan Kim769065e2019-10-29 17:29:26 -0700564 .intr_rx_overflow_o (intr_uart_rx_overflow),
565 .intr_rx_frame_err_o (intr_uart_rx_frame_err),
566 .intr_rx_break_err_o (intr_uart_rx_break_err),
567 .intr_rx_timeout_o (intr_uart_rx_timeout),
lowRISC Contributors802543a2019-08-31 12:12:56 +0100568 .intr_rx_parity_err_o (intr_uart_rx_parity_err),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700569 .clk_i (clkmgr_clocks.clk_io_secure),
570 .rst_ni (rstmgr_resets.rst_sys_io_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100571 );
572
Michael Schaffnera39557e2020-03-17 18:30:21 -0700573 gpio u_gpio (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100574 .tl_i (tl_gpio_d_h2d),
575 .tl_o (tl_gpio_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700576
577 // Input
578 .cio_gpio_i (cio_gpio_gpio_p2d),
579
580 // Output
581 .cio_gpio_o (cio_gpio_gpio_d2p),
582 .cio_gpio_en_o (cio_gpio_gpio_en_d2p),
583
584 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100585 .intr_gpio_o (intr_gpio_gpio),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700586 .clk_i (clkmgr_clocks.clk_io_peri),
587 .rst_ni (rstmgr_resets.rst_sys_io_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100588 );
589
Michael Schaffnera39557e2020-03-17 18:30:21 -0700590 spi_device u_spi_device (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100591 .tl_i (tl_spi_device_d_h2d),
592 .tl_o (tl_spi_device_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700593
594 // Input
Timothy Chenc38f7892020-07-16 18:19:48 -0700595 .cio_sck_i (cio_spi_device_sck_p2d),
596 .cio_csb_i (cio_spi_device_csb_p2d),
597 .cio_sdi_i (cio_spi_device_sdi_p2d),
Eunchan Kim769065e2019-10-29 17:29:26 -0700598
599 // Output
Timothy Chenc38f7892020-07-16 18:19:48 -0700600 .cio_sdo_o (cio_spi_device_sdo_d2p),
601 .cio_sdo_en_o (cio_spi_device_sdo_en_d2p),
Eunchan Kim769065e2019-10-29 17:29:26 -0700602
603 // Interrupt
604 .intr_rxf_o (intr_spi_device_rxf),
605 .intr_rxlvl_o (intr_spi_device_rxlvl),
606 .intr_txlvl_o (intr_spi_device_txlvl),
607 .intr_rxerr_o (intr_spi_device_rxerr),
608 .intr_rxoverflow_o (intr_spi_device_rxoverflow),
Eunchan Kim546c0d42019-09-24 15:07:06 -0700609 .intr_txunderflow_o (intr_spi_device_txunderflow),
Eunchan Kim2cfadab2019-10-02 12:41:11 -0700610 .scanmode_i (scanmode_i),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700611 .clk_i (clkmgr_clocks.clk_io_peri),
Timothy Chenc59f7012020-04-16 19:11:42 -0700612 .rst_ni (rstmgr_resets.rst_spi_device_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100613 );
614
Michael Schaffnera39557e2020-03-17 18:30:21 -0700615 flash_ctrl u_flash_ctrl (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100616 .tl_i (tl_flash_ctrl_d_h2d),
617 .tl_o (tl_flash_ctrl_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700618
619 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100620 .intr_prog_empty_o (intr_flash_ctrl_prog_empty),
Eunchan Kim769065e2019-10-29 17:29:26 -0700621 .intr_prog_lvl_o (intr_flash_ctrl_prog_lvl),
622 .intr_rd_full_o (intr_flash_ctrl_rd_full),
623 .intr_rd_lvl_o (intr_flash_ctrl_rd_lvl),
624 .intr_op_done_o (intr_flash_ctrl_op_done),
625 .intr_op_error_o (intr_flash_ctrl_op_error),
626
Eunchan Kime4a85072020-02-05 16:00:00 -0800627 // Inter-module signals
Eunchan Kim6599ba92020-04-13 15:27:16 -0700628 .flash_o(flash_ctrl_flash_req),
629 .flash_i(flash_ctrl_flash_rsp),
Timothy Chenac620652020-06-25 13:48:50 -0700630 .otp_i(flash_ctrl_pkg::OTP_FLASH_DEFAULT),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700631 .clk_i (clkmgr_clocks.clk_main_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700632 .rst_ni (rstmgr_resets.rst_lc_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100633 );
634
Michael Schaffnera39557e2020-03-17 18:30:21 -0700635 rv_timer u_rv_timer (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100636 .tl_i (tl_rv_timer_d_h2d),
637 .tl_o (tl_rv_timer_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700638
639 // Interrupt
lowRISC Contributors802543a2019-08-31 12:12:56 +0100640 .intr_timer_expired_0_0_o (intr_rv_timer_timer_expired_0_0),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700641 .clk_i (clkmgr_clocks.clk_io_timers),
642 .rst_ni (rstmgr_resets.rst_sys_io_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100643 );
644
Michael Schaffnera39557e2020-03-17 18:30:21 -0700645 aes u_aes (
Pirmin Vogeld4534382019-10-17 13:18:31 +0100646 .tl_i (tl_aes_d_h2d),
647 .tl_o (tl_aes_d_d2h),
Pirmin Vogela2d411d2020-07-13 17:33:42 +0200648
Pirmin Vogelbe4bcb72020-04-17 14:43:45 +0200649 // [0]: ctrl_err
650 .alert_tx_o ( alert_tx[0:0] ),
651 .alert_rx_i ( alert_rx[0:0] ),
652
Pirmin Vogela2d411d2020-07-13 17:33:42 +0200653 // Inter-module signals
654 .idle_o(aes_idle),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700655 .clk_i (clkmgr_clocks.clk_main_aes),
Timothy Chenc59f7012020-04-16 19:11:42 -0700656 .rst_ni (rstmgr_resets.rst_sys_n)
Pirmin Vogeld4534382019-10-17 13:18:31 +0100657 );
658
Michael Schaffnera39557e2020-03-17 18:30:21 -0700659 hmac u_hmac (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100660 .tl_i (tl_hmac_d_h2d),
661 .tl_o (tl_hmac_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700662
663 // Interrupt
Eunchan Kimd9d69aa2020-03-20 10:21:11 -0700664 .intr_hmac_done_o (intr_hmac_hmac_done),
665 .intr_fifo_empty_o (intr_hmac_fifo_empty),
666 .intr_hmac_err_o (intr_hmac_hmac_err),
Michael Schaffnerd4d5d2f2020-04-17 15:45:55 -0700667
Pirmin Vogelbe4bcb72020-04-17 14:43:45 +0200668 // [1]: msg_push_sha_disabled
669 .alert_tx_o ( alert_tx[1:1] ),
670 .alert_rx_i ( alert_rx[1:1] ),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700671 .clk_i (clkmgr_clocks.clk_main_hmac),
Timothy Chenc59f7012020-04-16 19:11:42 -0700672 .rst_ni (rstmgr_resets.rst_sys_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100673 );
674
Michael Schaffnera39557e2020-03-17 18:30:21 -0700675 rv_plic u_rv_plic (
lowRISC Contributors802543a2019-08-31 12:12:56 +0100676 .tl_i (tl_rv_plic_d_h2d),
677 .tl_o (tl_rv_plic_d_d2h),
Eunchan Kim769065e2019-10-29 17:29:26 -0700678
lowRISC Contributors802543a2019-08-31 12:12:56 +0100679 .intr_src_i (intr_vector),
680 .irq_o (irq_plic),
681 .irq_id_o (irq_id),
682 .msip_o (msip),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700683 .clk_i (clkmgr_clocks.clk_main_secure),
Timothy Chenc59f7012020-04-16 19:11:42 -0700684 .rst_ni (rstmgr_resets.rst_sys_n)
lowRISC Contributors802543a2019-08-31 12:12:56 +0100685 );
686
Michael Schaffnera39557e2020-03-17 18:30:21 -0700687 pinmux u_pinmux (
Eunchan Kim769065e2019-10-29 17:29:26 -0700688 .tl_i (tl_pinmux_d_h2d),
689 .tl_o (tl_pinmux_d_d2h),
690
Michael Schaffner920e4cc2020-04-28 22:58:12 -0700691 // Inter-module signals
Michael Schaffner39ef7f52020-07-10 21:58:48 -0700692 .lc_pinmux_strap_i('0),
Michael Schaffner920e4cc2020-04-28 22:58:12 -0700693 .lc_pinmux_strap_o(),
Michael Schaffner39ef7f52020-07-10 21:58:48 -0700694 .dft_strap_test_o(),
695 .io_pok_i({pinmux_pkg::NIOPokSignals{1'b1}}),
696 .sleep_en_i(1'b0),
Timothy Chen4ba25312020-06-17 13:08:57 -0700697 .aon_wkup_req_o(pwrmgr_wakeups),
Eunchan Kim769065e2019-10-29 17:29:26 -0700698
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700699 .periph_to_mio_i (mio_d2p ),
700 .periph_to_mio_oe_i (mio_d2p_en ),
701 .mio_to_periph_o (mio_p2d ),
Michael Schaffner920e4cc2020-04-28 22:58:12 -0700702
703 .mio_out_o,
704 .mio_oe_o,
705 .mio_in_i,
706
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700707 .periph_to_dio_i (dio_d2p ),
708 .periph_to_dio_oe_i (dio_d2p_en ),
709 .dio_to_periph_o (dio_p2d ),
Michael Schaffner920e4cc2020-04-28 22:58:12 -0700710
711 .dio_out_o,
712 .dio_oe_o,
713 .dio_in_i,
Timothy Chenf56c1b52020-04-28 17:00:43 -0700714 .clk_i (clkmgr_clocks.clk_main_secure),
Timothy Chen1faeb3c2020-05-11 22:06:32 -0700715 .clk_aon_i (clkmgr_clocks.clk_io_secure),
Michael Schaffner920e4cc2020-04-28 22:58:12 -0700716 .rst_ni (rstmgr_resets.rst_sys_n),
Timothy Chen1faeb3c2020-05-11 22:06:32 -0700717 .rst_aon_ni (rstmgr_resets.rst_sys_io_n)
Eunchan Kim769065e2019-10-29 17:29:26 -0700718 );
719
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700720 padctrl u_padctrl (
721 .tl_i (tl_padctrl_d_h2d),
722 .tl_o (tl_padctrl_d_d2h),
723
724 .mio_attr_o,
725 .dio_attr_o,
Michael Schaffner79eb65f2020-05-01 19:12:47 -0700726 .clk_i (clkmgr_clocks.clk_main_secure),
727 .rst_ni (rstmgr_resets.rst_sys_n)
728 );
729
Michael Schaffnera39557e2020-03-17 18:30:21 -0700730 alert_handler u_alert_handler (
Michael Schaffner666dde12019-10-25 11:57:54 -0700731 .tl_i (tl_alert_handler_d_h2d),
732 .tl_o (tl_alert_handler_d_d2h),
733
734 // Interrupt
735 .intr_classa_o (intr_alert_handler_classa),
736 .intr_classb_o (intr_alert_handler_classb),
737 .intr_classc_o (intr_alert_handler_classc),
738 .intr_classd_o (intr_alert_handler_classd),
739 // TODO: wire this to hardware debug circuit
740 .crashdump_o ( ),
741 // TODO: wire this to TRNG
742 .entropy_i ( 1'b0 ),
743 // alert signals
744 .alert_rx_o ( alert_rx ),
745 .alert_tx_i ( alert_tx ),
746 // escalation outputs
747 .esc_rx_i ( esc_rx ),
748 .esc_tx_o ( esc_tx ),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700749 .clk_i (clkmgr_clocks.clk_main_secure),
Timothy Chenc59f7012020-04-16 19:11:42 -0700750 .rst_ni (rstmgr_resets.rst_sys_n)
Michael Schaffner666dde12019-10-25 11:57:54 -0700751 );
752
Timothy Chen163050b2020-04-13 23:29:29 -0700753 pwrmgr u_pwrmgr (
754 .tl_i (tl_pwrmgr_d_h2d),
755 .tl_o (tl_pwrmgr_d_d2h),
756
757 // Interrupt
758 .intr_wakeup_o (intr_pwrmgr_wakeup),
759
760 // Inter-module signals
761 .pwr_ast_o(),
762 .pwr_ast_i(pwrmgr_pkg::PWR_AST_RSP_DEFAULT),
Timothy Chenc59f7012020-04-16 19:11:42 -0700763 .pwr_rst_o(pwrmgr_pwr_rst_req),
764 .pwr_rst_i(pwrmgr_pwr_rst_rsp),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700765 .pwr_clk_o(pwrmgr_pwr_clk_req),
766 .pwr_clk_i(pwrmgr_pwr_clk_rsp),
Timothy Chen163050b2020-04-13 23:29:29 -0700767 .pwr_otp_o(),
768 .pwr_otp_i(pwrmgr_pkg::PWR_OTP_RSP_DEFAULT),
769 .pwr_lc_o(),
770 .pwr_lc_i(pwrmgr_pkg::PWR_LC_RSP_DEFAULT),
771 .pwr_flash_i(pwrmgr_pkg::PWR_FLASH_DEFAULT),
Timothy Chenc59f7012020-04-16 19:11:42 -0700772 .pwr_cpu_i(pwrmgr_pwr_cpu),
Timothy Chen4ba25312020-06-17 13:08:57 -0700773 .wakeups_i(pwrmgr_wakeups),
774 .rstreqs_i('0),
Timothy Chen371c94d2020-06-30 17:18:14 -0700775 .clk_i (clkmgr_clocks.clk_io_powerup),
776 .clk_slow_i (clkmgr_clocks.clk_aon_powerup),
Timothy Chenc59f7012020-04-16 19:11:42 -0700777 .rst_ni (rstmgr_resets.rst_por_n),
Timothy Chena4cc10d2020-05-08 16:06:20 -0700778 .rst_slow_ni (rstmgr_resets.rst_por_aon_n)
Timothy Chenc59f7012020-04-16 19:11:42 -0700779 );
780
781 rstmgr u_rstmgr (
782 .tl_i (tl_rstmgr_d_h2d),
783 .tl_o (tl_rstmgr_d_d2h),
784
785 // Inter-module signals
786 .pwr_i(pwrmgr_pwr_rst_req),
787 .pwr_o(pwrmgr_pwr_rst_rsp),
788 .resets_o(rstmgr_resets),
789 .ast_i(rstmgr_pkg::RSTMGR_AST_DEFAULT),
790 .cpu_i(rstmgr_cpu),
791 .peri_i(rstmgr_pkg::RSTMGR_PERI_DEFAULT),
Timothy Chenac3a8c92020-06-29 20:17:07 -0700792 .scanmode_i (scanmode_i),
793 .scan_rst_ni (scan_rst_ni),
Timothy Chen371c94d2020-06-30 17:18:14 -0700794 .clk_i (clkmgr_clocks.clk_io_powerup),
795 .clk_aon_i (clkmgr_clocks.clk_aon_powerup),
796 .clk_main_i (clkmgr_clocks.clk_main_powerup),
797 .clk_io_i (clkmgr_clocks.clk_io_powerup),
798 .clk_usb_i (clkmgr_clocks.clk_usb_powerup),
799 .clk_io_div2_i (clkmgr_clocks.clk_io_div2_powerup),
Timothy Chenc59f7012020-04-16 19:11:42 -0700800 .rst_ni (rst_ni)
Timothy Chen163050b2020-04-13 23:29:29 -0700801 );
802
Timothy Chenf56c1b52020-04-28 17:00:43 -0700803 clkmgr u_clkmgr (
804 .tl_i (tl_clkmgr_d_h2d),
805 .tl_o (tl_clkmgr_d_d2h),
806
807 // Inter-module signals
808 .clocks_o(clkmgr_clocks),
Timothy Chen371c94d2020-06-30 17:18:14 -0700809 .clk_main_i(clkmgr_clk_main),
810 .clk_io_i(clkmgr_clk_io),
811 .clk_usb_i(clkmgr_clk_usb),
812 .clk_aon_i(clkmgr_clk_aon),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700813 .pwr_i(pwrmgr_pwr_clk_req),
814 .pwr_o(pwrmgr_pwr_clk_rsp),
815 .dft_i(clkmgr_pkg::CLK_DFT_DEFAULT),
Pirmin Vogela2d411d2020-07-13 17:33:42 +0200816 .status_i(clkmgr_status),
Timothy Chen371c94d2020-06-30 17:18:14 -0700817 .clk_i (clkmgr_clocks.clk_io_powerup),
Timothy Chena4cc10d2020-05-08 16:06:20 -0700818 .rst_ni (rstmgr_resets.rst_por_io_n),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700819 .rst_main_ni (rstmgr_resets.rst_por_n),
Timothy Chena4cc10d2020-05-08 16:06:20 -0700820 .rst_io_ni (rstmgr_resets.rst_por_io_n),
Timothy Chen371c94d2020-06-30 17:18:14 -0700821 .rst_usb_ni (rstmgr_resets.rst_por_usb_n),
822 .rst_io_div2_ni (rstmgr_resets.rst_por_io_div2_n)
Timothy Chenf56c1b52020-04-28 17:00:43 -0700823 );
824
Michael Schaffnera39557e2020-03-17 18:30:21 -0700825 nmi_gen u_nmi_gen (
Michael Schaffner666dde12019-10-25 11:57:54 -0700826 .tl_i (tl_nmi_gen_d_h2d),
827 .tl_o (tl_nmi_gen_d_d2h),
828
829 // Interrupt
830 .intr_esc0_o (intr_nmi_gen_esc0),
831 .intr_esc1_o (intr_nmi_gen_esc1),
832 .intr_esc2_o (intr_nmi_gen_esc2),
833 .intr_esc3_o (intr_nmi_gen_esc3),
834 // escalation signal inputs
835 .esc_rx_o ( esc_rx ),
836 .esc_tx_i ( esc_tx ),
Timothy Chenf56c1b52020-04-28 17:00:43 -0700837 .clk_i (clkmgr_clocks.clk_main_secure),
Timothy Chenc59f7012020-04-16 19:11:42 -0700838 .rst_ni (rstmgr_resets.rst_sys_n)
Michael Schaffner666dde12019-10-25 11:57:54 -0700839 );
840
Michael Schaffnera39557e2020-03-17 18:30:21 -0700841 usbdev u_usbdev (
Pirmin Vogelea91b302020-01-14 18:53:01 +0000842 .tl_i (tl_usbdev_d_h2d),
843 .tl_o (tl_usbdev_d_d2h),
844
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100845 // Input
846 .cio_sense_i (cio_usbdev_sense_p2d),
847 .cio_d_i (cio_usbdev_d_p2d),
848 .cio_dp_i (cio_usbdev_dp_p2d),
849 .cio_dn_i (cio_usbdev_dn_p2d),
Pirmin Vogelea91b302020-01-14 18:53:01 +0000850
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100851 // Output
852 .cio_se0_o (cio_usbdev_se0_d2p),
853 .cio_se0_en_o (cio_usbdev_se0_en_d2p),
Pirmin Vogelfe6863b2020-05-11 17:30:54 +0200854 .cio_dp_pullup_o (cio_usbdev_dp_pullup_d2p),
855 .cio_dp_pullup_en_o (cio_usbdev_dp_pullup_en_d2p),
856 .cio_dn_pullup_o (cio_usbdev_dn_pullup_d2p),
857 .cio_dn_pullup_en_o (cio_usbdev_dn_pullup_en_d2p),
Pirmin Vogelb054fc02020-03-11 11:23:03 +0100858 .cio_tx_mode_se_o (cio_usbdev_tx_mode_se_d2p),
859 .cio_tx_mode_se_en_o (cio_usbdev_tx_mode_se_en_d2p),
860 .cio_suspend_o (cio_usbdev_suspend_d2p),
861 .cio_suspend_en_o (cio_usbdev_suspend_en_d2p),
862 .cio_d_o (cio_usbdev_d_d2p),
863 .cio_d_en_o (cio_usbdev_d_en_d2p),
864 .cio_dp_o (cio_usbdev_dp_d2p),
865 .cio_dp_en_o (cio_usbdev_dp_en_d2p),
866 .cio_dn_o (cio_usbdev_dn_d2p),
867 .cio_dn_en_o (cio_usbdev_dn_en_d2p),
Pirmin Vogelea91b302020-01-14 18:53:01 +0000868
869 // Interrupt
870 .intr_pkt_received_o (intr_usbdev_pkt_received),
871 .intr_pkt_sent_o (intr_usbdev_pkt_sent),
872 .intr_disconnected_o (intr_usbdev_disconnected),
873 .intr_host_lost_o (intr_usbdev_host_lost),
874 .intr_link_reset_o (intr_usbdev_link_reset),
875 .intr_link_suspend_o (intr_usbdev_link_suspend),
876 .intr_link_resume_o (intr_usbdev_link_resume),
877 .intr_av_empty_o (intr_usbdev_av_empty),
878 .intr_rx_full_o (intr_usbdev_rx_full),
879 .intr_av_overflow_o (intr_usbdev_av_overflow),
880 .intr_link_in_err_o (intr_usbdev_link_in_err),
881 .intr_rx_crc_err_o (intr_usbdev_rx_crc_err),
882 .intr_rx_pid_err_o (intr_usbdev_rx_pid_err),
883 .intr_rx_bitstuff_err_o (intr_usbdev_rx_bitstuff_err),
884 .intr_frame_o (intr_usbdev_frame),
885 .intr_connected_o (intr_usbdev_connected),
886
Pirmin Vogeldd3a2f02020-05-12 14:59:50 +0200887 // Inter-module signals
888 .usb_ref_val_o(),
889 .usb_ref_pulse_o(),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700890 .clk_i (clkmgr_clocks.clk_io_peri),
891 .clk_usb_48mhz_i (clkmgr_clocks.clk_usb_peri),
892 .rst_ni (rstmgr_resets.rst_sys_io_n),
Timothy Chenc59f7012020-04-16 19:11:42 -0700893 .rst_usb_48mhz_ni (rstmgr_resets.rst_usb_n)
Pirmin Vogelea91b302020-01-14 18:53:01 +0000894 );
895
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100896 otbn u_otbn (
897 .tl_i (tl_otbn_d_h2d),
898 .tl_o (tl_otbn_d_d2h),
899
900 // Interrupt
901 .intr_done_o (intr_otbn_done),
902 .intr_err_o (intr_otbn_err),
903
Pirmin Vogelbe4bcb72020-04-17 14:43:45 +0200904 // [2]: imem_uncorrectable
905 // [3]: dmem_uncorrectable
906 // [4]: reg_uncorrectable
907 .alert_tx_o ( alert_tx[4:2] ),
908 .alert_rx_i ( alert_rx[4:2] ),
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100909
910 // Inter-module signals
911 .idle_o(),
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100912 .clk_i (clkmgr_clocks.clk_main_otbn),
913 .rst_ni (rstmgr_resets.rst_sys_n)
914 );
915
lowRISC Contributors802543a2019-08-31 12:12:56 +0100916 // interrupt assignments
917 assign intr_vector = {
Philipp Wagnera4a9e402020-06-22 12:06:56 +0100918 intr_otbn_err,
919 intr_otbn_done,
Timothy Chen163050b2020-04-13 23:29:29 -0700920 intr_pwrmgr_wakeup,
Pirmin Vogelea91b302020-01-14 18:53:01 +0000921 intr_usbdev_connected,
922 intr_usbdev_frame,
923 intr_usbdev_rx_bitstuff_err,
924 intr_usbdev_rx_pid_err,
925 intr_usbdev_rx_crc_err,
926 intr_usbdev_link_in_err,
927 intr_usbdev_av_overflow,
928 intr_usbdev_rx_full,
929 intr_usbdev_av_empty,
930 intr_usbdev_link_resume,
931 intr_usbdev_link_suspend,
932 intr_usbdev_link_reset,
933 intr_usbdev_host_lost,
934 intr_usbdev_disconnected,
935 intr_usbdev_pkt_sent,
936 intr_usbdev_pkt_received,
Michael Schaffner666dde12019-10-25 11:57:54 -0700937 intr_nmi_gen_esc3,
938 intr_nmi_gen_esc2,
939 intr_nmi_gen_esc1,
940 intr_nmi_gen_esc0,
941 intr_alert_handler_classd,
942 intr_alert_handler_classc,
943 intr_alert_handler_classb,
944 intr_alert_handler_classa,
Eunchan Kim226eab62019-10-18 14:11:29 -0700945 intr_hmac_hmac_err,
Eunchan Kimd9d69aa2020-03-20 10:21:11 -0700946 intr_hmac_fifo_empty,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100947 intr_hmac_hmac_done,
948 intr_flash_ctrl_op_error,
949 intr_flash_ctrl_op_done,
950 intr_flash_ctrl_rd_lvl,
951 intr_flash_ctrl_rd_full,
952 intr_flash_ctrl_prog_lvl,
953 intr_flash_ctrl_prog_empty,
Eunchan Kim546c0d42019-09-24 15:07:06 -0700954 intr_spi_device_txunderflow,
955 intr_spi_device_rxoverflow,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100956 intr_spi_device_rxerr,
957 intr_spi_device_txlvl,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100958 intr_spi_device_rxlvl,
Eunchan Kim8c57fe32019-09-02 21:14:24 -0700959 intr_spi_device_rxf,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100960 intr_uart_rx_parity_err,
961 intr_uart_rx_timeout,
962 intr_uart_rx_break_err,
963 intr_uart_rx_frame_err,
964 intr_uart_rx_overflow,
Timothy Chen087d4f42019-12-27 16:04:46 -0800965 intr_uart_tx_empty,
lowRISC Contributors802543a2019-08-31 12:12:56 +0100966 intr_uart_rx_watermark,
967 intr_uart_tx_watermark,
Eunchan Kim88a86152020-04-13 16:12:08 -0700968 intr_gpio_gpio,
969 1'b 0 // For ID 0.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100970 };
971
972 // TL-UL Crossbar
lowRISC Contributors802543a2019-08-31 12:12:56 +0100973 xbar_main u_xbar_main (
Timothy Chenf56c1b52020-04-28 17:00:43 -0700974 .clk_main_i (clkmgr_clocks.clk_main_infra),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700975 .clk_fixed_i (clkmgr_clocks.clk_io_infra),
Timothy Chenc59f7012020-04-16 19:11:42 -0700976 .rst_main_ni (rstmgr_resets.rst_sys_n),
Timothy Chen33b3b9d2020-05-08 10:14:17 -0700977 .rst_fixed_ni (rstmgr_resets.rst_sys_io_n),
Michael Schaffner666dde12019-10-25 11:57:54 -0700978 .tl_corei_i (tl_corei_h_h2d),
979 .tl_corei_o (tl_corei_h_d2h),
980 .tl_cored_i (tl_cored_h_h2d),
981 .tl_cored_o (tl_cored_h_d2h),
982 .tl_dm_sba_i (tl_dm_sba_h_h2d),
983 .tl_dm_sba_o (tl_dm_sba_h_d2h),
984 .tl_rom_o (tl_rom_d_h2d),
985 .tl_rom_i (tl_rom_d_d2h),
986 .tl_debug_mem_o (tl_debug_mem_d_h2d),
987 .tl_debug_mem_i (tl_debug_mem_d_d2h),
988 .tl_ram_main_o (tl_ram_main_d_h2d),
989 .tl_ram_main_i (tl_ram_main_d_d2h),
990 .tl_eflash_o (tl_eflash_d_h2d),
991 .tl_eflash_i (tl_eflash_d_d2h),
Eunchan Kim009f6e92020-06-03 17:56:52 -0700992 .tl_peri_o (tl_main_peri_h2d),
993 .tl_peri_i (tl_main_peri_d2h),
Michael Schaffner666dde12019-10-25 11:57:54 -0700994 .tl_flash_ctrl_o (tl_flash_ctrl_d_h2d),
995 .tl_flash_ctrl_i (tl_flash_ctrl_d_d2h),
Michael Schaffner666dde12019-10-25 11:57:54 -0700996 .tl_hmac_o (tl_hmac_d_h2d),
997 .tl_hmac_i (tl_hmac_d_d2h),
998 .tl_aes_o (tl_aes_d_h2d),
999 .tl_aes_i (tl_aes_d_d2h),
1000 .tl_rv_plic_o (tl_rv_plic_d_h2d),
1001 .tl_rv_plic_i (tl_rv_plic_d_d2h),
1002 .tl_pinmux_o (tl_pinmux_d_h2d),
1003 .tl_pinmux_i (tl_pinmux_d_d2h),
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001004 .tl_padctrl_o (tl_padctrl_d_h2d),
1005 .tl_padctrl_i (tl_padctrl_d_d2h),
Michael Schaffner666dde12019-10-25 11:57:54 -07001006 .tl_alert_handler_o (tl_alert_handler_d_h2d),
1007 .tl_alert_handler_i (tl_alert_handler_d_d2h),
1008 .tl_nmi_gen_o (tl_nmi_gen_d_h2d),
1009 .tl_nmi_gen_i (tl_nmi_gen_d_d2h),
Philipp Wagnera4a9e402020-06-22 12:06:56 +01001010 .tl_otbn_o (tl_otbn_d_h2d),
1011 .tl_otbn_i (tl_otbn_d_d2h),
lowRISC Contributors802543a2019-08-31 12:12:56 +01001012
1013 .scanmode_i
1014 );
Eunchan Kim55d7ae82019-12-19 17:08:35 -08001015 xbar_peri u_xbar_peri (
Timothy Chen33b3b9d2020-05-08 10:14:17 -07001016 .clk_peri_i (clkmgr_clocks.clk_io_infra),
1017 .rst_peri_ni (rstmgr_resets.rst_sys_io_n),
Eunchan Kim009f6e92020-06-03 17:56:52 -07001018 .tl_main_i (tl_main_peri_h2d),
1019 .tl_main_o (tl_main_peri_d2h),
Eunchan Kim55d7ae82019-12-19 17:08:35 -08001020 .tl_uart_o (tl_uart_d_h2d),
1021 .tl_uart_i (tl_uart_d_d2h),
1022 .tl_gpio_o (tl_gpio_d_h2d),
1023 .tl_gpio_i (tl_gpio_d_d2h),
1024 .tl_spi_device_o (tl_spi_device_d_h2d),
1025 .tl_spi_device_i (tl_spi_device_d_d2h),
1026 .tl_rv_timer_o (tl_rv_timer_d_h2d),
1027 .tl_rv_timer_i (tl_rv_timer_d_d2h),
Pirmin Vogelea91b302020-01-14 18:53:01 +00001028 .tl_usbdev_o (tl_usbdev_d_h2d),
1029 .tl_usbdev_i (tl_usbdev_d_d2h),
Timothy Chen163050b2020-04-13 23:29:29 -07001030 .tl_pwrmgr_o (tl_pwrmgr_d_h2d),
1031 .tl_pwrmgr_i (tl_pwrmgr_d_d2h),
Timothy Chenc59f7012020-04-16 19:11:42 -07001032 .tl_rstmgr_o (tl_rstmgr_d_h2d),
1033 .tl_rstmgr_i (tl_rstmgr_d_d2h),
Timothy Chenf56c1b52020-04-28 17:00:43 -07001034 .tl_clkmgr_o (tl_clkmgr_d_h2d),
1035 .tl_clkmgr_i (tl_clkmgr_d_d2h),
Timothy Chen6e2ba842020-06-29 15:04:13 -07001036 .tl_ram_ret_o (tl_ram_ret_d_h2d),
1037 .tl_ram_ret_i (tl_ram_ret_d_d2h),
Eunchan Kim55d7ae82019-12-19 17:08:35 -08001038
1039 .scanmode_i
1040 );
lowRISC Contributors802543a2019-08-31 12:12:56 +01001041
Eunchan Kim769065e2019-10-29 17:29:26 -07001042 // Pinmux connections
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001043 assign mio_d2p = {
Eunchan Kim769065e2019-10-29 17:29:26 -07001044 cio_gpio_gpio_d2p
1045 };
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001046 assign mio_d2p_en = {
Eunchan Kim769065e2019-10-29 17:29:26 -07001047 cio_gpio_gpio_en_d2p
1048 };
1049 assign {
1050 cio_gpio_gpio_p2d
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001051 } = mio_p2d;
Eunchan Kim769065e2019-10-29 17:29:26 -07001052
Michael Schaffner920e4cc2020-04-28 22:58:12 -07001053 // Dedicated IO connections
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001054 // Input-only DIOs have no d2p signals
1055 assign dio_d2p = {
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001056 1'b0, // DIO14: cio_spi_device_sck
1057 1'b0, // DIO13: cio_spi_device_csb
Scott Johnsonfe79c4b2020-07-08 10:31:08 -07001058 1'b0, // DIO12: cio_spi_device_sdi
1059 cio_spi_device_sdo_d2p, // DIO11
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001060 1'b0, // DIO10: cio_uart_rx
1061 cio_uart_tx_d2p, // DIO9
1062 1'b0, // DIO8: cio_usbdev_sense
1063 cio_usbdev_se0_d2p, // DIO7
1064 cio_usbdev_dp_pullup_d2p, // DIO6
1065 cio_usbdev_dn_pullup_d2p, // DIO5
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001066 cio_usbdev_tx_mode_se_d2p, // DIO4
1067 cio_usbdev_suspend_d2p, // DIO3
1068 cio_usbdev_d_d2p, // DIO2
1069 cio_usbdev_dp_d2p, // DIO1
1070 cio_usbdev_dn_d2p // DIO0
Michael Schaffner920e4cc2020-04-28 22:58:12 -07001071 };
1072
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001073 assign dio_d2p_en = {
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001074 1'b0, // DIO14: cio_spi_device_sck
1075 1'b0, // DIO13: cio_spi_device_csb
Scott Johnsonfe79c4b2020-07-08 10:31:08 -07001076 1'b0, // DIO12: cio_spi_device_sdi
1077 cio_spi_device_sdo_en_d2p, // DIO11
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001078 1'b0, // DIO10: cio_uart_rx
1079 cio_uart_tx_en_d2p, // DIO9
1080 1'b0, // DIO8: cio_usbdev_sense
1081 cio_usbdev_se0_en_d2p, // DIO7
1082 cio_usbdev_dp_pullup_en_d2p, // DIO6
1083 cio_usbdev_dn_pullup_en_d2p, // DIO5
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001084 cio_usbdev_tx_mode_se_en_d2p, // DIO4
1085 cio_usbdev_suspend_en_d2p, // DIO3
1086 cio_usbdev_d_en_d2p, // DIO2
1087 cio_usbdev_dp_en_d2p, // DIO1
1088 cio_usbdev_dn_en_d2p // DIO0
Michael Schaffner920e4cc2020-04-28 22:58:12 -07001089 };
1090
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001091 // Output-only DIOs have no p2d signal
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001092 assign cio_spi_device_sck_p2d = dio_p2d[14]; // DIO14
1093 assign cio_spi_device_csb_p2d = dio_p2d[13]; // DIO13
Scott Johnsonfe79c4b2020-07-08 10:31:08 -07001094 assign cio_spi_device_sdi_p2d = dio_p2d[12]; // DIO12
1095 // DIO11: cio_spi_device_sdo
Pirmin Vogelfe6863b2020-05-11 17:30:54 +02001096 assign cio_uart_rx_p2d = dio_p2d[10]; // DIO10
1097 // DIO9: cio_uart_tx
1098 assign cio_usbdev_sense_p2d = dio_p2d[8]; // DIO8
1099 // DIO7: cio_usbdev_se0
1100 // DIO6: cio_usbdev_dp_pullup
1101 // DIO5: cio_usbdev_dn_pullup
Michael Schaffner79eb65f2020-05-01 19:12:47 -07001102 // DIO4: cio_usbdev_tx_mode_se
1103 // DIO3: cio_usbdev_suspend
1104 assign cio_usbdev_d_p2d = dio_p2d[2]; // DIO2
1105 assign cio_usbdev_dp_p2d = dio_p2d[1]; // DIO1
1106 assign cio_usbdev_dn_p2d = dio_p2d[0]; // DIO0
Eunchan Kim769065e2019-10-29 17:29:26 -07001107
Nils Graf78607aa2019-09-16 15:47:23 -07001108 // make sure scanmode_i is never X (including during reset)
Timothy Chen371c94d2020-06-30 17:18:14 -07001109 `ASSERT_KNOWN(scanmodeKnown, scanmode_i, clkmgr_clk_main, 0)
Nils Graf78607aa2019-09-16 15:47:23 -07001110
lowRISC Contributors802543a2019-08-31 12:12:56 +01001111endmodule