📄 or1200_iwb_biu.v
字号:
////////////////////////////////////////////////////////////////////////// //////// OR1200's WISHBONE BIU //////// //////// This file is part of the OpenRISC 1200 project //////// http://www.opencores.org/cores/or1k/ //////// //////// Description //////// Implements WISHBONE interface //////// //////// To Do: //////// - if biu_cyc/stb are deasserted and wb_ack_i is asserted //////// and this happens even before aborted_r is asssrted, //////// wb_ack_i will be delivered even though transfer is //////// internally considered already aborted. However most //////// wb_ack_i are externally registered and delayed. Normally //////// this shouldn't cause any problems. //////// //////// Author(s): //////// - Damjan Lampret, lampret@opencores.org //////// ////////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2000 Authors and OPENCORES.ORG //////// //////// This source file may be used and distributed without //////// restriction provided that this copyright statement is not //////// removed from the file and that any derivative work contains //////// the original copyright notice and the associated disclaimer. //////// //////// This source file is free software; you can redistribute it //////// and/or modify it under the terms of the GNU Lesser General //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any //////// later version. //////// //////// This source is distributed in the hope that it will be //////// useful, but WITHOUT ANY WARRANTY; without even the implied //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //////// PURPOSE. See the GNU Lesser General Public License for more //////// details. //////// //////// You should have received a copy of the GNU Lesser General //////// Public License along with this source; if not, download it //////// from http://www.opencores.org/lgpl.shtml //////// ////////////////////////////////////////////////////////////////////////////// CVS Revision History//// $Log: or1200_iwb_biu.v,v $// Revision 1.2 2004/04/05 08:29:57 lampret// Merged branch_qmem into main tree.//// Revision 1.1 2003/12/05 00:12:08 lampret// New wb_biu for iwb interface.//// Revision 1.6.4.1 2003/07/08 15:36:37 lampret// Added embedded memory QMEM.//// Revision 1.6 2003/04/07 20:57:46 lampret// Fixed OR1200_CLKDIV_x_SUPPORTED defines. Fixed order of ifdefs.//// Revision 1.5 2002/12/08 08:57:56 lampret// Added optional support for WB B3 specification (xwb_cti_o, xwb_bte_o). Made xwb_cab_o optional.//// Revision 1.4 2002/09/16 03:09:16 lampret// Fixed a combinational loop.//// Revision 1.3 2002/08/12 05:31:37 lampret// Added optional retry counter for wb_rty_i. Added graceful termination for aborted transfers.//// Revision 1.2 2002/07/14 22:17:17 lampret// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.//// Revision 1.1 2002/01/03 08:16:15 lampret// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.//// Revision 1.12 2001/11/22 13:42:51 lampret// Added wb_cyc_o assignment after it was removed by accident.//// Revision 1.11 2001/11/20 21:28:10 lampret// Added optional sampling of inputs.//// Revision 1.10 2001/11/18 11:32:00 lampret// OR1200_REGISTERED_OUTPUTS can now be enabled.//// Revision 1.9 2001/10/21 17:57:16 lampret// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.//// Revision 1.8 2001/10/14 13:12:10 lampret// MP3 version.//// Revision 1.1.1.1 2001/10/06 10:18:35 igorm// no message//// Revision 1.3 2001/08/09 13:39:33 lampret// Major clean-up.//// Revision 1.2 2001/07/22 03:31:54 lampret// Fixed RAM's oen bug. Cache bypass under development.//// Revision 1.1 2001/07/20 00:46:23 lampret// Development version of RTL. Libraries are missing.////// synopsys translate_off`include "timescale.v"// synopsys translate_on`include "or1200_defines.v"module or1200_iwb_biu( // RISC clock, reset and clock control clk, rst, clmode, // WISHBONE interface 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,`ifdef OR1200_WB_CAB wb_cab_o,`endif`ifdef OR1200_WB_B3 wb_cti_o, wb_bte_o,`endif // 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_o, biu_ack_o, biu_err_o);parameter dw = `OR1200_OPERAND_WIDTH;parameter aw = `OR1200_OPERAND_WIDTH;//// RISC clock, reset and clock control//input clk; // RISC clockinput rst; // RISC resetinput [1:0] clmode; // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4//// WISHBONE interface//input wb_clk_i; // clock inputinput wb_rst_i; // reset inputinput wb_ack_i; // normal terminationinput wb_err_i; // termination w/ errorinput wb_rty_i; // termination w/ retryinput [dw-1:0] wb_dat_i; // input data busoutput wb_cyc_o; // cycle valid outputoutput [aw-1:0] wb_adr_o; // address bus outputsoutput wb_stb_o; // strobe outputoutput wb_we_o; // indicates write transferoutput [3:0] wb_sel_o; // byte select outputsoutput [dw-1:0] wb_dat_o; // output data bus`ifdef OR1200_WB_CABoutput wb_cab_o; // consecutive address burst`endif`ifdef OR1200_WB_B3output [2:0] wb_cti_o; // cycle type identifieroutput [1:0] wb_bte_o; // burst type extension`endif//// Internal RISC interface//input [dw-1:0] biu_dat_i; // input data businput [aw-1:0] biu_adr_i; // address businput biu_cyc_i; // WB cycleinput biu_stb_i; // WB strobeinput biu_we_i; // WB write enableinput biu_cab_i; // CAB inputinput [3:0] biu_sel_i; // byte selectsoutput [31:0] biu_dat_o; // output data busoutput biu_ack_o; // ack outputoutput biu_err_o; // err output//// Registers//reg [1:0] valid_div; // Used for synchronization`ifdef OR1200_REGISTERED_OUTPUTSreg [aw-1:0] wb_adr_o; // address bus outputsreg wb_cyc_o; // cycle outputreg wb_stb_o; // strobe outputreg wb_we_o; // indicates write transferreg [3:0] wb_sel_o; // byte select outputs`ifdef OR1200_WB_CABreg wb_cab_o; // CAB output`endif`ifdef OR1200_WB_B3reg [1:0] burst_len; // burst counterreg [2:0] wb_cti_o; // cycle type identifier`endifreg [dw-1:0] wb_dat_o; // output data bus`endif`ifdef OR1200_REGISTERED_INPUTSreg long_ack_o; // normal terminationreg long_err_o; // error terminationreg [dw-1:0] biu_dat_o; // output data bus`elsewire long_ack_o; // normal terminationwire long_err_o; // error termination`endifwire aborted; // Graceful abortreg aborted_r; // Graceful abortwire retry; // Retry`ifdef OR1200_WB_RETRYreg [`OR1200_WB_RETRY-1:0] retry_cntr; // Retry counter`endifreg previous_complete;wire same_addr;wire repeated_access;reg repeated_access_ack;reg [dw-1:0] wb_dat_r; // saved previous data read//// WISHBONE I/F <-> Internal RISC I/F conversion////// Address bus//`ifdef OR1200_REGISTERED_OUTPUTSalways @(posedge wb_clk_i or posedge wb_rst_i) if (wb_rst_i) wb_adr_o <= #1 {aw{1'b0}}; else if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i & ~aborted & ~(wb_stb_o & ~wb_ack_i) | biu_cab_i & (previous_complete | biu_ack_o)) wb_adr_o <= #1 biu_adr_i;`elseassign wb_adr_o = biu_adr_i;`endif//// Same access as previous one, store previous read data//assign same_addr = wb_adr_o == biu_adr_i;assign repeated_access = same_addr & previous_complete;always @(posedge wb_clk_i or posedge wb_rst_i) if (wb_rst_i) wb_dat_r <= #1 32'h0000_0000; else if (wb_ack_i) wb_dat_r <= #1 wb_dat_i;always @(posedge clk or posedge rst) if (rst) repeated_access_ack <= #1 1'b0; else if (repeated_access & biu_cyc_i & biu_stb_i) repeated_access_ack <= #1 1'b1; else repeated_access_ack <= #1 1'b0;//// Previous access completed//always @(posedge wb_clk_i or posedge wb_rst_i) if (wb_rst_i) previous_complete <= #1 1'b1; else if (wb_ack_i & biu_cyc_i & biu_stb_i)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -