OpenCores
URL https://opencores.org/ocsvn/xulalx25soc/xulalx25soc/trunk

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [busmaster.v] - Diff between revs 46 and 74

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 46 Rev 74
Line 49... Line 49...
`define INCLUDE_ZIPCPU
`define INCLUDE_ZIPCPU
// `define      NO_ZIP_WBU_DELAY
// `define      NO_ZIP_WBU_DELAY
`define IMPLEMENT_ONCHIP_RAM
`define IMPLEMENT_ONCHIP_RAM
`ifndef VERILATOR
`ifndef VERILATOR
`ifndef XULA25
`ifndef XULA25
`define FANCY_ICAP_ACCESS
// `define      FANCY_ICAP_ACCESS
`endif
`endif
`endif
`endif
`define FLASH_ACCESS
`define FLASH_ACCESS
// `define SDCARD_ACCESS        // Not built yet ...
`ifdef  XULA25
 
`define SDCARD_ACCESS
 
`endif
//
//
 
 
 
 
//
//
// Configuration question #2
// Configuration question #2
Line 71... Line 73...
// `define      FLASH_SCOPE
// `define      FLASH_SCOPE
`ifndef FLASH_SCOPE
`ifndef FLASH_SCOPE
// `define      WBUS_SCOPE // Occupies the FLASH_SCOPE location, so both cannot be active
// `define      WBUS_SCOPE // Occupies the FLASH_SCOPE location, so both cannot be active
`endif
`endif
//
//
// Position #2: The ICAP configuration scope
// Position #2: The ICAP configuration scope, could also be the SDCard scope
 
// depending on how we configure ourselves here
//
//
 
`ifdef  XULA25
`ifdef  FANCY_ICAP_ACCESS
`ifdef  FANCY_ICAP_ACCESS
`define CFG_SCOPE // Only defined if we have the access ...
`define CFG_SCOPE // Only defined if we have the access ...
 
`else
 
`ifdef  SDCARD_ACCESS
 
`define SDCARD_SCOPE
 
`endif
 
`endif
`endif
`endif
//
//
// Position #3: The SDRAM scope
// Position #3: The SDRAM scope / UART scope (never both)
//
//
`define SDRAM_SCOPE
// `define      SDRAM_SCOPE
 
// `define      UART_SCOPE
//
//
// Position #4: The Zip CPU scope
// Position #4: The Zip CPU scope
//
//
`ifdef  XULA25
`ifdef  XULA25
// `define      ZIP_SCOPE
// `define      ZIP_SCOPE
Line 183... Line 193...
        wire    [31:0]   zip_addr, zip_data;
        wire    [31:0]   zip_addr, zip_data;
        // and then coming from devices
        // and then coming from devices
        wire            zip_ack, zip_stall, zip_err;
        wire            zip_ack, zip_stall, zip_err;
        wire    dwb_we, dwb_stb, dwb_cyc, dwb_ack, dwb_stall, dwb_err;
        wire    dwb_we, dwb_stb, dwb_cyc, dwb_ack, dwb_stall, dwb_err;
        wire    [31:0]   dwb_addr, dwb_odata;
        wire    [31:0]   dwb_addr, dwb_odata;
        wire    [7:0]    w_ints_to_zip_cpu;
        wire    [8:0]    w_ints_to_zip_cpu;
`ifdef  INCLUDE_ZIPCPU
`ifdef  INCLUDE_ZIPCPU
`ifdef  XULA25
`ifdef  XULA25
        wire    [31:0]   zip_debug;
        wire    [31:0]   zip_debug;
        zipsystem #(24'h2000,ZA,8,1,8)
        zipsystem #(24'h2000,ZA,8,1,9)
                zippy(i_clk, 1'b0,
                zippy(i_clk, 1'b0,
                        // Zippys wishbone interface
                        // Zippys wishbone interface
                        zip_cyc, zip_stb, zip_we, w_zip_addr, zip_data,
                        zip_cyc, zip_stb, zip_we, w_zip_addr, zip_data,
                                zip_ack, zip_stall, dwb_idata, zip_err,
                                zip_ack, zip_stall, dwb_idata, zip_err,
                        w_ints_to_zip_cpu, zip_cpu_int,
                        w_ints_to_zip_cpu, zip_cpu_int,
Line 369... Line 379...
        assign  scop_sel = (io_bank)&&(pre_scop);
        assign  scop_sel = (io_bank)&&(pre_scop);
        assign  cfg_sel  =((wb_cyc)&&(wb_addr[31: 6]== 26'h05));
        assign  cfg_sel  =((wb_cyc)&&(wb_addr[31: 6]== 26'h05));
        // zip_sel is not on the bus at this point
        // zip_sel is not on the bus at this point
        assign  mem_sel  =((wb_cyc)&&(wb_addr[31:13]== 19'h01));
        assign  mem_sel  =((wb_cyc)&&(wb_addr[31:13]== 19'h01));
        assign  flash_sel=((wb_cyc)&&(wb_addr[31:18]== 14'h01));
        assign  flash_sel=((wb_cyc)&&(wb_addr[31:18]== 14'h01));
 
`ifdef  SDCARD_ACCESS
 
        assign  sdcard_sel=((wb_cyc)&&(wb_addr[31:2]== 30'h48));
 
`else
        assign  sdcard_sel=1'b0;
        assign  sdcard_sel=1'b0;
 
`endif
        assign  sdram_sel=((wb_cyc)&&(wb_addr[31:23]== 9'h01));
        assign  sdram_sel=((wb_cyc)&&(wb_addr[31:23]== 9'h01));
 
 
        assign  none_sel =((wb_cyc)&&(wb_stb)&&(~
        assign  none_sel =((wb_cyc)&&(wb_stb)&&(~
                        (io_sel
                        (io_sel
                        ||uart_sel
                        ||uart_sel
Line 412... Line 426...
 
 
        always @(posedge i_clk)
        always @(posedge i_clk)
                if (wb_err)
                if (wb_err)
                        bus_err_addr <= wb_addr;
                        bus_err_addr <= wb_addr;
 
 
        wire            flash_interrupt, scop_interrupt,
        wire            flash_interrupt, sdcard_interrupt, scop_interrupt,
                        uart_rx_int, uart_tx_int, pwm_int;
                        uart_rx_int, uart_tx_int, pwm_int;
        // The I/O processor, herein called an ioslave
        // The I/O processor, herein called an ioslave
        ioslave #(NGPO, NGPI) runio(i_clk,
        ioslave #(NGPO, NGPI) runio(i_clk,
                        wb_cyc, (io_sel)&&(wb_stb), wb_we, wb_addr[4:0],
                        wb_cyc, (io_sel)&&(wb_stb), wb_we, wb_addr[4:0],
                                wb_data, io_ack, io_stall, io_data,
                                wb_data, io_ack, io_stall, io_data,
                        i_gpio, o_gpio,
                        i_gpio, o_gpio,
                        bus_err_addr,
                        bus_err_addr,
                        { uart_tx_int, uart_rx_int, pwm_int, scop_interrupt,
                        {
 
                        sdcard_interrupt,
 
                        uart_tx_int, uart_rx_int, pwm_int, scop_interrupt,
                                flash_interrupt,
                                flash_interrupt,
`ifdef  XULA25
`ifdef  XULA25
                                zip_cpu_int
                                zip_cpu_int
`else
`else
                                1'b0
                                1'b0
Line 438... Line 454...
        //
        //
 
 
        //
        //
        //      UART device
        //      UART device
        //
        //
 
        wire    [31:0]   uart_debug;
        uartdev serialport(i_clk, i_rx_uart, o_tx_uart,
        uartdev serialport(i_clk, i_rx_uart, o_tx_uart,
                        wb_cyc, (wb_stb)&&(uart_sel), wb_we,
                        wb_cyc, (wb_stb)&&(uart_sel), wb_we,
                                        { ~wb_addr[2], wb_addr[0]}, wb_data,
                                        { ~wb_addr[2], wb_addr[0]}, wb_data,
                        uart_ack, uart_stall, uart_data,
                        uart_ack, uart_stall, uart_data,
                        uart_rx_int, uart_tx_int);
                        uart_rx_int, uart_tx_int,
 
                        uart_debug);
 
 
        //
        //
        //      PWM (audio) device
        //      PWM (audio) device
        //
        //
        // The audio rate is given by the number of clock ticks between
        // The audio rate is given by the number of clock ticks between
        // samples.  If we are running at 80 MHz, then divide that by the
        // samples.  If we are running at 80 MHz, then divide that by the
        // sample rate to get the first parameter for the PWM device.  The
        // sample rate to get the first parameter for the PWM device.  The
        // second parameter is zero or one, indicating whether or not the
        // second parameter is zero or one, indicating whether or not the
        // audio rate can be adjusted (1), or whether it is fixed within the
        // audio rate can be adjusted (1), or whether it is fixed within the
        // build (0).
        // build (0).
`ifdef  XULA25
        wbpwmaudio      #(16'h270f,0,16) //  8   kHz, fixed audio rate
        wbpwmaudio      #(32'd1814,1)   // 44.1 kHz, user adjustable
 
`else
 
        wbpwmaudio      #(32'h10000,0)   //  8   kHz, fixed audio rate
 
`endif
 
                pwmdev(i_clk,
                pwmdev(i_clk,
                        wb_cyc, (wb_stb)&&(pwm_sel), wb_we, wb_addr[0],
                        wb_cyc, (wb_stb)&&(pwm_sel), wb_we, wb_addr[0],
                        wb_data, pwm_ack, pwm_stall, pwm_data, o_pwm, pwm_int);
                        wb_data, pwm_ack, pwm_stall, pwm_data, o_pwm, pwm_int);
 
 
 
 
 
 
        //
        //
        //      FLASH MEMORY CONFIGURATION ACCESS
        //      FLASH MEMORY CONFIGURATION ACCESS
        //
        //
        wire    flash_cs_n, flash_sck, flash_mosi;
        wire    flash_cs_n, flash_sck, flash_mosi;
 
        wire    spi_user, sdcard_grant, flash_grant;
`ifdef  FLASH_ACCESS
`ifdef  FLASH_ACCESS
        wbspiflash      flashmem(i_clk,
        wbspiflash      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[17:0], wb_data,
                        wb_addr[17:0], wb_data,
                flash_ack, flash_stall, flash_data,
                flash_ack, flash_stall, flash_data,
                flash_sck, flash_cs_n, o_sf_cs_n, flash_mosi, i_spi_miso,
                flash_sck, flash_cs_n, o_sf_cs_n, flash_mosi, i_spi_miso,
                flash_interrupt);
                flash_interrupt, flash_grant);
`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_cyc)&&(wb_stb)&&((flash_sel)||(flctl_sel));
                r_flash_ack <= (wb_cyc)&&(wb_stb)&&((flash_sel)||(flctl_sel));
Line 489... Line 504...
        assign  flash_interrupt = 1'b0;
        assign  flash_interrupt = 1'b0;
 
 
        assign  flash_cs_n = 1'b1;
        assign  flash_cs_n = 1'b1;
        assign  flash_sck  = 1'b1;
        assign  flash_sck  = 1'b1;
        assign  flash_mosi = 1'b1;
        assign  flash_mosi = 1'b1;
 
 
        This is an error
 
`endif
`endif
 
 
 
        //
 
        //      SDCARD ACCESS
 
        //
 
        wire    sdcard_cs_n, sdcard_sck, sdcard_mosi;
 
        wire    [31:0]   sdspi_scope;
 
`ifdef  SDCARD_ACCESS
 
        sdspi   sdcard_controller(i_clk,
 
                // Wishbone interface
 
                wb_cyc, (wb_stb)&&(sdcard_sel), wb_we, wb_addr[1:0], wb_data,
 
                //      return
 
                        sdcard_ack, sdcard_stall, sdcard_data,
 
                // SPI interface
 
                sdcard_cs_n, sdcard_sck, sdcard_mosi, i_spi_miso,
 
                sdcard_interrupt, sdcard_grant, sdspi_scope);
 
`else
 
        reg     r_sdcard_ack;
 
        initial r_sdcard_ack = 1'b0;
 
        always @(posedge i_clk)
 
                r_sdcard_ack <= (wb_cyc)&&(wb_stb)&&(sdcard_sel);
 
        assign  sdcard_stall = 1'b0;
 
        assign  sdcard_ack = r_sdcard_ack;
 
        assign  sdcard_data = 32'h0000;
 
        assign  sdcard_interrupt= 1'b0;
 
`endif  // SDCARD_ACCESS
 
 
 
 
`ifdef  FLASH_ACCESS
`ifdef  FLASH_ACCESS
`ifdef  SDCARD_ACCESS
`ifdef  SDCARD_ACCESS
        spiarbiter      spichk(i_clk,
        spiarbiter      spichk(i_clk,
 
                // Channel zero
                flash_cs_n, flash_sck, flash_mosi,
                flash_cs_n, flash_sck, flash_mosi,
 
                // Channel one
                sdcard_cs_n, sdcard_sck, sdcard_mosi,
                sdcard_cs_n, sdcard_sck, sdcard_mosi,
                o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi);
                o_sf_cs_n, o_sd_cs_n, o_spi_sck, o_spi_mosi,
        This is an error
                spi_user);
 
        assign  sdcard_grant =  spi_user;
 
        assign  flash_grant  = ~spi_user;
`else
`else
        // Flash access, but no SD card access
        // Flash access, but no SD card access
        assign  o_sf_cs_n  = flash_cs_n;
        assign  o_sf_cs_n  = flash_cs_n;
        assign  o_sd_cs_n  = 1'b1;
        assign  o_sd_cs_n  = 1'b1;
        assign  o_spi_sck  = flash_sck;
        assign  o_spi_sck  = flash_sck;
        assign  o_spi_mosi = flash_mosi;
        assign  o_spi_mosi = flash_mosi;
 
        assign  spi_user = 1'b0;
`endif // SDCARD_ACCESS && FLASH_ACCESS
`endif // SDCARD_ACCESS && FLASH_ACCESS
`else // FLASH_ACCESS
`else // FLASH_ACCESS
`ifdef  SDCARD_ACCESS
`ifdef  SDCARD_ACCESS
        // SDCard access, but no flash access
        // SDCard access, but no flash access
        assign  o_sf_cs_n  = 1'b1;
        assign  o_sf_cs_n  = 1'b1;
        assign  o_sd_cs_n  = sdcard_cs_n;
        assign  o_sd_cs_n  = sdcard_cs_n;
        assign  o_spi_sck  = sdcard_sck;
        assign  o_spi_sck  = sdcard_sck;
        assign  o_spi_mosi = sdcard_mosi;
        assign  o_spi_mosi = sdcard_mosi;
 
        assign  spi_user = 1'b1;
`else
`else
        // No SPI access ...
        // No SPI access ...
        assign  o_sf_cs_n  = 1'b1;
        assign  o_sf_cs_n  = 1'b1;
        assign  o_sd_cs_n  = 1'b1;
        assign  o_sd_cs_n  = 1'b1;
        assign  o_spi_sck  = 1'b1;
        assign  o_spi_sck  = 1'b1;
        assign  o_spi_mosi = 1'b1;
        assign  o_spi_mosi = 1'b1;
 
        assign  spi_user = 1'b0;
`endif // SDCARD_ACCESS, w/o FLASH_ACCESS
`endif // SDCARD_ACCESS, w/o FLASH_ACCESS
`endif // !FLASH_ACCESS
`endif // !FLASH_ACCESS
 
 
 
 
        //
        //
Line 648... Line 694...
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01)),
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01)),
                                wb_we, wb_addr[0], wb_data,
                                wb_we, wb_addr[0], wb_data,
                        scop_cfg_ack, scop_cfg_stall, scop_cfg_data,
                        scop_cfg_ack, scop_cfg_stall, scop_cfg_data,
                scop_cfg_interrupt);
                scop_cfg_interrupt);
`else
`else
 
`ifdef  SDCARD_SCOPE
 
        wire            scop_sd_trigger, scop_sd_ce;
 
        assign  scop_sd_trigger = (wb_cyc)&&(wb_stb)&&(sdcard_sel)&&(wb_we);
 
        assign  scop_sd_ce = 1'b1; // sdspi_scope[31];
 
        wbscope #(5'h9) sdspiscope(i_clk, scop_sd_ce,
 
                        scop_sd_trigger, sdspi_scope,
 
                // Wishbone interface
 
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01)),
 
                        wb_we, wb_addr[0], wb_data,
 
                scop_cfg_ack, scop_cfg_stall, scop_cfg_data,scop_cfg_interrupt);
 
`else
        assign  scop_cfg_data = 32'h00;
        assign  scop_cfg_data = 32'h00;
        assign  scop_cfg_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01);
        assign  scop_cfg_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b01);
        assign  scop_cfg_stall = 1'b0;
        assign  scop_cfg_stall = 1'b0;
        assign  scop_cfg_interrupt = 1'b0;
        assign  scop_cfg_interrupt = 1'b0;
`endif
`endif
 
`endif
 
 
        wire    [31:0]   scop_ram_data;
        wire    [31:0]   scop_two_data;
        wire            scop_ram_ack, scop_ram_stall, scop_ram_interrupt;
        wire            scop_two_ack, scop_two_stall, scop_two_interrupt;
`ifdef  SDRAM_SCOPE
`ifdef  SDRAM_SCOPE
        wire            sdram_trigger;
        wire            sdram_trigger;
        assign  sdram_trigger = sdram_debug[18]; // sdram_sel;
        assign  sdram_trigger = sdram_debug[18]; // sdram_sel;
 
 
        wbscope #(5'hb) sdramscope(i_clk, 1'b1, sdram_trigger,
        wbscope #(5'hb) sdramscope(i_clk, 1'b1, sdram_trigger,
                        sdram_debug,
                        sdram_debug,
                        //{ sdram_trigger, wb_data[30:0] },
                        //{ sdram_trigger, wb_data[30:0] },
                // Wishbone interface
                // Wishbone interface
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10)), wb_we, wb_addr[0],
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10)), wb_we, wb_addr[0],
                        wb_data,
                        wb_data,
                        scop_ram_ack, scop_ram_stall, scop_ram_data,
                        scop_two_ack, scop_two_stall, scop_two_data,
                scop_ram_interrupt);
                scop_two_interrupt);
`else
`else
        assign  scop_ram_data = 32'h00;
`ifdef  UART_SCOPE
        assign  scop_ram_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10);
        wire            uart_trigger;
        assign  scop_ram_stall = 1'b0;
        assign  uart_trigger = uart_debug[31];
        assign  scop_ram_interrupt = 1'b0;
 
 
        // wbscopc #(5'ha) uartscope(i_clk,1'b1, uart_trigger, uart_debug[30:0],
 
        wbscope #(5'ha) uartscope(i_clk, 1'b1, uart_trigger, uart_debug[31:0],
 
                // Wishbone interface
 
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10)), wb_we, wb_addr[0],
 
                        wb_data,
 
                        scop_two_ack, scop_two_stall, scop_two_data,
 
                scop_two_interrupt);
 
`else
 
        assign  scop_two_data = 32'h00;
 
        assign  scop_two_ack  = (wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b10);
 
        assign  scop_two_stall = 1'b0;
 
        assign  scop_two_interrupt = 1'b0;
 
`endif
`endif
`endif
 
 
        wire    [31:0]   scop_zip_data;
        wire    [31:0]   scop_zip_data;
        wire            scop_zip_ack, scop_zip_stall, scop_zip_interrupt;
        wire            scop_zip_ack, scop_zip_stall, scop_zip_interrupt;
`ifdef  ZIP_SCOPE
`ifdef  ZIP_SCOPE
        wire            zip_trigger;
        wire            zip_trigger;
        assign  zip_trigger=(wbu_zip_sel)&&(wbu_we)&&(wbu_stb)&&(~wbu_addr[0]);
        assign  zip_trigger=(wbu_zip_sel)&&(wbu_we)&&(wbu_stb)&&(~wbu_addr[0]);
        wbscope #(5'ha) zipscope(i_clk, 1'b1, zip_trigger,
        wbscope #(5'h9) zipscope(i_clk, 1'b1, zip_trigger,
                        zip_debug,
                        zip_debug,
                // Wishbone interface
                // Wishbone interface
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b11)), wb_we, wb_addr[0],
                i_clk, wb_cyc, ((wb_stb)&&(scop_sel)&&(wb_addr[2:1]==2'b11)), wb_we, wb_addr[0],
                        wb_data,
                        wb_data,
                        scop_zip_ack, scop_zip_stall, scop_zip_data,
                        scop_zip_ack, scop_zip_stall, scop_zip_data,
Line 696... Line 767...
        assign  scop_zip_interrupt = 1'b0;
        assign  scop_zip_interrupt = 1'b0;
`endif
`endif
 
 
 
 
        assign  scop_interrupt = scop_flash_interrupt || scop_cfg_interrupt
        assign  scop_interrupt = scop_flash_interrupt || scop_cfg_interrupt
                                || scop_ram_interrupt || scop_zip_interrupt;
                                || scop_two_interrupt || scop_zip_interrupt;
        assign  scop_ack   = scop_cfg_ack | scop_flash_ack | scop_ram_ack | scop_zip_ack;
        assign  scop_ack   = scop_cfg_ack | scop_flash_ack | scop_two_ack | scop_zip_ack;
        assign  scop_stall = ((~wb_addr[2])?
        assign  scop_stall = ((~wb_addr[2])?
                                ((wb_addr[1])?scop_flash_stall:scop_cfg_stall)
                                ((wb_addr[1])?scop_flash_stall:scop_cfg_stall)
                                : ((wb_addr[1])?scop_ram_stall:scop_zip_stall));
                                : ((wb_addr[1])?scop_two_stall:scop_zip_stall));
        assign  scop_data  = ((scop_cfg_ack)?scop_cfg_data
        assign  scop_data  = ((scop_cfg_ack)?scop_cfg_data
                                : ((scop_flash_ack) ? scop_flash_data
                                : ((scop_flash_ack) ? scop_flash_data
                                : ((scop_ram_ack) ? scop_ram_data
                                : ((scop_two_ack) ? scop_two_data
                                : scop_zip_data)));
                                : scop_zip_data)));
 
 
 
 
        reg     r_sdcard_ack;
 
        initial r_sdcard_ack = 1'b0;
 
        always @(posedge i_clk)
 
                r_sdcard_ack <= (wb_cyc)&&(wb_stb)&&(sdcard_sel);
 
        assign  sdcard_stall = 1'b0;
 
        assign  sdcard_ack = r_sdcard_ack;
 
        assign  sdcard_data = 32'h0000;
 
endmodule
endmodule
 
 
// 0x8684 interrupts ...???
// 0x8684 interrupts ...???
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.