📄 wb_slave.v
字号:
////////////////////////////////////////////////////////////////////////// //////// File name "wb_slave.v" //////// //////// This file is part of the "PCI bridge" project //////// http://www.opencores.org/cores/pci/ //////// //////// Author(s): //////// - Miha Dolenc (mihad@opencores.org) //////// //////// All additional information is avaliable in the README.pdf //////// file. //////// //////// ////////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2001 Miha Dolenc, mihad@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: wb_slave.v,v $// Revision 1.6 2001/07/30 15:24:17 mihad// Updated selects checking on WISHBONE bus, so it does not pass any// requests to pci which conflict with pci specification.////`define FSM_BITS 4 // number of bits needed for FSM states// WISHBONE data output selections encoding`include "bus_commands.v"`include "constants.v"module WB_SLAVE( wb_clock_in, reset_in, wb_hit_in, wb_conf_hit_in, wb_map_in, wb_pref_en_in, wb_mrl_en_in, wb_addr_in, del_bc_in, wb_del_req_pending_in, wb_del_comp_pending_in, pci_drcomp_pending_in, del_bc_out, del_req_out, del_done_out, del_burst_out, del_write_out, del_write_in, del_error_in, del_in_progress_out, ccyc_addr_in, wb_del_addr_in, wb_del_be_in, wb_conf_offset_out, wb_conf_renable_out, wb_conf_wenable_out, wb_conf_be_out, wb_conf_data_in, wb_conf_data_out, wb_data_out, wb_cbe_out, wbw_fifo_wenable_out, wbw_fifo_control_out, wbw_fifo_almost_full_in, wbw_fifo_full_in, wbr_fifo_renable_out, wbr_fifo_be_in, wbr_fifo_data_in, wbr_fifo_control_in, wbr_fifo_flush_out, wbr_fifo_almost_empty_in, wbr_fifo_empty_in, pciw_fifo_empty_in, wbs_lock_in, CYC_I, STB_I, WE_I, SEL_I, SDATA_I, SDATA_O, ACK_O, RTY_O, ERR_O, CAB_I );/*----------------------------------------------------------------------------------------------------------------------Various parameters needed for state machine and other stuff----------------------------------------------------------------------------------------------------------------------*/parameter WBR_SEL = 1'b0 ;parameter CONF_SEL = 1'b1 ;parameter S_IDLE = `FSM_BITS'h0 ; parameter S_W_ADDR_DATA = `FSM_BITS'h1 ;parameter S_TURN_ARROUND = `FSM_BITS'h2 ;parameter S_READ = `FSM_BITS'h3 ;parameter S_CONF_WRITE = `FSM_BITS'h4 ;parameter S_CONF_READ = `FSM_BITS'h5 ;/*----------------------------------------------------------------------------------------------------------------------System signals inputswb_clock_in - WISHBONE bus clock inputreset_in - system reset input controlled by bridge's reset logic----------------------------------------------------------------------------------------------------------------------*/input wb_clock_in, reset_in ;/*----------------------------------------------------------------------------------------------------------------------Inputs from address decoding logicwb_hit_in - Decoder logic indicates if address is in a range of one of imageswb_conf_hit_in - Decoder logic indicates that address is in configuration space rangewb_map_in - Decoder logic provides information about image mapping - memory mapped image - wb_map_in = 0 IO space mapped image - wb_map_in = 1 wb_pref_en_in - Prefetch enable signal from currently selected image - used for PCI bus command usagewb_addr_in - Address already transalted from WB bus to PCI bus inputwb_mrl_en_in - Memory read line enable input for each image----------------------------------------------------------------------------------------------------------------------*/input [4:0] wb_hit_in ; // hit indicatorsinput wb_conf_hit_in ; // configuration hit indicatorinput [4:0] wb_pref_en_in ; // prefetch enable from all imagesinput [4:0] wb_mrl_en_in ; // Memory Read line command enable from images input [4:0] wb_map_in ; // address space mapping indicators - 1 memory space mapping, 0-IO space mappinginput [31:0] wb_addr_in ; // Translated address input/*----------------------------------------------------------------------------------------------------------------------Delayed transaction control inputs and outputs:Used for locking particular accesses when delayed transactions are in progress:wb_del_addr_in - delayed transaction address input - when completion is ready it's used for transaction decodingwb_del_be_in - delayed transaction byte enable input - when completion is ready it's used for transaction decoding----------------------------------------------------------------------------------------------------------------------*/input [31:0] wb_del_addr_in ;input [3:0] wb_del_be_in ;input [3:0] del_bc_in ; // delayed request bus command usedinput wb_del_req_pending_in ; // delayed request pending indicatorinput wb_del_comp_pending_in ; // delayed completion pending indicatorinput pci_drcomp_pending_in ; // PCI initiated delayed read completion pending output [3:0] del_bc_out ; // delayed transaction bus command outputoutput del_req_out ; // output for issuing delayed transaction requestsoutput del_done_out ; // output indicating current delayed completion finished on WISHBONE busoutput del_burst_out ; // delayed burst transaction indicatoroutput del_in_progress_out ; // delayed in progress indicator - since delayed transaction can be a burst transaction, progress indicator must be used for proper operationoutput del_write_out ; // write enable for delayed transaction - used for indicating that transaction is a writeinput del_write_in ; // indicates that current delayed completion is from a write requestinput del_error_in ; // indicate that delayed request terminated with an error - used for write requestsinput [31:0] ccyc_addr_in ; // configuration cycle address input - it's separate from other addresses, since it is stored separately and decoded for type 0 configuration access/*----------------------------------------------------------------------------------------------------------------------Configuration space access control and data signalswb_conf_offset_out - lower 12 bits of address input provided for register offsetwb_conf_renable - read enable signal for configuration space accesseswb_conf_wenable - write enable signal for configuration space accesseswb_conf_be_out - byte enable signals for configuration space accesseswb_conf_data_in - data from configuration spacewb_conf_data_in - data provided for configuration space----------------------------------------------------------------------------------------------------------------------*/output [11:0] wb_conf_offset_out ; // register offset outputoutput wb_conf_renable_out, // configuration read and write enable outputs wb_conf_wenable_out ; output [3:0] wb_conf_be_out ; // byte enable outputs for configuration spaceinput [31:0] wb_conf_data_in ; // configuration data input from configuration spaceoutput [31:0] wb_conf_data_out ; // configuration data output for configuration space/*----------------------------------------------------------------------------------------------------------------------Data from WISHBONE bus output to interiror of the core:Data output is used for normal and configuration accesses.---------------------------------------------------------------------------------------------------------------------*/output [31:0] wb_data_out ;/*----------------------------------------------------------------------------------------------------------------------Bus command - byte enable output - during address phase of image access this bus holds information about PCIbus command that should be used, during dataphases ( configuration or image access ) this bus contains invertedSEL_I signals---------------------------------------------------------------------------------------------------------------------*/output [3:0] wb_cbe_out ;/*----------------------------------------------------------------------------------------------------------------------WBW_FIFO control signals used for sinking data into WBW_FIFO and status monitoring---------------------------------------------------------------------------------------------------------------------*/output wbw_fifo_wenable_out ; // write enable for WBW_FIFO outputoutput [3:0] wbw_fifo_control_out ; // control bus output for WBW_FIFOinput wbw_fifo_almost_full_in ; // almost full status indicator from WBW_FIFOinput wbw_fifo_full_in ; // full status indicator from WBW_FIFO/*----------------------------------------------------------------------------------------------------------------------WBR_FIFO control signals used for fetching data from WBR_FIFO and status monitoring---------------------------------------------------------------------------------------------------------------------*/output wbr_fifo_renable_out ; // WBR_FIFO read enable outputinput [3:0] wbr_fifo_be_in ; // byte enable input from WBR_FIFOinput [31:0] wbr_fifo_data_in ; // data input from WBR_FIFOinput [3:0] wbr_fifo_control_in ; // control bus input from WBR_FIFOoutput wbr_fifo_flush_out ; // flush signal for WBR_FIFOinput wbr_fifo_almost_empty_in ; // almost empty status indicator from WBR_FIFOinput wbr_fifo_empty_in ; // empty status indicator from WBR_FIFO// used for transaction ordering requirements - WISHBONE read cannot complete until writes from PCI are completedinput pciw_fifo_empty_in ; // empty status indicator from PCIW_FIFO/*----------------------------------------------------------------------------------------------------------------------wbs_lock_in - internal signal - when error reporting is enabled and WISHBONE master detects an error while completingposted write on PCI, then WISHBONE slave unit doesn't accept any new requests or posted writes. Delayed completionsare allowed to complete on WISHBONE if all other requirements are satisfied also. ---------------------------------------------------------------------------------------------------------------------*/input wbs_lock_in ;/*----------------------------------------------------------------------------------------------------------------------WISHBONE bus interface signals - can be connected directly to WISHBONE bus---------------------------------------------------------------------------------------------------------------------*/input CYC_I ; // cycle indicatorinput STB_I ; // strobe input - input data is valid when strobe and cycle indicator are highinput WE_I ; // write enable input - 1 - write operation, 0 - read operationinput [3:0] SEL_I ; // Byte select inputsinput [31:0] SDATA_I ; // WISHBONE slave interface input data busoutput [31:0] SDATA_O ; // WISHBONE slave interface output data busoutput ACK_O ; // Acknowledge output - qualifies valid data on data output bus or received data on data input busoutput RTY_O ; // retry output - signals to WISHBONE master that cycle should be terminated and retried lateroutput ERR_O ; // Signals to WISHBONE master that access resulted in an errorinput CAB_I ; // consecutive address burst input - indicates that master will do a serial address transfer in current cyclereg [(`FSM_BITS - 1):0] c_state ; //current state registerreg [(`FSM_BITS - 1):0] n_state ; //next state input to current state register// state machine register controlalways@(posedge wb_clock_in or posedge reset_in)begin if (reset_in) c_state <= #`FF_DELAY S_IDLE ; else c_state <= #`FF_DELAY n_state ;end// write operation indicator for delayed transaction requestsassign del_write_out = WE_I ;// variable for bus command multiplexer logic output for delayed requestsreg [3:0] del_bc ;//register for intermediate data and select storagereg [35:0] d_incoming ;// enable for incoming data register
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -