Line 80... |
Line 80... |
// http://www.gnu.org/licenses/gpl.html
|
// http://www.gnu.org/licenses/gpl.html
|
//
|
//
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
//
|
//
|
|
`include "cpudefs.v"
|
|
//
|
// While I hate adding delays to any bus access, this next delay is required
|
// While I hate adding delays to any bus access, this next delay is required
|
// to make timing close in my Basys-3 design.
|
// to make timing close in my Basys-3 design.
|
`define DELAY_DBG_BUS
|
`define DELAY_DBG_BUS
|
// On my previous version, I needed to add a delay to access the external
|
// On my previous version, I needed to add a delay to access the external
|
// bus. Activate the define below and that delay will be put back into place.
|
// bus. Activate the define below and that delay will be put back into place.
|
Line 149... |
Line 151... |
// ADDRESS:
|
// ADDRESS:
|
// 5 PERIPHERAL-BIT
|
// 5 PERIPHERAL-BIT
|
// [4:0] REGISTER-ADDR
|
// [4:0] REGISTER-ADDR
|
// DBGDATA
|
// DBGDATA
|
// read/writes internal registers
|
// read/writes internal registers
|
|
//
|
|
//
|
|
//
|
module zipsystem(i_clk, i_rst,
|
module zipsystem(i_clk, i_rst,
|
// Wishbone master interface from the CPU
|
// Wishbone master interface from the CPU
|
o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
|
o_wb_cyc, o_wb_stb, o_wb_we, o_wb_addr, o_wb_data,
|
i_wb_ack, i_wb_stall, i_wb_data, i_wb_err,
|
i_wb_ack, i_wb_stall, i_wb_data, i_wb_err,
|
// Incoming interrupts
|
// Incoming interrupts
|
i_ext_int,
|
i_ext_int,
|
// Our one outgoing interrupt
|
// Our one outgoing interrupt
|
o_ext_int,
|
o_ext_int,
|
// Wishbone slave interface for debugging purposes
|
// Wishbone slave interface for debugging purposes
|
i_dbg_cyc, i_dbg_stb, i_dbg_we, i_dbg_addr, i_dbg_data,
|
i_dbg_cyc, i_dbg_stb, i_dbg_we, i_dbg_addr, i_dbg_data,
|
o_dbg_ack, o_dbg_stall, o_dbg_data,
|
o_dbg_ack, o_dbg_stall, o_dbg_data
|
o_cpu_debug);
|
`ifdef DEBUG_SCOPE
|
|
, o_cpu_debug
|
|
`endif
|
|
);
|
parameter RESET_ADDRESS=24'h0100000, ADDRESS_WIDTH=24,
|
parameter RESET_ADDRESS=24'h0100000, ADDRESS_WIDTH=24,
|
LGICACHE=6, START_HALTED=1, EXTERNAL_INTERRUPTS=1,
|
LGICACHE=12, START_HALTED=1, EXTERNAL_INTERRUPTS=1,
|
// Derived parameters
|
// Derived parameters
|
AW=ADDRESS_WIDTH;
|
AW=ADDRESS_WIDTH;
|
input i_clk, i_rst;
|
input i_clk, i_rst;
|
// Wishbone master
|
// Wishbone master
|
output wire o_wb_cyc, o_wb_stb, o_wb_we;
|
output wire o_wb_cyc, o_wb_stb, o_wb_we;
|
Line 184... |
Line 192... |
input [31:0] i_dbg_data;
|
input [31:0] i_dbg_data;
|
output wire o_dbg_ack;
|
output wire o_dbg_ack;
|
output wire o_dbg_stall;
|
output wire o_dbg_stall;
|
output wire [31:0] o_dbg_data;
|
output wire [31:0] o_dbg_data;
|
//
|
//
|
|
`ifdef DEBUG_SCOPE
|
output wire [31:0] o_cpu_debug;
|
output wire [31:0] o_cpu_debug;
|
|
`endif
|
|
|
wire [31:0] ext_idata;
|
wire [31:0] ext_idata;
|
|
|
// Delay the debug port by one clock, to meet timing requirements
|
// Delay the debug port by one clock, to meet timing requirements
|
wire dbg_cyc, dbg_stb, dbg_we, dbg_addr, dbg_stall;
|
wire dbg_cyc, dbg_stb, dbg_we, dbg_addr, dbg_stall;
|
Line 465... |
Line 475... |
wire dc_cyc, dc_stb, dc_we, dc_ack, dc_stall;
|
wire dc_cyc, dc_stb, dc_we, dc_ack, dc_stall;
|
wire [31:0] dc_data;
|
wire [31:0] dc_data;
|
wire [(AW-1):0] dc_addr;
|
wire [(AW-1):0] dc_addr;
|
wire cpu_gbl_cyc;
|
wire cpu_gbl_cyc;
|
assign dmac_stb = (sys_stb)&&(sys_addr[4]);
|
assign dmac_stb = (sys_stb)&&(sys_addr[4]);
|
// `define INCLUDE_DMA_CONTROLLER
|
`define INCLUDE_DMA_CONTROLLER
|
`ifdef INCLUDE_DMA_CONTROLLER
|
`ifdef INCLUDE_DMA_CONTROLLER
|
wbdmac #(AW) dma_controller(i_clk,
|
wbdmac #(AW) dma_controller(i_clk,
|
sys_cyc, dmac_stb, sys_we,
|
sys_cyc, dmac_stb, sys_we,
|
sys_addr[1:0], sys_data,
|
sys_addr[1:0], sys_data,
|
dmac_ack, dmac_stall, dmac_data,
|
dmac_ack, dmac_stall, dmac_data,
|
Line 605... |
Line 615... |
cpu_gbl_cyc, cpu_gbl_stb,
|
cpu_gbl_cyc, cpu_gbl_stb,
|
cpu_lcl_cyc, cpu_lcl_stb,
|
cpu_lcl_cyc, cpu_lcl_stb,
|
cpu_we, cpu_addr, cpu_data,
|
cpu_we, cpu_addr, cpu_data,
|
cpu_ack, cpu_stall, wb_data,
|
cpu_ack, cpu_stall, wb_data,
|
cpu_err,
|
cpu_err,
|
cpu_op_stall, cpu_pf_stall, cpu_i_count,
|
cpu_op_stall, cpu_pf_stall, cpu_i_count
|
o_cpu_debug);
|
`ifdef DEBUG_SCOPE
|
|
, o_cpu_debug
|
|
`endif
|
|
);
|
|
|
// Now, arbitrate the bus ... first for the local peripherals
|
// Now, arbitrate the bus ... first for the local peripherals
|
// For the debugger to have access to the local system bus, the
|
// For the debugger to have access to the local system bus, the
|
// following must be true:
|
// following must be true:
|
// (dbg_cyc) The debugger must request the bus
|
// (dbg_cyc) The debugger must request the bus
|