/* * top.v * * vim: ts=4 sw=4 * * Copyright (C) 2019-2020 Sylvain Munaut * SPDX-License-Identifier: CERN-OHL-P-2.0 */ `default_nettype none `include "boards.vh" module top ( // SPI inout wire spi_mosi, inout wire spi_miso, inout wire spi_clk, output wire spi_flash_cs_n, `ifdef HAS_PSRAM output wire spi_ram_cs_n, `endif // USB TODO: remove later inout wire usb_dp, inout wire usb_dn, output wire usb_pu, // Debug UART input wire uart_rx, output wire uart_tx, // Buttons (2 for now to test up and down) input wire btn_n, input wire btn_1, input wire btn_2, // LEDs to blink to show that a value change has been registered? output wire[4:0] led, // GPIOs for out signal output wire out1, output wire out2, output wire out3, // LED TODO: remove later output wire [2:0] rgb, // Clock input wire clk_in ); localparam integer SPRAM_AW = 14; /* 14 => 64k, 15 => 128k */ localparam integer WB_N = 5; // TODO: Reduce localparam integer WB_DW = 32; localparam integer WB_AW = 16; localparam integer WB_RW = WB_DW * WB_N; localparam integer WB_MW = WB_DW / 8; localparam integer FAST_PWM_WIDTH = 8; localparam integer PULSE_COUNTER_WIDTH = 8; localparam integer SLOW_PWM_WIDTH = 14; genvar i; // Signals // ------- // Wishbone wire [WB_AW-1:0] wb_addr; wire [WB_DW-1:0] wb_rdata [0:WB_N-1]; wire [WB_RW-1:0] wb_rdata_flat; wire [WB_DW-1:0] wb_wdata; wire [WB_MW-1:0] wb_wmsk; wire [WB_N -1:0] wb_cyc; wire wb_we; wire [WB_N -1:0] wb_ack; // WarmBoot reg boot_now; reg [1:0] boot_sel; // Clock / Reset logic wire clk_24m; wire clk_48m; wire rst; // 3 signal wire [SLOW_PWM_WIDTH-1:0] period1; wire [SLOW_PWM_WIDTH-1:0] delay1; wire [SLOW_PWM_WIDTH-1:0] period2; wire [SLOW_PWM_WIDTH-1:0] delay2; wire [FAST_PWM_WIDTH-1:0] period3; wire [FAST_PWM_WIDTH-1:0] duty3; wire [SLOW_PWM_WIDTH-1:0] delay3; wire [PULSE_COUNTER_WIDTH-1:0] npuls3; wire [1:0] odd_train_flag; wire ena_odd_out3; // Mailbox signal wires wire [16*16-1:0] mailbox_regs_flat; // Flattened register array (16 registers of 16 bits each) // SoC // --- soc_picorv32_base #( .WB_N (WB_N), .WB_DW (WB_DW), .WB_AW (WB_AW), .SPRAM_AW(SPRAM_AW) ) base_I ( .wb_addr (wb_addr), .wb_rdata(wb_rdata_flat), .wb_wdata(wb_wdata), .wb_wmsk (wb_wmsk), .wb_we (wb_we), .wb_cyc (wb_cyc), .wb_ack (wb_ack), .clk (clk_24m), .rst (rst) ); for (i=0; i