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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [wbicapetwo.v] - Diff between revs 13 and 25

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 13 Rev 25
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
//
// Filename:    wbicapetwo.v
// Filename:    wbicapetwo.v
//
//
// Project:     Wishbone to ICAPE2 interface conversion
// Project:     Wishbone to ICAPE2 interface conversion
//
//
// Purpose:     This routine maps the configuration registers of a 7-series
// Purpose:     This routine maps the configuration registers of a 7-series
//              Xilinx part onto register addresses on a wishbone bus interface
//              Xilinx part onto register addresses on a wishbone bus interface
//              via the ICAPE2 access port to those parts.  The big thing this
//              via the ICAPE2 access port to those parts.  The big thing this
//              captures is the timing and handshaking required to read and
//              captures is the timing and handshaking required to read and
//              write registers from the configuration interface.
//              write registers from the configuration interface.
//
//
//              As an example of what can be done, writing a 32'h00f to
//              As an example of what can be done, writing a 32'h00f to
//              local address 5'h4 sends the IPROG command to the FPGA, causing
//              local address 5'h4 sends the IPROG command to the FPGA, causing
//              it to immediately reconfigure itself.
//              it to immediately reconfigure itself.
//
//
//              As another example, the warm boot start address is located
//              As another example, the warm boot start address is located
//              in register 5'h10.  Writing to this address, followed by
//              in register 5'h10.  Writing to this address, followed by
//              issuing the IPROG command just mentioned will cause the
//              issuing the IPROG command just mentioned will cause the
//              FPGA to configure from that warm boot start address.
//              FPGA to configure from that warm boot start address.
// 
// 
//              For more details on the configuration interface, the registers
//              For more details on the configuration interface, the registers
//              in question, their meanings and what they do, please see
//              in question, their meanings and what they do, please see
//              User's Guide 470, the "7 Series FPGAs Configuration" User
//              User's Guide 470, the "7 Series FPGAs Configuration" User
//              Guide.
//              Guide.
//
//
// Notes:       This module supports both reads and writes from the ICAPE2
// Notes:       This module supports both reads and writes from the ICAPE2
//              interface.  These follow the following pattern.
//              interface.  These follow the following pattern.
//
//
//      For writes:
//      For writes:
//              (Idle)  0xffffffff      (Dummy)
//              (Idle)  0xffffffff      (Dummy)
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0xaa995566      SYNC WORD
//              (CS/W)  0xaa995566      SYNC WORD
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  ...             Write command
//              (CS/W)  ...             Write command
//              (CS/W)  ...             Write value, from Wishbone bus
//              (CS/W)  ...             Write value, from Wishbone bus
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x30008001      Write to CMD register (address 4)
//              (CS/W)  0x30008001      Write to CMD register (address 4)
//              (CS/W)  0x0000000d      DESYNC command
//              (CS/W)  0x0000000d      DESYNC command
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (Idle)
//              (Idle)
//
//
//      and for reads:
//      and for reads:
//              (Idle)  0xffffffff      (Dummy)
//              (Idle)  0xffffffff      (Dummy)
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0xaa995566      SYNC WORD
//              (CS/W)  0xaa995566      SYNC WORD
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  ...             Read command
//              (CS/W)  ...             Read command
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (Idle)  0x20000000      (Idle the interface again, so we can rd)
//              (Idle)  0x20000000      (Idle the interface again, so we can rd)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (CS/R)  0x20000000      (Wait)
//              (Idle)  0x20000000      (Idle the interface before writing)
//              (Idle)  0x20000000      (Idle the interface before writing)
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x30008001      Write to CMD register (address 4)
//              (CS/W)  0x30008001      Write to CMD register (address 4)
//              (CS/W)  0x0000000d      DESYNC command
//              (CS/W)  0x0000000d      DESYNC command
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (CS/W)  0x20000000      NOOP
//              (Idle)
//              (Idle)
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015, Gisselquist Technology, LLC
// Copyright (C) 2015, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
//
`define MBOOT_IDLE      5'h00
`define MBOOT_IDLE      5'h00
`define MBOOT_START     5'h01
`define MBOOT_START     5'h01
`define MBOOT_READ      5'h06
`define MBOOT_READ      5'h06
`define MBOOT_WRITE     5'h0f
`define MBOOT_WRITE     5'h0f
`define MBOOT_DESYNC    5'h11
`define MBOOT_DESYNC    5'h11
module  wbicapetwo(i_clk,
module  wbicapetwo(i_clk,
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
                        o_wb_ack, o_wb_stall, o_wb_data, o_dbg);
                        o_wb_ack, o_wb_stall, o_wb_data, o_dbg);
 
        parameter       LGDIV = 3; /// Log of the clock divide
        input                   i_clk;
        input                   i_clk;
        // Wishbone inputs
        // Wishbone inputs
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
        input                   i_wb_cyc, i_wb_stb, i_wb_we;
        input           [4:0]    i_wb_addr;
        input           [4:0]    i_wb_addr;
        input           [31:0]   i_wb_data;
        input           [31:0]   i_wb_data;
        // Wishbone outputs
        // Wishbone outputs
        output  reg             o_wb_ack, o_wb_stall;
        output  reg             o_wb_ack, o_wb_stall;
        output  reg     [31:0]   o_wb_data;
        output  reg     [31:0]   o_wb_data;
        // Debugging output
        // Debugging output
        output  wire    [31:0]   o_dbg;
        output  wire    [31:0]   o_dbg;
        // ICAPE2 interface signals
        // ICAPE2 interface signals
        //      These are kept internal to this block ...
        //      These are kept internal to this block ...
 
 
        reg             wb_req, r_we;
        reg             wb_req, r_we;
        reg     [31:0]   r_data;
        reg     [31:0]   r_data;
        reg     [4:0]    r_addr;
        reg     [4:0]    r_addr;
 
 
`ifdef  DIVIDE_BY_FOUR
 
        reg     [1:0]    slow_clk_counter;
 
        reg             clk_stb, clk_stall;
        reg             clk_stb, clk_stall;
        wire            slow_clk;
        wire            slow_clk;
 
 
 
        generate
 
        if (LGDIV <= 1)
 
        begin
 
                reg             r_slow_clk;
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
        begin
                slow_clk  <= slow_clk + 2'b01;
                        r_slow_clk  <= (slow_clk + 1'b1);
                // We'll move on the positive edge of the clock, so therefore
                        // We'll move on the positive edge of the clock,
                // clk_stb must be true one clock before that, so we test for
                        // so therefore clk_stb must be true one clock before
                // it one clock before that.
                        // that, so we test for it one clock before that.
                clk_stb   <= (slow_clk_counter == 2'b10);
                        clk_stb   <= (slow_clk == 1'b1);
                // CLK_STALL is set to true two clocks before any cycle that
                        // CLK_STALL is set to true two clocks before any
                // will, by necessity, stall.
                        // cycle that will, by necessity, stall.
                clk_stall <= (slow_clk_counter != 2'b01);
                        clk_stall <= (slow_clk != 1'b0); //True all but 1ckcycle
        end
        end
 
 
        assign  slow_clk = slow_clk_counter[1];
                assign  slow_clk = r_slow_clk;
`else
        end else begin
        reg             slow_clk, clk_stb, clk_stall;
                reg     [(LGDIV-1):0]    slow_clk_counter;
 
 
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
        begin
                slow_clk  <= (slow_clk + 1'b1);
                        slow_clk_counter  <= slow_clk_counter + 1'b1;
                // We'll move on the positive edge of the clock, so therefore
                // We'll move on the positive edge of the clock, so therefore
                // clk_stb must be true one clock before that, so we test for
                        // clk_stb must be true one clock before that, so we test for
                // it one clock before that.
                // it one clock before that.
                clk_stb   <= (slow_clk == 1'b1);
                        clk_stb   <= (slow_clk_counter=={{(LGDIV){1'b1}},1'b0});
                // CLK_STALL is set to true two clocks before any cycle that
                // CLK_STALL is set to true two clocks before any cycle that
                // will, by necessity, stall.
                // will, by necessity, stall.
                clk_stall <= (slow_clk != 1'b0); //True all but one clock
                        clk_stall <= (slow_clk_counter!={{(LGDIV){1'b0}},1'b1});
        end
        end
`endif
 
 
                assign  slow_clk = slow_clk_counter[(LGDIV-1)];
 
        end endgenerate
 
 
        reg     [31:0]   cfg_in;
        reg     [31:0]   cfg_in;
        reg             cfg_cs_n, cfg_rdwrn;
        reg             cfg_cs_n, cfg_rdwrn;
        wire    [31:0]   cfg_out;
        wire    [31:0]   cfg_out;
        reg     [4:0]    state;
        reg     [4:0]    state;
        initial state = `MBOOT_IDLE;
        initial state = `MBOOT_IDLE;
        initial cfg_cs_n = 1'b1;
        initial cfg_cs_n = 1'b1;
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
        begin
                // In general, o_wb_ack is always zero.  The exceptions to this
                // In general, o_wb_ack is always zero.  The exceptions to this
                // will be handled individually below.
                // will be handled individually below.
                o_wb_ack <= 1'b0;
                o_wb_ack <= 1'b0;
                // We can simplify our logic a touch by always setting
                // We can simplify our logic a touch by always setting
                // o_wb_data.  It will only be examined if o_wb_ack
                // o_wb_data.  It will only be examined if o_wb_ack
                // is also true, so this is okay.
                // is also true, so this is okay.
                o_wb_data <= cfg_out;
                o_wb_data <= cfg_out;
 
 
                // Turn any request "off", so that it will not be ack'd, if
                // Turn any request "off", so that it will not be ack'd, if
                // the wb_cyc line is ever lowered.
                // the wb_cyc line is ever lowered.
                wb_req <= wb_req & i_wb_cyc;
                wb_req <= wb_req & i_wb_cyc;
                o_wb_stall <= (state != `MBOOT_IDLE)||(clk_stall);
                o_wb_stall <= (state != `MBOOT_IDLE)||(clk_stall);
                if (clk_stb)
                if (clk_stb)
                begin
                begin
                        state <= state + 5'h01;
                        state <= state + 5'h01;
                        case(state)
                        case(state)
                        `MBOOT_IDLE: begin
                        `MBOOT_IDLE: begin
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_in <= 32'hffffffff; // Dummy word
                                cfg_in <= 32'hffffffff; // Dummy word
 
 
                                state <= `MBOOT_IDLE;
                                state <= `MBOOT_IDLE;
 
 
                                o_wb_ack <= 1'b0;
                                o_wb_ack <= 1'b0;
 
 
                                r_addr <= i_wb_addr;
                                r_addr <= i_wb_addr;
                                r_data <= i_wb_data;
                                r_data <= i_wb_data;
                                r_we   <= i_wb_we;
                                r_we   <= i_wb_we;
                                if(i_wb_stb) // &&(!o_wb_stall)
                                if(i_wb_stb) // &&(!o_wb_stall)
                                begin
                                begin
                                        state <= `MBOOT_START;
                                        state <= `MBOOT_START;
                                        wb_req <= 1'b1;
                                        wb_req <= 1'b1;
                                        //
                                        //
                                        o_wb_ack <= 1'b0;
                                        o_wb_ack <= 1'b0;
                                end end
                                end end
                        `MBOOT_START: begin
                        `MBOOT_START: begin
                                cfg_in <= 32'hffffffff; // NOOP
                                cfg_in <= 32'hffffffff; // NOOP
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                end
                                end
                        5'h02: begin
                        5'h02: begin
                                cfg_cs_n <= 1'b0; // Activate interface
                                cfg_cs_n <= 1'b0; // Activate interface
                                cfg_rdwrn <= 1'b0;
                                cfg_rdwrn <= 1'b0;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h03: begin
                        5'h03: begin
                                cfg_in <= 32'haa995566; // Sync word
                                cfg_in <= 32'haa995566; // Sync word
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h04: begin
                        5'h04: begin
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h05: begin
                        5'h05: begin
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                state <= (r_we) ? `MBOOT_WRITE : `MBOOT_READ;
                                state <= (r_we) ? `MBOOT_WRITE : `MBOOT_READ;
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        `MBOOT_READ: begin
                        `MBOOT_READ: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= { 8'h28, 6'h0, r_addr, 13'h001 };
                                cfg_in <= { 8'h28, 6'h0, r_addr, 13'h001 };
                                end
                                end
                        5'h07: begin
                        5'h07: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h08: begin
                        5'h08: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h09: begin // Idle the interface before the read cycle
                        5'h09: begin // Idle the interface before the read cycle
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h0a: begin // Re-activate the interface and wait 3 cycles
                        5'h0a: begin // Re-activate the interface and wait 3 cycles
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_rdwrn <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h0b: begin // ... still waiting, cycle two
                        5'h0b: begin // ... still waiting, cycle two
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h0c: begin // ... still waiting, cycle three
                        5'h0c: begin // ... still waiting, cycle three
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h0d: begin // ... still waiting, cycle four
                        5'h0d: begin // ... still waiting, cycle four
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h0e: begin // and now our answer is there
                        5'h0e: begin // and now our answer is there
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_rdwrn <= 1'b1;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                //
                                //
                                // Wishbone return
                                // Wishbone return
                                o_wb_ack <= wb_req;
                                o_wb_ack <= wb_req;
                                // o_wb_data <= cfg_out; // Independent of state
                                // o_wb_data <= cfg_out; // Independent of state
                                wb_req <= 1'b0;
                                wb_req <= 1'b0;
                                //
                                //
                                state <= `MBOOT_DESYNC;
                                state <= `MBOOT_DESYNC;
                                end
                                end
                        `MBOOT_WRITE: begin
                        `MBOOT_WRITE: begin
                                // Issue a write command to the given address
                                // Issue a write command to the given address
                                cfg_in <= { 8'h30, 6'h0, r_addr, 13'h001 };
                                cfg_in <= { 8'h30, 6'h0, r_addr, 13'h001 };
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        5'h10: begin
                        5'h10: begin
                                cfg_in <= r_data;       // Write the value
                                cfg_in <= r_data;       // Write the value
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                end
                                end
                        `MBOOT_DESYNC: begin
                        `MBOOT_DESYNC: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_rdwrn <= 1'b0;
                                cfg_rdwrn <= 1'b0;
                                cfg_in <= 32'h20000000; // 1st NOOP
                                cfg_in <= 32'h20000000; // 1st NOOP
                                end
                                end
                        5'h12: begin
                        5'h12: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h20000000; // 2nd NOOP
                                cfg_in <= 32'h20000000; // 2nd NOOP
                                end
                                end
                        5'h13: begin
                        5'h13: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h30008001; // Write to CMD register
                                cfg_in <= 32'h30008001; // Write to CMD register
                                end
                                end
                        5'h14: begin
                        5'h14: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h0000000d; // DESYNC command
                                cfg_in <= 32'h0000000d; // DESYNC command
                                end
                                end
                        5'h15: begin
                        5'h15: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h16: begin
                        5'h16: begin
                                cfg_cs_n <= 1'b0;
                                cfg_cs_n <= 1'b0;
                                cfg_in <= 32'h20000000; // NOOP
                                cfg_in <= 32'h20000000; // NOOP
                                end
                                end
                        5'h17: begin
                        5'h17: begin
                                // Acknowledge the bus transaction, it is now complete
                                // Acknowledge the bus transaction, it is now complete
                                o_wb_ack <= wb_req;
                                o_wb_ack <= wb_req;
                                wb_req <= 1'b0;
                                wb_req <= 1'b0;
                                //
                                //
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                cfg_rdwrn <= 1'b0;
                                cfg_rdwrn <= 1'b0;
                                cfg_in <= 32'hffffffff; // DUMMY
                                cfg_in <= 32'hffffffff; // DUMMY
                                //
                                //
                                state <= `MBOOT_IDLE;
                                state <= `MBOOT_IDLE;
                                end
                                end
                        default: begin
                        default: begin
                                wb_req <= 1'b0;
                                wb_req <= 1'b0;
                                cfg_cs_n <= 1'b1;
                                cfg_cs_n <= 1'b1;
                                cfg_rdwrn <= 1'b0;
                                cfg_rdwrn <= 1'b0;
                                state <= `MBOOT_IDLE;
                                state <= `MBOOT_IDLE;
                                cfg_in <= 32'hffffffff; // DUMMY WORD
                                cfg_in <= 32'hffffffff; // DUMMY WORD
                                end
                                end
                        endcase
                        endcase
                end
                end
        end
        end
 
 
        genvar  k;
        genvar  k;
        //
        //
        // The data registers to the ICAPE2 interface are bit swapped within
        // The data registers to the ICAPE2 interface are bit swapped within
        // each byte.  Thus, in order to read from or write to the interface,
        // each byte.  Thus, in order to read from or write to the interface,
        // we need to bit swap the bits in each byte.  These next lines
        // we need to bit swap the bits in each byte.  These next lines
        // accomplish that for both the input and output ports.
        // accomplish that for both the input and output ports.
        //
        //
        wire    [31:0]   bit_swapped_cfg_in;
        wire    [31:0]   bit_swapped_cfg_in;
        generate
        generate
        for(k=0; k<8; k=k+1)
        for(k=0; k<8; k=k+1)
        begin
        begin
                assign bit_swapped_cfg_in[   k] = cfg_in[   7-k];
                assign bit_swapped_cfg_in[   k] = cfg_in[   7-k];
                assign bit_swapped_cfg_in[ 8+k] = cfg_in[ 8+7-k];
                assign bit_swapped_cfg_in[ 8+k] = cfg_in[ 8+7-k];
                assign bit_swapped_cfg_in[16+k] = cfg_in[16+7-k];
                assign bit_swapped_cfg_in[16+k] = cfg_in[16+7-k];
                assign bit_swapped_cfg_in[24+k] = cfg_in[24+7-k];
                assign bit_swapped_cfg_in[24+k] = cfg_in[24+7-k];
        end endgenerate
        end endgenerate
 
 
        wire    [31:0]   bit_swapped_cfg_out;
        wire    [31:0]   bit_swapped_cfg_out;
        generate
        generate
        for(k=0; k<8; k=k+1)
        for(k=0; k<8; k=k+1)
        begin
        begin
                assign cfg_out[   k] = bit_swapped_cfg_out[   7-k];
                assign cfg_out[   k] = bit_swapped_cfg_out[   7-k];
                assign cfg_out[ 8+k] = bit_swapped_cfg_out[ 8+7-k];
                assign cfg_out[ 8+k] = bit_swapped_cfg_out[ 8+7-k];
                assign cfg_out[16+k] = bit_swapped_cfg_out[16+7-k];
                assign cfg_out[16+k] = bit_swapped_cfg_out[16+7-k];
                assign cfg_out[24+k] = bit_swapped_cfg_out[24+7-k];
                assign cfg_out[24+k] = bit_swapped_cfg_out[24+7-k];
        end endgenerate
        end endgenerate
 
 
        ICAPE2 #(.ICAP_WIDTH("X32")) reconfig(.CLK(slow_clk),
        ICAPE2 #(.ICAP_WIDTH("X32")) reconfig(.CLK(slow_clk),
                        .CSIB(cfg_cs_n), .RDWRB(cfg_rdwrn),
                        .CSIB(cfg_cs_n), .RDWRB(cfg_rdwrn),
                        .I(bit_swapped_cfg_in), .O(bit_swapped_cfg_out));
                        .I(bit_swapped_cfg_in), .O(bit_swapped_cfg_out));
 
 
        assign o_dbg = {
        assign o_dbg = {
`ifdef  DIVIDE_BY_FOUR
`ifdef  DIVIDE_BY_FOUR
                slow_clk_counter, clk_stb, clk_stall,
                slow_clk_counter, clk_stb, clk_stall,
`else
`else
                1'b0, slow_clk, clk_stb, clk_stall,
                1'b0, slow_clk, clk_stb, clk_stall,
`endif
`endif
                i_wb_stb, o_wb_ack, cfg_cs_n, cfg_rdwrn,
                i_wb_stb, o_wb_ack, cfg_cs_n, cfg_rdwrn,
                o_wb_stall, state, 2'h0,
                o_wb_stall, state, 2'h0,
                        cfg_in[7:0],
                        cfg_in[7:0],
                        cfg_out[7:0] };
                        cfg_out[7:0] };
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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