Line 44... |
Line 44... |
//
|
//
|
`define IMPLEMENT_ONCHIP_RAM
|
`define IMPLEMENT_ONCHIP_RAM
|
`define FLASH_ACCESS
|
`define FLASH_ACCESS
|
`define DBG_SCOPE // About 204 LUTs, at 2^6 addresses
|
`define DBG_SCOPE // About 204 LUTs, at 2^6 addresses
|
// `define COMPRESSED_SCOPE
|
// `define COMPRESSED_SCOPE
|
|
`define HAS_RXUART
|
`define INCLUDE_CPU_RESET_LOGIC
|
`define INCLUDE_CPU_RESET_LOGIC
|
|
`define LOWLOGIC_FLASH // Saves about 154 LUTs
|
|
`define USE_LITE_UART // Saves about 55 LUTs
|
module busmaster(i_clk, i_rst,
|
module busmaster(i_clk, i_rst,
|
i_uart, o_uart_rts_n, o_uart, i_uart_cts_n,
|
i_uart, o_uart_rts_n, o_uart, i_uart_cts_n,
|
// The SPI Flash lines
|
// The SPI Flash lines
|
o_qspi_cs_n, o_qspi_sck, o_qspi_dat, i_qspi_dat, o_qspi_mod,
|
o_qspi_cs_n, o_qspi_sck, o_qspi_dat, i_qspi_dat, o_qspi_mod,
|
// The board I/O
|
// The board I/O
|
Line 73... |
Line 76... |
input i_clk, i_rst;
|
input i_clk, i_rst;
|
// UART parameters
|
// UART parameters
|
input i_uart, i_uart_cts_n;
|
input i_uart, i_uart_cts_n;
|
output wire o_uart, o_uart_rts_n;
|
output wire o_uart, o_uart_rts_n;
|
// SPI flash control
|
// SPI flash control
|
output wire o_qspi_cs_n, o_qspi_sck;
|
output wire o_qspi_cs_n;
|
|
`ifdef LOWLOGIC_FLASH
|
|
output wire [1:0] o_qspi_sck;
|
|
`else
|
|
output wire o_qspi_sck;
|
|
`endif
|
output wire [3:0] o_qspi_dat;
|
output wire [3:0] o_qspi_dat;
|
input [3:0] i_qspi_dat;
|
input [3:0] i_qspi_dat;
|
output wire [1:0] o_qspi_mod;
|
output wire [1:0] o_qspi_mod;
|
// Board I/O
|
// Board I/O
|
input [1:0] i_btn;
|
input [1:0] i_btn;
|
Line 138... |
Line 146... |
r_button <= x_button;
|
r_button <= x_button;
|
btn_reset <= ((r_button)&&(zip_cpu_int))||(watchdog_int);
|
btn_reset <= ((r_button)&&(zip_cpu_int))||(watchdog_int);
|
end
|
end
|
assign cpu_reset = btn_reset;
|
assign cpu_reset = btn_reset;
|
`else
|
`else
|
assign cpu_reset = 1'b0;
|
assign cpu_reset = (watchdog_int);
|
`endif
|
`endif
|
|
|
zipbones #(CMOD_ZIPCPU_RESET_ADDRESS,ZA,6)
|
zipbones #(CMOD_ZIPCPU_RESET_ADDRESS,ZA,6)
|
swic(i_clk, btn_reset, // 1'b0,
|
swic(i_clk, cpu_reset, // 1'b0,
|
// Zippys wishbone interface
|
// Zippys wishbone interface
|
wb_cyc, wb_stb, wb_we, w_zip_addr, wb_data, wb_sel,
|
wb_cyc, wb_stb, wb_we, w_zip_addr, wb_data, wb_sel,
|
wb_ack, wb_stall, wb_idata, wb_err,
|
wb_ack, wb_stall, wb_idata, wb_err,
|
w_interrupt, zip_cpu_int,
|
w_interrupt, zip_cpu_int,
|
// Debug wishbone interface -- not really used
|
// Debug wishbone interface -- not really used
|
Line 435... |
Line 443... |
wire [3:0] w_led;
|
wire [3:0] w_led;
|
spio thespio(i_clk, wb_cyc,(wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h5),
|
spio thespio(i_clk, wb_cyc,(wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h5),
|
wb_we, wb_data, spio_data,
|
wb_we, wb_data, spio_data,
|
o_kp_col, i_kp_row, i_btn, w_led,
|
o_kp_col, i_kp_row, i_btn, w_led,
|
keypad_int, button_int);
|
keypad_int, button_int);
|
assign o_led = { w_led[3]|w_interrupt,w_led[2]|zip_cpu_int,w_led[1:0] };
|
assign o_led = { w_led[3]|w_interrupt,w_led[2]|zip_cpu_int,
|
|
w_led[1], w_led[0] };
|
|
|
//
|
//
|
// General purpose (sort of) I/O: (Bottom two bits robbed in each
|
// General purpose (sort of) I/O: (Bottom two bits robbed in each
|
// direction for an I2C link at the toplevel.v design)
|
// direction for an I2C link at the toplevel.v design)
|
//
|
//
|
Line 457... |
Line 466... |
wire rx_break, rx_parity_err, rx_frame_err, rx_ck_uart, rx_stb;
|
wire rx_break, rx_parity_err, rx_frame_err, rx_ck_uart, rx_stb;
|
wire [7:0] rx_data;
|
wire [7:0] rx_data;
|
//
|
//
|
assign uart_setup = UART_SETUP;
|
assign uart_setup = UART_SETUP;
|
//
|
//
|
|
`ifdef HAS_RXUART
|
|
`ifdef USE_LITE_UART
|
|
rxuartlite #(UART_SETUP[23:0])
|
|
rcvuart(i_clk, i_uart, rx_stb, rx_data);
|
|
assign rx_break = 1'b0;
|
|
assign rx_parity_err = 1'b0;
|
|
assign rx_frame_err = 1'b0;
|
|
assign rx_ck_uart = 1'b0;
|
|
`else
|
rxuart #(UART_SETUP)
|
rxuart #(UART_SETUP)
|
rcvuart(i_clk, 1'b0, uart_setup, i_uart, rx_stb, rx_data,
|
rcvuart(i_clk, 1'b0, uart_setup, i_uart, rx_stb, rx_data,
|
rx_break, rx_parity_err, rx_frame_err, rx_ck_uart);
|
rx_break, rx_parity_err, rx_frame_err, rx_ck_uart);
|
|
`endif
|
|
`else
|
|
assign rx_break = 1'b0;
|
|
assign rx_parity_err = 1'b0;
|
|
assign rx_frame_err = 1'b0;
|
|
assign rx_ck_uart = 1'b0;
|
|
assign rx_stb = 1'b0;
|
|
assign rx_data = 8'h0;
|
|
`endif
|
//
|
//
|
wire tx_break, tx_busy;
|
wire tx_break, tx_busy;
|
reg tx_stb;
|
reg tx_stb;
|
reg [7:0] tx_data;
|
reg [7:0] tx_data;
|
assign tx_break = 1'b0;
|
assign tx_break = 1'b0;
|
|
`ifdef USE_LITE_UART
|
|
txuartlite #(UART_SETUP[23:0])
|
|
tcvuart(i_clk, tx_stb, tx_data, o_uart, tx_busy);
|
|
`else
|
txuart #(UART_SETUP)
|
txuart #(UART_SETUP)
|
tcvuart(i_clk, 1'b0, uart_setup, tx_break, tx_stb, tx_data,
|
tcvuart(i_clk, 1'b0, uart_setup, tx_break, tx_stb, tx_data,
|
i_uart_cts_n, o_uart, tx_busy);
|
i_uart_cts_n, o_uart, tx_busy);
|
|
`endif
|
|
|
//
|
//
|
// Rudimentary serial port control
|
// Rudimentary serial port control
|
//
|
//
|
reg [7:0] r_rx_data;
|
reg [7:0] r_rx_data;
|
Line 485... |
Line 517... |
tx_data <= wb_data[7:0];
|
tx_data <= wb_data[7:0];
|
tx_stb <= 1'b1;
|
tx_stb <= 1'b1;
|
end
|
end
|
else if ((tx_stb)&&(!tx_busy))
|
else if ((tx_stb)&&(!tx_busy))
|
tx_stb <= 1'b0;
|
tx_stb <= 1'b0;
|
|
`ifdef HAS_RXUART
|
initial rx_rdy = 1'b0;
|
initial rx_rdy = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (rx_stb)
|
if (rx_stb)
|
r_rx_data <= rx_data;
|
r_rx_data <= rx_data;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
begin
|
begin
|
if((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h7)&&(!wb_we))
|
if((wb_stb)&&(io_sel)&&(wb_addr[3:0]==4'h7)&&(!wb_we))
|
rx_rdy <= rx_stb;
|
rx_rdy <= rx_stb;
|
else if (rx_stb)
|
else
|
rx_rdy <= (rx_rdy | rx_stb);
|
rx_rdy <= (rx_rdy | rx_stb);
|
end
|
end
|
assign o_uart_rts_n = (rx_rdy);
|
assign o_uart_rts_n = (rx_rdy);
|
assign uart_data = { 23'h0, !rx_rdy, r_rx_data };
|
assign uart_data = { 23'h0, !rx_rdy, r_rx_data };
|
|
`else
|
|
assign o_uart_rts_n = 1'b1;
|
|
assign uart_data = 32'h00;
|
|
`endif
|
//
|
//
|
// uart_ack gets returned as part of io_ack, since that happens when
|
// uart_ack gets returned as part of io_ack, since that happens when
|
// io_sel and wb_stb are defined
|
// io_sel and wb_stb are defined
|
//
|
//
|
// always @(posedge i_clk)
|
// always @(posedge i_clk)
|
Line 511... |
Line 548... |
|
|
//
|
//
|
// FLASH MEMORY CONFIGURATION ACCESS
|
// FLASH MEMORY CONFIGURATION ACCESS
|
//
|
//
|
`ifdef FLASH_ACCESS
|
`ifdef FLASH_ACCESS
|
|
`ifdef LOWLOGIC_FLASH
|
|
qflashxpress flashmem(i_clk,
|
|
wb_cyc,(wb_stb)&&(flash_sel),
|
|
wb_addr[(LGFLASHSZ-3):0],
|
|
flash_ack, flash_stall, flash_data,
|
|
o_qspi_sck, o_qspi_cs_n, o_qspi_mod, o_qspi_dat, i_qspi_dat);
|
|
|
|
assign flash_interrupt = 1'b0;
|
|
`else
|
wbqspiflash #(LGFLASHSZ) flashmem(i_clk,
|
wbqspiflash #(LGFLASHSZ) flashmem(i_clk,
|
wb_cyc,(wb_stb)&&(flash_sel),(wb_stb)&&(flctl_sel),wb_we,
|
wb_cyc,(wb_stb)&&(flash_sel),(wb_stb)&&(flctl_sel),wb_we,
|
wb_addr[(LGFLASHSZ-3):0], wb_data,
|
wb_addr[(LGFLASHSZ-3):0], wb_data,
|
flash_ack, flash_stall, flash_data,
|
flash_ack, flash_stall, flash_data,
|
o_qspi_sck, o_qspi_cs_n, o_qspi_mod, o_qspi_dat, i_qspi_dat,
|
o_qspi_sck, o_qspi_cs_n, o_qspi_mod, o_qspi_dat, i_qspi_dat,
|
flash_interrupt);
|
flash_interrupt);
|
|
`endif
|
`else
|
`else
|
reg r_flash_ack;
|
reg r_flash_ack;
|
initial r_flash_ack = 1'b0;
|
initial r_flash_ack = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
r_flash_ack <= (wb_stb)&&((flash_sel)||(flctl_sel));
|
r_flash_ack <= (wb_stb)&&((flash_sel)||(flctl_sel));
|