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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_wb_biu.v] - Diff between revs 358 and 364

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

Rev 358 Rev 364
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  OR1200's WISHBONE BIU                                       ////
////  OR1200's WISHBONE BIU                                       ////
////                                                              ////
////                                                              ////
////  This file is part of the OpenRISC 1200 project              ////
////  This file is part of the OpenRISC 1200 project              ////
////  http://opencores.org/project,or1k                           ////
////  http://opencores.org/project,or1k                           ////
////                                                              ////
////                                                              ////
////  Description                                                 ////
////  Description                                                 ////
////  Implements WISHBONE interface                               ////
////  Implements WISHBONE interface                               ////
////                                                              ////
////                                                              ////
////  To Do:                                                      ////
////  To Do:                                                      ////
////   - if biu_cyc/stb are deasserted and wb_ack_i is asserted   ////
////   - if biu_cyc/stb are deasserted and wb_ack_i is asserted   ////
////   and this happens even before aborted_r is asssrted,        ////
////   and this happens even before aborted_r is asssrted,        ////
////   wb_ack_i will be delivered even though transfer is         ////
////   wb_ack_i will be delivered even though transfer is         ////
////   internally considered already aborted. However most        ////
////   internally considered already aborted. However most        ////
////   wb_ack_i are externally registered and delayed. Normally   ////
////   wb_ack_i are externally registered and delayed. Normally   ////
////   this shouldn't cause any problems.                         ////
////   this shouldn't cause any problems.                         ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Damjan Lampret, lampret@opencores.org                 ////
////      - Damjan Lampret, lampret@opencores.org                 ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
//
//
// $Log: or1200_wb_biu.v,v $
// $Log: or1200_wb_biu.v,v $
// Revision 2.0  2010/06/30 11:00:00  ORSoC
// Revision 2.0  2010/06/30 11:00:00  ORSoC
// Major update: 
// Major update: 
// Structure reordered and bugs fixed. 
// Structure reordered and bugs fixed. 
//
//
 
 
// synopsys translate_off
// synopsys translate_off
`include "timescale.v"
`include "timescale.v"
// synopsys translate_on
// synopsys translate_on
`include "or1200_defines.v"
`include "or1200_defines.v"
 
 
module or1200_wb_biu(
module or1200_wb_biu(
                     // RISC clock, reset and clock control
                     // RISC clock, reset and clock control
                     clk, rst, clmode,
                     clk, rst, clmode,
 
 
                     // WISHBONE interface
                     // WISHBONE interface
                     wb_clk_i, wb_rst_i, wb_ack_i, wb_err_i, wb_rty_i, wb_dat_i,
                     wb_clk_i, wb_rst_i, wb_ack_i, wb_err_i, wb_rty_i, wb_dat_i,
                     wb_cyc_o, wb_adr_o, wb_stb_o, wb_we_o, wb_sel_o, wb_dat_o,
                     wb_cyc_o, wb_adr_o, wb_stb_o, wb_we_o, wb_sel_o, wb_dat_o,
`ifdef OR1200_WB_CAB
`ifdef OR1200_WB_CAB
                     wb_cab_o,
                     wb_cab_o,
`endif
`endif
`ifdef OR1200_WB_B3
`ifdef OR1200_WB_B3
                     wb_cti_o, wb_bte_o,
                     wb_cti_o, wb_bte_o,
`endif
`endif
 
 
                     // Internal RISC bus
                     // Internal RISC bus
                     biu_dat_i, biu_adr_i, biu_cyc_i, biu_stb_i, biu_we_i, biu_sel_i, biu_cab_i,
                     biu_dat_i, biu_adr_i, biu_cyc_i, biu_stb_i, biu_we_i, biu_sel_i, biu_cab_i,
                     biu_dat_o, biu_ack_o, biu_err_o
                     biu_dat_o, biu_ack_o, biu_err_o
                     );
                     );
 
 
   parameter dw = `OR1200_OPERAND_WIDTH;
   parameter dw = `OR1200_OPERAND_WIDTH;
   parameter aw = `OR1200_OPERAND_WIDTH;
   parameter aw = `OR1200_OPERAND_WIDTH;
 
 
   //
   //
   // RISC clock, reset and clock control
   // RISC clock, reset and clock control
   //
   //
   input                                clk;            // RISC clock
   input                                clk;            // RISC clock
   input                                rst;            // RISC reset
   input                                rst;            // RISC reset
   input [1:0]                           clmode;         // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
   input [1:0]                           clmode;         // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
 
 
   //
   //
   // WISHBONE interface
   // WISHBONE interface
   //
   //
   input                                wb_clk_i;       // clock input
   input                                wb_clk_i;       // clock input
   input                                wb_rst_i;       // reset input
   input                                wb_rst_i;       // reset input
   input                                wb_ack_i;       // normal termination
   input                                wb_ack_i;       // normal termination
   input                                wb_err_i;       // termination w/ error
   input                                wb_err_i;       // termination w/ error
   input                                wb_rty_i;       // termination w/ retry
   input                                wb_rty_i;       // termination w/ retry
   input [dw-1:0]                        wb_dat_i;       // input data bus
   input [dw-1:0]                        wb_dat_i;       // input data bus
   output                               wb_cyc_o;       // cycle valid output
   output                               wb_cyc_o;       // cycle valid output
   output [aw-1:0]                       wb_adr_o;       // address bus outputs
   output [aw-1:0]                       wb_adr_o;       // address bus outputs
   output                               wb_stb_o;       // strobe output
   output                               wb_stb_o;       // strobe output
   output                               wb_we_o;        // indicates write transfer
   output                               wb_we_o;        // indicates write transfer
   output [3:0]                  wb_sel_o;       // byte select outputs
   output [3:0]                  wb_sel_o;       // byte select outputs
   output [dw-1:0]                       wb_dat_o;       // output data bus
   output [dw-1:0]                       wb_dat_o;       // output data bus
`ifdef OR1200_WB_CAB
`ifdef OR1200_WB_CAB
   output                               wb_cab_o;       // consecutive address burst
   output                               wb_cab_o;       // consecutive address burst
`endif
`endif
`ifdef OR1200_WB_B3
`ifdef OR1200_WB_B3
   output [2:0]                  wb_cti_o;       // cycle type identifier
   output [2:0]                  wb_cti_o;       // cycle type identifier
   output [1:0]                  wb_bte_o;       // burst type extension
   output [1:0]                  wb_bte_o;       // burst type extension
`endif
`endif
 
 
   //
   //
   // Internal RISC interface
   // Internal RISC interface
   //
   //
   input [dw-1:0]                        biu_dat_i;      // input data bus
   input [dw-1:0]                        biu_dat_i;      // input data bus
   input [aw-1:0]                        biu_adr_i;      // address bus
   input [aw-1:0]                        biu_adr_i;      // address bus
   input                                biu_cyc_i;      // WB cycle
   input                                biu_cyc_i;      // WB cycle
   input                                biu_stb_i;      // WB strobe
   input                                biu_stb_i;      // WB strobe
   input                                biu_we_i;       // WB write enable
   input                                biu_we_i;       // WB write enable
   input                                biu_cab_i;      // CAB input
   input                                biu_cab_i;      // CAB input
   input [3:0]                           biu_sel_i;      // byte selects
   input [3:0]                           biu_sel_i;      // byte selects
   output [31:0]                         biu_dat_o;      // output data bus
   output [31:0]                         biu_dat_o;      // output data bus
   output                               biu_ack_o;      // ack output
   output                               biu_ack_o;      // ack output
   output                               biu_err_o;      // err output
   output                               biu_err_o;      // err output
 
 
   //
   //
   // Registers
   // Registers
   //
   //
   wire                                 wb_ack;         // normal termination
   wire                                 wb_ack;         // normal termination
   reg [aw-1:0]                  wb_adr_o;       // address bus outputs
   reg [aw-1:0]                  wb_adr_o;       // address bus outputs
   reg                                  wb_cyc_o;       // cycle output
   reg                                  wb_cyc_o;       // cycle output
   reg                                  wb_stb_o;       // strobe output
   reg                                  wb_stb_o;       // strobe output
   reg                                  wb_we_o;        // indicates write transfer
   reg                                  wb_we_o;        // indicates write transfer
   reg [3:0]                             wb_sel_o;       // byte select outputs
   reg [3:0]                             wb_sel_o;       // byte select outputs
`ifdef OR1200_WB_CAB
`ifdef OR1200_WB_CAB
   reg                                  wb_cab_o;       // CAB output
   reg                                  wb_cab_o;       // CAB output
`endif
`endif
`ifdef OR1200_WB_B3
`ifdef OR1200_WB_B3
   reg [2:0]                             wb_cti_o;       // cycle type identifier
   reg [2:0]                             wb_cti_o;       // cycle type identifier
   reg [1:0]                             wb_bte_o;       // burst type extension
   reg [1:0]                             wb_bte_o;       // burst type extension
`endif
`endif
`ifdef OR1200_NO_DC
`ifdef OR1200_NO_DC
   reg [dw-1:0]                  wb_dat_o;       // output data bus
   reg [dw-1:0]                  wb_dat_o;       // output data bus
`else
`else
   assign wb_dat_o = biu_dat_i;    // No register on this - straight from DCRAM
   assign wb_dat_o = biu_dat_i;    // No register on this - straight from DCRAM
`endif
`endif
 
 
`ifdef OR1200_WB_RETRY
`ifdef OR1200_WB_RETRY
   reg [`OR1200_WB_RETRY-1:0]            retry_cnt;      // Retry counter
   reg [`OR1200_WB_RETRY-1:0]            retry_cnt;      // Retry counter
`else
`else
   wire                                 retry_cnt;
   wire                                 retry_cnt;
   assign retry_cnt = 1'b0;
   assign retry_cnt = 1'b0;
`endif
`endif
`ifdef OR1200_WB_B3
`ifdef OR1200_WB_B3
   reg [1:0]                             burst_len;      // burst counter
   reg [1:0]                             burst_len;      // burst counter
`endif
`endif
 
 
   reg                                  biu_stb_reg;    // WB strobe
   reg                                  biu_stb_reg;    // WB strobe
   wire                                 biu_stb;        // WB strobe
   wire                                 biu_stb;        // WB strobe
   reg                                  wb_cyc_nxt;     // next WB cycle value
   reg                                  wb_cyc_nxt;     // next WB cycle value
   reg                                  wb_stb_nxt;     // next WB strobe value
   reg                                  wb_stb_nxt;     // next WB strobe value
   reg [2:0]                             wb_cti_nxt;     // next cycle type identifier value
   reg [2:0]                             wb_cti_nxt;     // next cycle type identifier value
 
 
   reg                                  wb_ack_cnt;     // WB ack toggle counter
   reg                                  wb_ack_cnt;     // WB ack toggle counter
   reg                                  wb_err_cnt;     // WB err toggle counter
   reg                                  wb_err_cnt;     // WB err toggle counter
   reg                                  wb_rty_cnt;     // WB rty toggle counter
   reg                                  wb_rty_cnt;     // WB rty toggle counter
   reg                                  biu_ack_cnt;    // BIU ack toggle counter
   reg                                  biu_ack_cnt;    // BIU ack toggle counter
   reg                                  biu_err_cnt;    // BIU err toggle counter
   reg                                  biu_err_cnt;    // BIU err toggle counter
   reg                                  biu_rty_cnt;    // BIU rty toggle counter
   reg                                  biu_rty_cnt;    // BIU rty toggle counter
   wire                                 biu_rty;        // BIU rty indicator
   wire                                 biu_rty;        // BIU rty indicator
 
 
   reg [1:0]                             wb_fsm_state_cur;       // WB FSM - surrent state
   reg [1:0]                             wb_fsm_state_cur;       // WB FSM - surrent state
   reg [1:0]                             wb_fsm_state_nxt;       // WB FSM - next state
   reg [1:0]                             wb_fsm_state_nxt;       // WB FSM - next state
   wire [1:0]                            wb_fsm_idle     = 2'h0; // WB FSM state - IDLE
   wire [1:0]                            wb_fsm_idle     = 2'h0; // WB FSM state - IDLE
   wire [1:0]                            wb_fsm_trans    = 2'h1; // WB FSM state - normal TRANSFER
   wire [1:0]                            wb_fsm_trans    = 2'h1; // WB FSM state - normal TRANSFER
   wire [1:0]                            wb_fsm_last     = 2'h2; // EB FSM state - LAST transfer
   wire [1:0]                            wb_fsm_last     = 2'h2; // EB FSM state - LAST transfer
 
 
   //
   //
   // WISHBONE I/F <-> Internal RISC I/F conversion
   // WISHBONE I/F <-> Internal RISC I/F conversion
   //
   //
   //assign wb_ack = wb_ack_i;
   //assign wb_ack = wb_ack_i;
   assign wb_ack = wb_ack_i & !wb_err_i & !wb_rty_i;
   assign wb_ack = wb_ack_i & !wb_err_i & !wb_rty_i;
 
 
   //
   //
   // WB FSM - register part
   // WB FSM - register part
   // 
   // 
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
      if (wb_rst_i == `OR1200_RST_VALUE)
      if (wb_rst_i == `OR1200_RST_VALUE)
        wb_fsm_state_cur <=  wb_fsm_idle;
        wb_fsm_state_cur <=  wb_fsm_idle;
      else
      else
        wb_fsm_state_cur <=  wb_fsm_state_nxt;
        wb_fsm_state_cur <=  wb_fsm_state_nxt;
   end
   end
 
 
   //
   //
   // WB burst tength counter
   // WB burst tength counter
   // 
   // 
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
         burst_len <=  2'h0;
         burst_len <=  2'h0;
      end
      end
      else begin
      else begin
         // burst counter
         // burst counter
         if (wb_fsm_state_cur == wb_fsm_idle)
         if (wb_fsm_state_cur == wb_fsm_idle)
           burst_len <=  2'h2;
           burst_len <=  2'h2;
         else if (wb_stb_o & wb_ack)
         else if (wb_stb_o & wb_ack)
           burst_len <=  burst_len - 1'b1;
           burst_len <=  burst_len - 1'b1;
      end
      end
   end
   end
 
 
   // 
   // 
   // WB FSM - combinatorial part
   // WB FSM - combinatorial part
   // 
   // 
   always @(wb_fsm_state_cur or burst_len or wb_err_i or wb_rty_i or wb_ack or
   always @(wb_fsm_state_cur or burst_len or wb_err_i or wb_rty_i or wb_ack or
            wb_cti_o or wb_sel_o or wb_stb_o or wb_we_o or biu_cyc_i or
            wb_cti_o or wb_sel_o or wb_stb_o or wb_we_o or biu_cyc_i or
            biu_stb or biu_cab_i or biu_sel_i or biu_we_i) begin
            biu_stb or biu_cab_i or biu_sel_i or biu_we_i) begin
      // States of WISHBONE Finite State Machine
      // States of WISHBONE Finite State Machine
      case(wb_fsm_state_cur)
      case(wb_fsm_state_cur)
        // IDLE 
        // IDLE 
        wb_fsm_idle : begin
        wb_fsm_idle : begin
           wb_cyc_nxt = biu_cyc_i & biu_stb;
           wb_cyc_nxt = biu_cyc_i & biu_stb;
           wb_stb_nxt = biu_cyc_i & biu_stb;
           wb_stb_nxt = biu_cyc_i & biu_stb;
           wb_cti_nxt = {!biu_cab_i, 1'b1, !biu_cab_i};
           wb_cti_nxt = {!biu_cab_i, 1'b1, !biu_cab_i};
           if (biu_cyc_i & biu_stb)
           if (biu_cyc_i & biu_stb)
             wb_fsm_state_nxt = wb_fsm_trans;
             wb_fsm_state_nxt = wb_fsm_trans;
           else
           else
             wb_fsm_state_nxt = wb_fsm_idle;
             wb_fsm_state_nxt = wb_fsm_idle;
        end
        end
        // normal TRANSFER
        // normal TRANSFER
        wb_fsm_trans : begin
        wb_fsm_trans : begin
           wb_cyc_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
           wb_cyc_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
                        !(wb_ack & wb_cti_o == 3'b111);
                        !(wb_ack & wb_cti_o == 3'b111);
 
 
           wb_stb_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i & !wb_ack |
           wb_stb_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i & !wb_ack |
                        !wb_err_i & !wb_rty_i & wb_cti_o == 3'b010 /*& !wb_we_o -- Removed to add burst write, JPB*/;
                        !wb_err_i & !wb_rty_i & wb_cti_o == 3'b010 /*& !wb_we_o -- Removed to add burst write, JPB*/;
 
 
           wb_cti_nxt[2] = wb_stb_o & wb_ack & burst_len == 'h0 | wb_cti_o[2];
           wb_cti_nxt[2] = wb_stb_o & wb_ack & burst_len == 'h0 | wb_cti_o[2];
           wb_cti_nxt[1] = 1'b1  ;
           wb_cti_nxt[1] = 1'b1  ;
           wb_cti_nxt[0] = wb_stb_o & wb_ack & burst_len == 'h0 | wb_cti_o[0];
           wb_cti_nxt[0] = wb_stb_o & wb_ack & burst_len == 'h0 | wb_cti_o[0];
 
 
           //if ((!biu_cyc_i | !biu_stb | !biu_cab_i) & wb_cti_o == 3'b010  | 
           //if ((!biu_cyc_i | !biu_stb | !biu_cab_i) & wb_cti_o == 3'b010  | 
           //     biu_sel_i != wb_sel_o | biu_we_i != wb_we_o)
           //     biu_sel_i != wb_sel_o | biu_we_i != wb_we_o)
 
 
           if ((!biu_cyc_i | !biu_stb | !biu_cab_i | biu_sel_i != wb_sel_o |
           if ((!biu_cyc_i | !biu_stb | !biu_cab_i | biu_sel_i != wb_sel_o |
                biu_we_i != wb_we_o) & wb_cti_o == 3'b010)
                biu_we_i != wb_we_o) & wb_cti_o == 3'b010)
             wb_fsm_state_nxt = wb_fsm_last;
             wb_fsm_state_nxt = wb_fsm_last;
           else if ((wb_err_i | wb_rty_i | wb_ack & wb_cti_o==3'b111) &
           else if ((wb_err_i | wb_rty_i | wb_ack & wb_cti_o==3'b111) &
                    wb_stb_o)
                    wb_stb_o)
             wb_fsm_state_nxt = wb_fsm_idle;
             wb_fsm_state_nxt = wb_fsm_idle;
           else
           else
             wb_fsm_state_nxt = wb_fsm_trans;
             wb_fsm_state_nxt = wb_fsm_trans;
        end
        end
        // LAST transfer
        // LAST transfer
        wb_fsm_last : begin
        wb_fsm_last : begin
           wb_cyc_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
           wb_cyc_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
                        !(wb_ack & wb_cti_o == 3'b111);
                        !(wb_ack & wb_cti_o == 3'b111);
           wb_stb_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
           wb_stb_nxt = !wb_stb_o | !wb_err_i & !wb_rty_i &
                        !(wb_ack & wb_cti_o == 3'b111);
                        !(wb_ack & wb_cti_o == 3'b111);
           wb_cti_nxt[2] = wb_ack & wb_stb_o | wb_cti_o[2];
           wb_cti_nxt[2] = wb_ack & wb_stb_o | wb_cti_o[2];
           wb_cti_nxt[1] = 1'b1                  ;
           wb_cti_nxt[1] = 1'b1                  ;
           wb_cti_nxt[0] = wb_ack & wb_stb_o | wb_cti_o[0];
           wb_cti_nxt[0] = wb_ack & wb_stb_o | wb_cti_o[0];
           if ((wb_err_i | wb_rty_i | wb_ack & wb_cti_o == 3'b111) & wb_stb_o)
           if ((wb_err_i | wb_rty_i | wb_ack & wb_cti_o == 3'b111) & wb_stb_o)
             wb_fsm_state_nxt = wb_fsm_idle;
             wb_fsm_state_nxt = wb_fsm_idle;
           else
           else
             wb_fsm_state_nxt = wb_fsm_last;
             wb_fsm_state_nxt = wb_fsm_last;
        end
        end
        // default state
        // default state
        default:begin
        default:begin
           wb_cyc_nxt = 1'bx;
           wb_cyc_nxt = 1'bx;
           wb_stb_nxt = 1'bx;
           wb_stb_nxt = 1'bx;
           wb_cti_nxt = 3'bxxx;
           wb_cti_nxt = 3'bxxx;
           wb_fsm_state_nxt = 2'bxx;
           wb_fsm_state_nxt = 2'bxx;
        end
        end
      endcase
      endcase
   end
   end
 
 
   //
   //
   // WB FSM - output signals
   // WB FSM - output signals
   // 
   // 
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
         wb_cyc_o       <=  1'b0;
         wb_cyc_o       <=  1'b0;
         wb_stb_o       <=  1'b0;
         wb_stb_o       <=  1'b0;
         wb_cti_o       <=  3'b111;
         wb_cti_o       <=  3'b111;
         wb_bte_o       <=  2'b01;      // 4-beat wrap burst = constant
         wb_bte_o       <=  2'b01;      // 4-beat wrap burst = constant
`ifdef OR1200_WB_CAB
`ifdef OR1200_WB_CAB
         wb_cab_o       <=  1'b0;
         wb_cab_o       <=  1'b0;
`endif
`endif
         wb_we_o                <=  1'b0;
         wb_we_o                <=  1'b0;
         wb_sel_o       <=  4'hf;
         wb_sel_o       <=  4'hf;
         wb_adr_o       <=  {aw{1'b0}};
         wb_adr_o       <=  {aw{1'b0}};
`ifdef OR1200_NO_DC
`ifdef OR1200_NO_DC
         wb_dat_o       <=  {dw{1'b0}};
         wb_dat_o       <=  {dw{1'b0}};
`endif
`endif
      end
      end
      else begin
      else begin
         wb_cyc_o       <=  wb_cyc_nxt;
         wb_cyc_o       <=  wb_cyc_nxt;
         //             wb_stb_o        <=  wb_stb_nxt;
         //             wb_stb_o        <=  wb_stb_nxt;
         if (wb_ack & wb_cti_o == 3'b111)
         if (wb_ack & wb_cti_o == 3'b111)
           wb_stb_o        <=  1'b0;
           wb_stb_o        <=  1'b0;
         else
         else
           wb_stb_o        <=  wb_stb_nxt;
           wb_stb_o        <=  wb_stb_nxt;
         wb_cti_o       <=  wb_cti_nxt;
         wb_cti_o       <=  wb_cti_nxt;
         wb_bte_o       <=  2'b01;      // 4-beat wrap burst = constant
         wb_bte_o       <=  2'b01;      // 4-beat wrap burst = constant
`ifdef OR1200_WB_CAB
`ifdef OR1200_WB_CAB
         wb_cab_o       <=  biu_cab_i;
         wb_cab_o       <=  biu_cab_i;
`endif
`endif
         // we and sel - set at beginning of access 
         // we and sel - set at beginning of access 
         if (wb_fsm_state_cur == wb_fsm_idle) begin
         if (wb_fsm_state_cur == wb_fsm_idle) begin
            wb_we_o             <=  biu_we_i;
            wb_we_o             <=  biu_we_i;
            wb_sel_o    <=  biu_sel_i;
            wb_sel_o    <=  biu_sel_i;
         end
         end
         // adr - set at beginning of access and changed at every termination 
         // adr - set at beginning of access and changed at every termination 
         if (wb_fsm_state_cur == wb_fsm_idle) begin
         if (wb_fsm_state_cur == wb_fsm_idle) begin
            wb_adr_o    <=  biu_adr_i;
            wb_adr_o    <=  biu_adr_i;
         end
         end
         else if (wb_stb_o & wb_ack) begin
         else if (wb_stb_o & wb_ack) begin
            wb_adr_o[3:2]       <=  wb_adr_o[3:2] + 1'b1;
            wb_adr_o[3:2]       <=  wb_adr_o[3:2] + 1'b1;
         end
         end
`ifdef OR1200_NO_DC
`ifdef OR1200_NO_DC
         // dat - write data changed after avery subsequent write access
         // dat - write data changed after avery subsequent write access
         if (!wb_stb_o) begin
         if (!wb_stb_o) begin
            wb_dat_o    <=  biu_dat_i;
            wb_dat_o    <=  biu_dat_i;
         end
         end
`endif
`endif
      end
      end
   end
   end
 
 
   //
   //
   // WB & BIU termination toggle counters
   // WB & BIU termination toggle counters
   // 
   // 
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
   always @(posedge wb_clk_i or `OR1200_RST_EVENT wb_rst_i) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
      if (wb_rst_i == `OR1200_RST_VALUE) begin
         wb_ack_cnt     <=  1'b0;
         wb_ack_cnt     <=  1'b0;
         wb_err_cnt     <=  1'b0;
         wb_err_cnt     <=  1'b0;
         wb_rty_cnt     <=  1'b0;
         wb_rty_cnt     <=  1'b0;
      end
      end
      else begin
      else begin
         // WB ack toggle counter
         // WB ack toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           wb_ack_cnt   <=  1'b0;
           wb_ack_cnt   <=  1'b0;
         else if (wb_stb_o & wb_ack)
         else if (wb_stb_o & wb_ack)
           wb_ack_cnt   <=  !wb_ack_cnt;
           wb_ack_cnt   <=  !wb_ack_cnt;
         // WB err toggle counter
         // WB err toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           wb_err_cnt   <=  1'b0;
           wb_err_cnt   <=  1'b0;
         else if (wb_stb_o & wb_err_i)
         else if (wb_stb_o & wb_err_i)
           wb_err_cnt   <=  !wb_err_cnt;
           wb_err_cnt   <=  !wb_err_cnt;
         // WB rty toggle counter
         // WB rty toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           wb_rty_cnt   <=  1'b0;
           wb_rty_cnt   <=  1'b0;
         else if (wb_stb_o & wb_rty_i)
         else if (wb_stb_o & wb_rty_i)
           wb_rty_cnt   <=  !wb_rty_cnt;
           wb_rty_cnt   <=  !wb_rty_cnt;
      end
      end
   end
   end
 
 
   always @(posedge clk or `OR1200_RST_EVENT rst) begin
   always @(posedge clk or `OR1200_RST_EVENT rst) begin
      if (rst == `OR1200_RST_VALUE) begin
      if (rst == `OR1200_RST_VALUE) begin
         biu_stb_reg    <=  1'b0;
         biu_stb_reg    <=  1'b0;
         biu_ack_cnt    <=  1'b0;
         biu_ack_cnt    <=  1'b0;
         biu_err_cnt    <=  1'b0;
         biu_err_cnt    <=  1'b0;
         biu_rty_cnt    <=  1'b0;
         biu_rty_cnt    <=  1'b0;
`ifdef OR1200_WB_RETRY
`ifdef OR1200_WB_RETRY
         retry_cnt      <= {`OR1200_WB_RETRY{1'b0}};
         retry_cnt      <= {`OR1200_WB_RETRY{1'b0}};
`endif
`endif
      end
      end
      else begin
      else begin
         // BIU strobe
         // BIU strobe
         if (biu_stb_i & !biu_cab_i & biu_ack_o)
         if (biu_stb_i & !biu_cab_i & biu_ack_o)
           biu_stb_reg  <=  1'b0;
           biu_stb_reg  <=  1'b0;
         else
         else
           biu_stb_reg  <=  biu_stb_i;
           biu_stb_reg  <=  biu_stb_i;
         // BIU ack toggle counter
         // BIU ack toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           biu_ack_cnt  <=  1'b0 ;
           biu_ack_cnt  <=  1'b0 ;
         else if (biu_ack_o)
         else if (biu_ack_o)
           biu_ack_cnt  <=  !biu_ack_cnt ;
           biu_ack_cnt  <=  !biu_ack_cnt ;
         // BIU err toggle counter
         // BIU err toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           biu_err_cnt  <=  1'b0 ;
           biu_err_cnt  <=  1'b0 ;
         else if (wb_err_i & biu_err_o)
         else if (wb_err_i & biu_err_o)
           biu_err_cnt  <=  !biu_err_cnt ;
           biu_err_cnt  <=  !biu_err_cnt ;
         // BIU rty toggle counter
         // BIU rty toggle counter
         if (wb_fsm_state_cur == wb_fsm_idle | !clmode)
         if (wb_fsm_state_cur == wb_fsm_idle | !(|clmode))
           biu_rty_cnt  <=  1'b0 ;
           biu_rty_cnt  <=  1'b0 ;
         else if (biu_rty)
         else if (biu_rty)
           biu_rty_cnt  <=  !biu_rty_cnt ;
           biu_rty_cnt  <=  !biu_rty_cnt ;
`ifdef OR1200_WB_RETRY
`ifdef OR1200_WB_RETRY
         if (biu_ack_o | biu_err_o)
         if (biu_ack_o | biu_err_o)
           retry_cnt    <=  {`OR1200_WB_RETRY{1'b0}};
           retry_cnt    <=  {`OR1200_WB_RETRY{1'b0}};
         else if (biu_rty)
         else if (biu_rty)
           retry_cnt    <=  retry_cnt + 1'b1;
           retry_cnt    <=  retry_cnt + 1'b1;
`endif
`endif
      end
      end
   end
   end
 
 
   assign biu_stb = biu_stb_i & biu_stb_reg;
   assign biu_stb = biu_stb_i & biu_stb_reg;
 
 
   //
   //
   // Input BIU data bus
   // Input BIU data bus
   //
   //
   assign       biu_dat_o       = wb_dat_i;
   assign       biu_dat_o       = wb_dat_i;
 
 
   //
   //
   // Input BIU termination signals 
   // Input BIU termination signals 
   //
   //
   assign       biu_rty         = (wb_fsm_state_cur == wb_fsm_trans) & wb_rty_i & wb_stb_o & (wb_rty_cnt ~^ biu_rty_cnt);
   assign       biu_rty         = (wb_fsm_state_cur == wb_fsm_trans) & wb_rty_i & wb_stb_o & (wb_rty_cnt ~^ biu_rty_cnt);
   assign       biu_ack_o       = (wb_fsm_state_cur == wb_fsm_trans) & wb_ack & wb_stb_o & (wb_ack_cnt ~^ biu_ack_cnt);
   assign       biu_ack_o       = (wb_fsm_state_cur == wb_fsm_trans) & wb_ack & wb_stb_o & (wb_ack_cnt ~^ biu_ack_cnt);
   assign       biu_err_o       = (wb_fsm_state_cur == wb_fsm_trans) & wb_err_i & wb_stb_o & (wb_err_cnt ~^ biu_err_cnt)
   assign       biu_err_o       = (wb_fsm_state_cur == wb_fsm_trans) & wb_err_i & wb_stb_o & (wb_err_cnt ~^ biu_err_cnt)
`ifdef OR1200_WB_RETRY
`ifdef OR1200_WB_RETRY
     | biu_rty & retry_cnt[`OR1200_WB_RETRY-1];
     | biu_rty & retry_cnt[`OR1200_WB_RETRY-1];
`else
`else
   ;
   ;
`endif
`endif
 
 
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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