shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 1 | /* |
| 2 | * PicoSoC - A simple example SoC using PicoRV32 |
| 3 | * |
| 4 | * Copyright (C) 2017 Clifford Wolf <clifford@clifford.at> |
| 5 | * |
| 6 | * Permission to use, copy, modify, and/or distribute this software for any |
| 7 | * purpose with or without fee is hereby granted, provided that the above |
| 8 | * copyright notice and this permission notice appear in all copies. |
| 9 | * |
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 | * |
| 18 | * Revision 1, July 2019: Added signals to drive flash_clk and flash_csb |
| 19 | * output enable (inverted), tied to reset so that the flash is completely |
| 20 | * isolated from the processor when the processor is in reset. |
| 21 | * |
| 22 | * Also: Made ram_wenb a 4-bit bus so that the memory access can be made |
| 23 | * byte-wide for byte-wide instructions. |
| 24 | */ |
| 25 | |
| 26 | `ifdef PICORV32_V |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 27 | `error "mgmt_soc.v must be read before picorv32.v!" |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 28 | `endif |
| 29 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 30 | `define PICORV32_REGS mgmt_soc_regs |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 31 | |
| 32 | `include "picorv32.v" |
| 33 | `include "spimemio.v" |
| 34 | `include "simpleuart.v" |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 35 | `include "simple_spi_master.v" |
| 36 | `include "counter_timer.v" |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 37 | `include "wb_intercon.v" |
| 38 | `include "mem_wb.v" |
| 39 | `include "gpio_wb.v" |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 40 | `include "sysctrl.v" |
| 41 | `include "la_wb.v" |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 42 | `include "mprj_ctrl.v" |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 43 | `include "convert_gpio_sigs.v" |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 44 | |
Tim Edwards | 9eda80d | 2020-10-08 21:36:44 -0400 | [diff] [blame] | 45 | module mgmt_soc #( |
| 46 | parameter MPRJ_IO_PADS = 32, |
| 47 | parameter MPRJ_PWR_PADS = 32 |
| 48 | ) ( |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 49 | `ifdef LVS |
| 50 | inout vdd1v8, /* 1.8V domain */ |
| 51 | inout vss, |
| 52 | `endif |
| 53 | input pll_clk, |
| 54 | input ext_clk, |
| 55 | input ext_clk_sel, |
| 56 | |
| 57 | input clk, |
| 58 | input resetn, |
| 59 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 60 | // Trap state from CPU |
| 61 | output trap, |
| 62 | |
| 63 | // GPIO (one pin) |
| 64 | output gpio_out_pad, // Connect to out on gpio pad |
| 65 | input gpio_in_pad, // Connect to in on gpio pad |
| 66 | output gpio_mode0_pad, // Connect to dm[0] on gpio pad |
| 67 | output gpio_mode1_pad, // Connect to dm[2] on gpio pad |
| 68 | output gpio_outenb_pad, // Connect to oe_n on gpio pad |
| 69 | output gpio_inenb_pad, // Connect to inp_dis on gpio pad |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 70 | |
| 71 | // LA signals |
| 72 | input [127:0] la_input, // From Mega-Project to cpu |
| 73 | output [127:0] la_output, // From CPU to Mega-Project |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 74 | output [127:0] la_oen, // LA output enable (active low) |
| 75 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 76 | // Mega-Project I/O Configuration (serial load) |
| 77 | output mprj_io_loader_resetn, |
| 78 | output mprj_io_loader_clock, |
| 79 | output mprj_io_loader_data, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 80 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 81 | // Mega-Project pad data (when management SoC controls the pad) |
Tim Edwards | 44bab47 | 2020-10-04 22:09:54 -0400 | [diff] [blame] | 82 | input [MPRJ_IO_PADS-1:0] mgmt_in_data, |
| 83 | output [MPRJ_IO_PADS-1:0] mgmt_out_data, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 84 | |
| 85 | // IRQ |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 86 | input irq_spi, // IRQ from standalone SPI |
| 87 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 88 | // Flash memory control (SPI master) |
| 89 | output flash_csb, |
| 90 | output flash_clk, |
| 91 | |
| 92 | output flash_csb_oeb, |
| 93 | output flash_clk_oeb, |
| 94 | |
| 95 | output flash_io0_oeb, |
| 96 | output flash_io1_oeb, |
| 97 | output flash_io2_oeb, |
| 98 | output flash_io3_oeb, |
| 99 | |
| 100 | output flash_csb_ieb, |
| 101 | output flash_clk_ieb, |
| 102 | |
| 103 | output flash_io0_ieb, |
| 104 | output flash_io1_ieb, |
| 105 | output flash_io2_ieb, |
| 106 | output flash_io3_ieb, |
| 107 | |
| 108 | output flash_io0_do, |
| 109 | output flash_io1_do, |
| 110 | output flash_io2_do, |
| 111 | output flash_io3_do, |
| 112 | |
| 113 | input flash_io0_di, |
| 114 | input flash_io1_di, |
| 115 | input flash_io2_di, |
| 116 | input flash_io3_di, |
| 117 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 118 | // SPI pass-thru mode |
| 119 | input pass_thru_mgmt, |
| 120 | input pass_thru_mgmt_csb, |
| 121 | input pass_thru_mgmt_sck, |
| 122 | input pass_thru_mgmt_sdi, |
| 123 | output pass_thru_mgmt_sdo, |
| 124 | |
Tim Edwards | 8115320 | 2020-10-09 19:57:04 -0400 | [diff] [blame] | 125 | // SPI master->slave direct link |
| 126 | output hk_connect, |
| 127 | |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 128 | // WB MI A (Mega project) |
| 129 | input mprj_ack_i, |
Tim Edwards | ef8312e | 2020-09-22 17:20:06 -0400 | [diff] [blame] | 130 | input [31:0] mprj_dat_i, |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 131 | output mprj_cyc_o, |
Tim Edwards | ef8312e | 2020-09-22 17:20:06 -0400 | [diff] [blame] | 132 | output mprj_stb_o, |
| 133 | output mprj_we_o, |
| 134 | output [3:0] mprj_sel_o, |
| 135 | output [31:0] mprj_adr_o, |
| 136 | output [31:0] mprj_dat_o, |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 137 | |
| 138 | // WB MI B (xbar) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 139 | input [31:0] xbar_dat_i, |
| 140 | input xbar_ack_i, |
| 141 | output xbar_cyc_o, |
| 142 | output xbar_stb_o, |
| 143 | output xbar_we_o, |
| 144 | output [3:0] xbar_sel_o, |
| 145 | output [31:0] xbar_adr_o, |
| 146 | output [31:0] xbar_dat_o |
| 147 | ); |
| 148 | /* Memory reverted back to 256 words while memory has to be synthesized */ |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 149 | parameter integer MEM_WORDS = 8192; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 150 | parameter [31:0] STACKADDR = (4*MEM_WORDS); // end of memory |
| 151 | parameter [31:0] PROGADDR_RESET = 32'h 1000_0000; |
| 152 | parameter [31:0] PROGADDR_IRQ = 32'h 0000_0000; |
| 153 | |
| 154 | // Slaves Base Addresses |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 155 | parameter RAM_BASE_ADR = 32'h 0000_0000; |
| 156 | parameter FLASH_BASE_ADR = 32'h 1000_0000; |
| 157 | parameter UART_BASE_ADR = 32'h 2000_0000; |
| 158 | parameter GPIO_BASE_ADR = 32'h 2100_0000; |
Tim Edwards | 856b092 | 2020-10-09 16:30:22 -0400 | [diff] [blame] | 159 | parameter COUNTER_TIMER0_BASE_ADR = 32'h 2200_0000; |
| 160 | parameter COUNTER_TIMER1_BASE_ADR = 32'h 2300_0000; |
| 161 | parameter SPI_MASTER_BASE_ADR = 32'h 2400_0000; |
| 162 | parameter LA_BASE_ADR = 32'h 2500_0000; |
| 163 | parameter MPRJ_CTRL_ADR = 32'h 2600_0000; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 164 | parameter FLASH_CTRL_CFG = 32'h 2D00_0000; |
Tim Edwards | 856b092 | 2020-10-09 16:30:22 -0400 | [diff] [blame] | 165 | parameter SYS_BASE_ADR = 32'h 2F00_0000; |
| 166 | parameter MPRJ_BASE_ADR = 32'h 3000_0000; // WB MI A |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 167 | parameter XBAR_BASE_ADR = 32'h 8000_0000; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 168 | |
| 169 | // UART |
| 170 | parameter UART_CLK_DIV = 8'h00; |
| 171 | parameter UART_DATA = 8'h04; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 172 | |
| 173 | // SPI Master |
| 174 | parameter SPI_MASTER_CONFIG = 8'h00; |
| 175 | parameter SPI_MASTER_DATA = 8'h04; |
| 176 | |
| 177 | // Counter-timer 0 |
| 178 | parameter COUNTER_TIMER0_CONFIG = 8'h00; |
| 179 | parameter COUNTER_TIMER0_VALUE = 8'h04; |
| 180 | parameter COUNTER_TIMER0_DATA = 8'h08; |
| 181 | |
| 182 | // Counter-timer 1 |
| 183 | parameter COUNTER_TIMER1_CONFIG = 8'h00; |
| 184 | parameter COUNTER_TIMER1_VALUE = 8'h04; |
| 185 | parameter COUNTER_TIMER1_DATA = 8'h08; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 186 | |
| 187 | // SOC GPIO |
| 188 | parameter GPIO_DATA = 8'h00; |
| 189 | parameter GPIO_ENA = 8'h04; |
| 190 | parameter GPIO_PU = 8'h08; |
| 191 | parameter GPIO_PD = 8'h0c; |
| 192 | |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 193 | // LA |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 194 | parameter LA_DATA_0 = 8'h00; |
| 195 | parameter LA_DATA_1 = 8'h04; |
| 196 | parameter LA_DATA_2 = 8'h08; |
| 197 | parameter LA_DATA_3 = 8'h0c; |
| 198 | parameter LA_ENA_0 = 8'h10; |
| 199 | parameter LA_ENA_1 = 8'h14; |
| 200 | parameter LA_ENA_2 = 8'h18; |
| 201 | parameter LA_ENA_3 = 8'h1c; |
| 202 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 203 | // System Control Registers |
Tim Edwards | 44bab47 | 2020-10-04 22:09:54 -0400 | [diff] [blame] | 204 | parameter PLL_OUT = 8'h00; |
| 205 | parameter TRAP_OUT = 8'h04; |
| 206 | parameter IRQ7_SRC = 8'h08; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 207 | |
| 208 | // Wishbone Interconnect |
| 209 | localparam ADR_WIDTH = 32; |
| 210 | localparam DAT_WIDTH = 32; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 211 | localparam NUM_SLAVES = 13; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 212 | |
| 213 | parameter [NUM_SLAVES*ADR_WIDTH-1: 0] ADR_MASK = { |
| 214 | {8'h80, {ADR_WIDTH-8{1'b0}}}, |
| 215 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 216 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 217 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 218 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 219 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 220 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 221 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 222 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 223 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 224 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
| 225 | {8'hFF, {ADR_WIDTH-8{1'b0}}}, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 226 | {8'hFF, {ADR_WIDTH-8{1'b0}}} |
| 227 | }; |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 228 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 229 | parameter [NUM_SLAVES*ADR_WIDTH-1: 0] SLAVE_ADR = { |
| 230 | {XBAR_BASE_ADR}, |
| 231 | {SYS_BASE_ADR}, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 232 | {FLASH_CTRL_CFG}, |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 233 | {MPRJ_BASE_ADR}, |
| 234 | {MPRJ_CTRL_ADR}, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 235 | {LA_BASE_ADR}, |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 236 | {SPI_MASTER_BASE_ADR}, |
| 237 | {COUNTER_TIMER1_BASE_ADR}, |
| 238 | {COUNTER_TIMER0_BASE_ADR}, |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 239 | {GPIO_BASE_ADR}, |
| 240 | {UART_BASE_ADR}, |
| 241 | {FLASH_BASE_ADR}, |
| 242 | {RAM_BASE_ADR} |
| 243 | }; |
| 244 | |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 245 | // The following functions are connected to specific user project |
| 246 | // area pins, when under control of the management area (during |
| 247 | // startup, and when not otherwise programmed for the user project). |
| 248 | |
| 249 | // JTAG = jtag_out (inout) |
| 250 | // SDO = sdo_out (output) (shared with SPI master) |
| 251 | // SDI = mgmt_in_data[2] (input) (shared with SPI master) |
| 252 | // CSB = mgmt_in_data[3] (input) (shared with SPI master) |
| 253 | // SCK = mgmt_in_data[4] (input) (shared with SPI master) |
| 254 | // ser_rx = mgmt_in_data[5] (input) |
| 255 | // ser_tx = mgmt_out_data[6] (output) |
| 256 | // irq_pin = mgmt_in_data[7] (input) |
| 257 | // flash_csb = mgmt_out_data[8] (output) (user area flash) |
| 258 | // flash_sck = mgmt_out_data[9] (output) (user area flash) |
| 259 | // flash_io0 = mgmt_in/out_data[10] (input) (user area flash) |
| 260 | // flash_io1 = mgmt_in/out_data[11] (output) (user area flash) |
| 261 | |
| 262 | // OEB lines for [0] and [1] are the only ones connected directly to |
| 263 | // the pad. All others have OEB controlled by the configuration bit |
| 264 | // in the control block. |
| 265 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 266 | // memory-mapped I/O control registers |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 267 | wire gpio_pullup; // Intermediate GPIO pullup |
| 268 | wire gpio_pulldown; // Intermediate GPIO pulldown |
| 269 | wire gpio_outenb; // Intermediate GPIO out enable (bar) |
| 270 | wire gpio_out; // Intermediate GPIO output |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 271 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 272 | wire gpio; // GPIO output data |
| 273 | wire gpio_pu; // GPIO pull-up enable |
| 274 | wire gpio_pd; // GPIO pull-down enable |
| 275 | wire gpio_oeb; // GPIO output enable (sense negative) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 276 | |
Tim Edwards | ef8312e | 2020-09-22 17:20:06 -0400 | [diff] [blame] | 277 | wire pll_output_dest; // PLL clock output destination |
| 278 | wire trap_output_dest; // Trap signal output destination |
| 279 | wire irq_7_inputsrc; // IRQ 7 source |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 280 | |
| 281 | // GPIO assignments |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 282 | assign gpio_out = (trap_output_dest == 1'b1) ? trap : gpio; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 283 | assign gpio_outenb = (trap_output_dest == 1'b0) ? gpio_oeb : 1'b0; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 284 | assign gpio_pullup = (trap_output_dest == 1'b0) ? gpio_pu : 1'b0; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 285 | assign gpio_pulldown = (trap_output_dest == 1'b0) ? gpio_pd : 1'b0; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 286 | |
Tim Edwards | ef8312e | 2020-09-22 17:20:06 -0400 | [diff] [blame] | 287 | // Convert GPIO signals to sky130_fd_io pad signals |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 288 | convert_gpio_sigs convert_gpio_bit ( |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 289 | .gpio_out(gpio_out), |
| 290 | .gpio_outenb(gpio_outenb), |
| 291 | .gpio_pu(gpio_pullup), |
| 292 | .gpio_pd(gpio_pulldown), |
| 293 | .gpio_out_pad(gpio_out_pad), |
| 294 | .gpio_outenb_pad(gpio_outenb_pad), |
| 295 | .gpio_inenb_pad(gpio_inenb_pad), |
| 296 | .gpio_mode1_pad(gpio_mode1_pad), |
| 297 | .gpio_mode0_pad(gpio_mode0_pad) |
| 298 | ); |
| 299 | |
| 300 | reg [31:0] irq; |
| 301 | wire irq_7; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 302 | wire irq_stall; |
| 303 | wire irq_uart; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 304 | wire irq_spi_master; |
| 305 | wire irq_counter_timer0; |
| 306 | wire irq_counter_timer1; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 307 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 308 | assign irq_stall = 0; |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 309 | assign irq_7 = (irq_7_inputsrc == 1'b1) ? mgmt_in_data[7] : 1'b0; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 310 | |
| 311 | always @* begin |
| 312 | irq = 0; |
| 313 | irq[3] = irq_stall; |
| 314 | irq[4] = irq_uart; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 315 | irq[6] = irq_spi; |
| 316 | irq[7] = irq_7; |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 317 | irq[9] = irq_spi_master; |
| 318 | irq[10] = irq_counter_timer0; |
| 319 | irq[11] = irq_counter_timer1; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 320 | end |
| 321 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 322 | // Assumption : no syscon module and wb_clk is the clock coming from the chip pin ? |
| 323 | assign wb_clk_i = clk; |
| 324 | assign wb_rst_i = ~resetn; // Redundant |
| 325 | |
| 326 | // Wishbone Master |
| 327 | wire [31:0] cpu_adr_o; |
| 328 | wire [31:0] cpu_dat_i; |
| 329 | wire [3:0] cpu_sel_o; |
| 330 | wire cpu_we_o; |
| 331 | wire cpu_cyc_o; |
| 332 | wire cpu_stb_o; |
| 333 | wire [31:0] cpu_dat_o; |
| 334 | wire cpu_ack_i; |
| 335 | |
| 336 | assign xbar_cyc_o = cpu_cyc_o; |
| 337 | assign xbar_we_o = cpu_we_o; |
| 338 | assign xbar_sel_o = cpu_sel_o; |
| 339 | assign xbar_adr_o = cpu_adr_o; |
| 340 | assign xbar_dat_o = cpu_dat_o; |
| 341 | |
| 342 | picorv32_wb #( |
| 343 | .STACKADDR(STACKADDR), |
| 344 | .PROGADDR_RESET(PROGADDR_RESET), |
| 345 | .PROGADDR_IRQ(PROGADDR_IRQ), |
| 346 | .BARREL_SHIFTER(1), |
| 347 | .COMPRESSED_ISA(1), |
| 348 | .ENABLE_MUL(1), |
| 349 | .ENABLE_DIV(1), |
| 350 | .ENABLE_IRQ(1), |
| 351 | .ENABLE_IRQ_QREGS(0) |
| 352 | ) cpu ( |
| 353 | .wb_clk_i (wb_clk_i), |
| 354 | .wb_rst_i (wb_rst_i), |
| 355 | .trap (trap), |
| 356 | .irq (irq), |
| 357 | .mem_instr(mem_instr), |
| 358 | .wbm_adr_o(cpu_adr_o), |
| 359 | .wbm_dat_i(cpu_dat_i), |
| 360 | .wbm_stb_o(cpu_stb_o), |
| 361 | .wbm_ack_i(cpu_ack_i), |
| 362 | .wbm_cyc_o(cpu_cyc_o), |
| 363 | .wbm_dat_o(cpu_dat_o), |
| 364 | .wbm_we_o(cpu_we_o), |
| 365 | .wbm_sel_o(cpu_sel_o) |
| 366 | ); |
| 367 | |
| 368 | // Wishbone Slave SPIMEMIO |
| 369 | wire spimemio_flash_stb_i; |
| 370 | wire spimemio_flash_ack_o; |
| 371 | wire [31:0] spimemio_flash_dat_o; |
| 372 | |
| 373 | wire spimemio_cfg_stb_i; |
| 374 | wire spimemio_cfg_ack_o; |
| 375 | wire [31:0] spimemio_cfg_dat_o; |
| 376 | |
| 377 | spimemio_wb spimemio ( |
| 378 | .wb_clk_i(wb_clk_i), |
| 379 | .wb_rst_i(wb_rst_i), |
| 380 | |
| 381 | .wb_adr_i(cpu_adr_o), |
| 382 | .wb_dat_i(cpu_dat_o), |
| 383 | .wb_sel_i(cpu_sel_o), |
| 384 | .wb_we_i(cpu_we_o), |
| 385 | .wb_cyc_i(cpu_cyc_o), |
| 386 | |
| 387 | // FLash Slave |
| 388 | .wb_flash_stb_i(spimemio_flash_stb_i), |
| 389 | .wb_flash_ack_o(spimemio_flash_ack_o), |
| 390 | .wb_flash_dat_o(spimemio_flash_dat_o), |
| 391 | |
| 392 | // Config Register Slave |
| 393 | .wb_cfg_stb_i(spimemio_cfg_stb_i), |
| 394 | .wb_cfg_ack_o(spimemio_cfg_ack_o), |
| 395 | .wb_cfg_dat_o(spimemio_cfg_dat_o), |
| 396 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 397 | .pass_thru(pass_thru_mgmt), |
| 398 | .pass_thru_csb(pass_thru_mgmt_csb), |
| 399 | .pass_thru_sck(pass_thru_mgmt_sck), |
| 400 | .pass_thru_sdi(pass_thru_mgmt_sdi), |
| 401 | .pass_thru_sdo(pass_thru_mgmt_sdo), |
| 402 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 403 | .flash_csb (flash_csb), |
| 404 | .flash_clk (flash_clk), |
| 405 | |
| 406 | .flash_csb_oeb (flash_csb_oeb), |
| 407 | .flash_clk_oeb (flash_clk_oeb), |
| 408 | |
| 409 | .flash_io0_oeb (flash_io0_oeb), |
| 410 | .flash_io1_oeb (flash_io1_oeb), |
| 411 | .flash_io2_oeb (flash_io2_oeb), |
| 412 | .flash_io3_oeb (flash_io3_oeb), |
| 413 | |
| 414 | .flash_csb_ieb (flash_csb_ieb), |
| 415 | .flash_clk_ieb (flash_clk_ieb), |
| 416 | |
| 417 | .flash_io0_ieb (flash_io0_ieb), |
| 418 | .flash_io1_ieb (flash_io1_ieb), |
| 419 | .flash_io2_ieb (flash_io2_ieb), |
| 420 | .flash_io3_ieb (flash_io3_ieb), |
| 421 | |
| 422 | .flash_io0_do (flash_io0_do), |
| 423 | .flash_io1_do (flash_io1_do), |
| 424 | .flash_io2_do (flash_io2_do), |
| 425 | .flash_io3_do (flash_io3_do), |
| 426 | |
| 427 | .flash_io0_di (flash_io0_di), |
| 428 | .flash_io1_di (flash_io1_di), |
| 429 | .flash_io2_di (flash_io2_di), |
| 430 | .flash_io3_di (flash_io3_di) |
| 431 | ); |
| 432 | |
| 433 | // Wishbone Slave uart |
| 434 | wire uart_stb_i; |
| 435 | wire uart_ack_o; |
| 436 | wire [31:0] uart_dat_o; |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 437 | wire uart_enabled; |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 438 | |
| 439 | simpleuart_wb #( |
| 440 | .BASE_ADR(UART_BASE_ADR), |
| 441 | .CLK_DIV(UART_CLK_DIV), |
| 442 | .DATA(UART_DATA) |
| 443 | ) simpleuart ( |
| 444 | // Wishbone Interface |
| 445 | .wb_clk_i(wb_clk_i), |
| 446 | .wb_rst_i(wb_rst_i), |
| 447 | |
| 448 | .wb_adr_i(cpu_adr_o), |
| 449 | .wb_dat_i(cpu_dat_o), |
| 450 | .wb_sel_i(cpu_sel_o), |
| 451 | .wb_we_i(cpu_we_o), |
| 452 | .wb_cyc_i(cpu_cyc_o), |
| 453 | |
| 454 | .wb_stb_i(uart_stb_i), |
| 455 | .wb_ack_o(uart_ack_o), |
| 456 | .wb_dat_o(uart_dat_o), |
| 457 | |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 458 | .uart_enabled(uart_enabled), |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 459 | .ser_tx(ser_tx), |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 460 | .ser_rx(mgmt_in_data[5]) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 461 | ); |
| 462 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 463 | // Wishbone SPI master |
| 464 | wire spi_master_stb_i; |
| 465 | wire spi_master_ack_o; |
| 466 | wire [31:0] spi_master_dat_o; |
| 467 | |
| 468 | simple_spi_master_wb #( |
| 469 | .BASE_ADR(SPI_MASTER_BASE_ADR), |
| 470 | .CONFIG(SPI_MASTER_CONFIG), |
| 471 | .DATA(SPI_MASTER_DATA) |
| 472 | ) simple_spi_master_inst ( |
| 473 | // Wishbone Interface |
| 474 | .wb_clk_i(wb_clk_i), |
| 475 | .wb_rst_i(wb_rst_i), |
| 476 | |
| 477 | .wb_adr_i(cpu_adr_o), |
| 478 | .wb_dat_i(cpu_dat_o), |
| 479 | .wb_sel_i(cpu_sel_o), |
| 480 | .wb_we_i(cpu_we_o), |
| 481 | .wb_cyc_i(cpu_cyc_o), |
| 482 | |
| 483 | .wb_stb_i(spi_master_stb_i), |
| 484 | .wb_ack_o(spi_master_ack_o), |
| 485 | .wb_dat_o(spi_master_dat_o), |
| 486 | |
Tim Edwards | 8115320 | 2020-10-09 19:57:04 -0400 | [diff] [blame] | 487 | .hk_connect(hk_connect), |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 488 | .csb(mgmt_out_pre[3]), |
| 489 | .sck(mgmt_out_pre[4]), |
| 490 | .sdi(mgmt_in_data[1]), |
| 491 | .sdo(mgmt_out_pre[2]), |
| 492 | .sdoenb(), |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 493 | .irq(irq_spi_master) |
| 494 | ); |
| 495 | |
| 496 | // Wishbone Counter-timer 0 |
| 497 | wire counter_timer0_stb_i; |
| 498 | wire counter_timer0_ack_o; |
| 499 | wire [31:0] counter_timer0_dat_o; |
| 500 | |
| 501 | counter_timer_wb #( |
| 502 | .BASE_ADR(COUNTER_TIMER0_BASE_ADR), |
| 503 | .CONFIG(COUNTER_TIMER0_CONFIG), |
| 504 | .VALUE(COUNTER_TIMER0_VALUE), |
| 505 | .DATA(COUNTER_TIMER0_DATA) |
| 506 | ) counter_timer_0 ( |
| 507 | // Wishbone Interface |
| 508 | .wb_clk_i(wb_clk_i), |
| 509 | .wb_rst_i(wb_rst_i), |
| 510 | |
| 511 | .wb_adr_i(cpu_adr_o), |
| 512 | .wb_dat_i(cpu_dat_o), |
| 513 | .wb_sel_i(cpu_sel_o), |
| 514 | .wb_we_i(cpu_we_o), |
| 515 | .wb_cyc_i(cpu_cyc_o), |
| 516 | |
| 517 | .wb_stb_i(counter_timer0_stb_i), |
| 518 | .wb_ack_o(counter_timer0_ack_o), |
| 519 | .wb_dat_o(counter_timer0_dat_o), |
| 520 | .irq(irq_counter_timer0) |
| 521 | ); |
| 522 | |
| 523 | // Wishbone Counter-timer 1 |
| 524 | wire counter_timer1_stb_i; |
| 525 | wire counter_timer1_ack_o; |
| 526 | wire [31:0] counter_timer1_dat_o; |
| 527 | |
| 528 | counter_timer_wb #( |
| 529 | .BASE_ADR(COUNTER_TIMER1_BASE_ADR), |
| 530 | .CONFIG(COUNTER_TIMER1_CONFIG), |
| 531 | .VALUE(COUNTER_TIMER1_VALUE), |
| 532 | .DATA(COUNTER_TIMER1_DATA) |
| 533 | ) counter_timer_1 ( |
| 534 | // Wishbone Interface |
| 535 | .wb_clk_i(wb_clk_i), |
| 536 | .wb_rst_i(wb_rst_i), |
| 537 | |
| 538 | .wb_adr_i(cpu_adr_o), |
| 539 | .wb_dat_i(cpu_dat_o), |
| 540 | .wb_sel_i(cpu_sel_o), |
| 541 | .wb_we_i(cpu_we_o), |
| 542 | .wb_cyc_i(cpu_cyc_o), |
| 543 | |
| 544 | .wb_stb_i(counter_timer1_stb_i), |
| 545 | .wb_ack_o(counter_timer1_ack_o), |
| 546 | .wb_dat_o(counter_timer1_dat_o), |
| 547 | .irq(irq_counter_timer1) |
| 548 | ); |
| 549 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 550 | // Wishbone Slave GPIO Registers |
| 551 | wire gpio_stb_i; |
| 552 | wire gpio_ack_o; |
| 553 | wire [31:0] gpio_dat_o; |
| 554 | |
| 555 | gpio_wb #( |
| 556 | .BASE_ADR(GPIO_BASE_ADR), |
| 557 | .GPIO_DATA(GPIO_DATA), |
| 558 | .GPIO_ENA(GPIO_ENA), |
| 559 | .GPIO_PD(GPIO_PD), |
| 560 | .GPIO_PU(GPIO_PU) |
| 561 | ) gpio_wb ( |
| 562 | .wb_clk_i(wb_clk_i), |
| 563 | .wb_rst_i(wb_rst_i), |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 564 | .wb_adr_i(cpu_adr_o), |
| 565 | .wb_dat_i(cpu_dat_o), |
| 566 | .wb_sel_i(cpu_sel_o), |
| 567 | .wb_we_i(cpu_we_o), |
| 568 | .wb_cyc_i(cpu_cyc_o), |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 569 | .wb_stb_i(gpio_stb_i), |
| 570 | .wb_ack_o(gpio_ack_o), |
| 571 | .wb_dat_o(gpio_dat_o), |
| 572 | .gpio_in_pad(gpio_in_pad), |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 573 | .gpio(gpio), |
| 574 | .gpio_oeb(gpio_oeb), |
| 575 | .gpio_pu(gpio_pu), |
| 576 | .gpio_pd(gpio_pd) |
| 577 | ); |
| 578 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 579 | // Wishbone Slave System Control Register |
| 580 | wire sys_stb_i; |
| 581 | wire sys_ack_o; |
| 582 | wire [31:0] sys_dat_o; |
| 583 | |
| 584 | sysctrl_wb #( |
| 585 | .BASE_ADR(SYS_BASE_ADR), |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 586 | .PLL_OUT(PLL_OUT), |
| 587 | .TRAP_OUT(TRAP_OUT), |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 588 | .IRQ7_SRC(IRQ7_SRC) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 589 | ) sysctrl ( |
| 590 | .wb_clk_i(wb_clk_i), |
| 591 | .wb_rst_i(wb_rst_i), |
| 592 | |
| 593 | .wb_adr_i(cpu_adr_o), |
| 594 | .wb_dat_i(cpu_dat_o), |
| 595 | .wb_sel_i(cpu_sel_o), |
| 596 | .wb_we_i(cpu_we_o), |
| 597 | .wb_cyc_i(cpu_cyc_o), |
| 598 | |
| 599 | .wb_stb_i(sys_stb_i), |
| 600 | .wb_ack_o(sys_ack_o), |
| 601 | .wb_dat_o(sys_dat_o), |
| 602 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 603 | .pll_output_dest(pll_output_dest), |
| 604 | .trap_output_dest(trap_output_dest), |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 605 | .irq_7_inputsrc(irq_7_inputsrc) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 606 | ); |
| 607 | |
| 608 | // Logic Analyzer |
| 609 | wire la_stb_i; |
| 610 | wire la_ack_o; |
| 611 | wire [31:0] la_dat_o; |
| 612 | |
| 613 | la_wb #( |
| 614 | .BASE_ADR(LA_BASE_ADR), |
| 615 | .LA_DATA_0(LA_DATA_0), |
| 616 | .LA_DATA_1(LA_DATA_1), |
| 617 | .LA_DATA_3(LA_DATA_3), |
| 618 | .LA_ENA_0(LA_ENA_0), |
| 619 | .LA_ENA_1(LA_ENA_1), |
| 620 | .LA_ENA_2(LA_ENA_2), |
| 621 | .LA_ENA_3(LA_ENA_3) |
| 622 | ) la ( |
| 623 | .wb_clk_i(wb_clk_i), |
| 624 | .wb_rst_i(wb_rst_i), |
| 625 | |
| 626 | .wb_adr_i(cpu_adr_o), |
| 627 | .wb_dat_i(cpu_dat_o), |
| 628 | .wb_sel_i(cpu_sel_o), |
| 629 | .wb_we_i(cpu_we_o), |
| 630 | .wb_cyc_i(cpu_cyc_o), |
| 631 | |
| 632 | .wb_stb_i(la_stb_i), |
| 633 | .wb_ack_o(la_ack_o), |
| 634 | .wb_dat_o(la_dat_o), |
| 635 | |
| 636 | .la_data(la_output), |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 637 | .la_data_in(la_input), |
| 638 | .la_oen(la_oen) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 639 | ); |
| 640 | |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 641 | // WB Slave Mega-Project Control |
| 642 | wire mprj_ctrl_stb_i; |
| 643 | wire mprj_ctrl_ack_o; |
| 644 | wire [31:0] mprj_ctrl_dat_o; |
Tim Edwards | 9eda80d | 2020-10-08 21:36:44 -0400 | [diff] [blame] | 645 | wire [MPRJ_IO_PADS-1:0] mgmt_out_pre; |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 646 | |
| 647 | // Bits assigned to specific functions as outputs prevent the |
| 648 | // mprj GPIO-as-output from applying data when that function |
| 649 | // is active |
| 650 | |
| 651 | assign mgmt_out_data[MPRJ_IO_PADS-1:7] = mgmt_out_pre[MPRJ_IO_PADS-1:7]; |
| 652 | assign mgmt_out_data[6] = uart_enabled ? ser_tx : mgmt_out_pre[6]; |
| 653 | assign mgmt_out_data[5:0] = mgmt_out_pre[5:0]; |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 654 | |
| 655 | mprj_ctrl_wb #( |
| 656 | .BASE_ADR(MPRJ_CTRL_ADR), |
| 657 | .IO_PADS(MPRJ_IO_PADS), |
Tim Edwards | c18c474 | 2020-10-03 11:26:39 -0400 | [diff] [blame] | 658 | .PWR_PADS(MPRJ_PWR_PADS) |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 659 | ) mprj_ctrl ( |
| 660 | .wb_clk_i(wb_clk_i), |
| 661 | .wb_rst_i(wb_rst_i), |
| 662 | |
| 663 | .wb_adr_i(cpu_adr_o), |
| 664 | .wb_dat_i(cpu_dat_o), |
| 665 | .wb_sel_i(cpu_sel_o), |
| 666 | .wb_we_i(cpu_we_o), |
| 667 | .wb_cyc_i(cpu_cyc_o), |
| 668 | .wb_stb_i(mprj_ctrl_stb_i), |
| 669 | .wb_ack_o(mprj_ctrl_ack_o), |
| 670 | .wb_dat_o(mprj_ctrl_dat_o), |
| 671 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 672 | .serial_clock(mprj_io_loader_clock), |
| 673 | .serial_resetn(mprj_io_loader_resetn), |
| 674 | .serial_data_out(mprj_io_loader_data), |
Tim Edwards | ca2f318 | 2020-10-06 10:05:11 -0400 | [diff] [blame] | 675 | .mgmt_gpio_out(mgmt_out_pre), |
| 676 | .mgmt_gpio_in(mgmt_in_data) |
shalan | 0d14e6e | 2020-08-31 16:50:48 +0200 | [diff] [blame] | 677 | ); |
| 678 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 679 | // Wishbone Slave RAM |
| 680 | wire mem_stb_i; |
| 681 | wire mem_ack_o; |
| 682 | wire [31:0] mem_dat_o; |
| 683 | |
| 684 | mem_wb #( |
| 685 | .MEM_WORDS(MEM_WORDS) |
| 686 | ) soc_mem ( |
| 687 | .wb_clk_i(wb_clk_i), |
| 688 | .wb_rst_i(wb_rst_i), |
| 689 | |
| 690 | .wb_adr_i(cpu_adr_o), |
| 691 | .wb_dat_i(cpu_dat_o), |
| 692 | .wb_sel_i(cpu_sel_o), |
| 693 | .wb_we_i(cpu_we_o), |
| 694 | .wb_cyc_i(cpu_cyc_o), |
| 695 | |
| 696 | .wb_stb_i(mem_stb_i), |
| 697 | .wb_ack_o(mem_ack_o), |
| 698 | .wb_dat_o(mem_dat_o) |
| 699 | ); |
| 700 | |
| 701 | // Wishbone intercon logic |
| 702 | wb_intercon #( |
| 703 | .AW(ADR_WIDTH), |
| 704 | .DW(DAT_WIDTH), |
| 705 | .NS(NUM_SLAVES), |
| 706 | .ADR_MASK(ADR_MASK), |
| 707 | .SLAVE_ADR(SLAVE_ADR) |
| 708 | ) intercon ( |
| 709 | // Master Interface |
| 710 | .wbm_adr_i(cpu_adr_o), |
| 711 | .wbm_stb_i(cpu_stb_o), |
| 712 | .wbm_dat_o(cpu_dat_i), |
| 713 | .wbm_ack_o(cpu_ack_i), |
| 714 | |
| 715 | // Slaves Interface |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 716 | .wbs_stb_o({ xbar_stb_o, sys_stb_i, spimemio_cfg_stb_i, |
| 717 | mprj_stb_o, mprj_ctrl_stb_i, la_stb_i, |
| 718 | spi_master_stb_i, counter_timer1_stb_i, counter_timer0_stb_i, |
| 719 | gpio_stb_i, uart_stb_i, |
| 720 | spimemio_flash_stb_i, mem_stb_i }), |
| 721 | .wbs_dat_i({ xbar_dat_i, sys_dat_o, spimemio_cfg_dat_o, |
| 722 | mprj_dat_i, mprj_ctrl_dat_o, la_dat_o, |
| 723 | spi_master_dat_o, counter_timer1_dat_o, counter_timer0_dat_o, |
| 724 | gpio_dat_o, uart_dat_o, |
| 725 | spimemio_flash_dat_o, mem_dat_o }), |
| 726 | .wbs_ack_i({ xbar_ack_i, sys_ack_o, spimemio_cfg_ack_o, |
| 727 | mprj_ack_i, mprj_ctrl_ack_o, la_ack_o, |
| 728 | spi_master_ack_o, counter_timer1_ack_o, counter_timer0_ack_o, |
| 729 | gpio_ack_o, uart_ack_o, |
| 730 | spimemio_flash_ack_o, mem_ack_o }) |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 731 | ); |
| 732 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 733 | endmodule |
| 734 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 735 | // Implementation note: |
| 736 | // Replace the following two modules with wrappers for your SRAM cells. |
Tim Edwards | ef8312e | 2020-09-22 17:20:06 -0400 | [diff] [blame] | 737 | |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 738 | module mgmt_soc_regs ( |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 739 | input clk, wen, |
| 740 | input [5:0] waddr, |
| 741 | input [5:0] raddr1, |
| 742 | input [5:0] raddr2, |
| 743 | input [31:0] wdata, |
| 744 | output [31:0] rdata1, |
| 745 | output [31:0] rdata2 |
| 746 | ); |
| 747 | reg [31:0] regs [0:31]; |
| 748 | |
| 749 | always @(posedge clk) |
| 750 | if (wen) regs[waddr[4:0]] <= wdata; |
| 751 | |
| 752 | assign rdata1 = regs[raddr1[4:0]]; |
| 753 | assign rdata2 = regs[raddr2[4:0]]; |
| 754 | endmodule |