|
|
// File : ../RTL/hostController/sendpacketarbiter.v
|
// File : ../RTL/hostController/sendpacketarbiter.v
|
// Generated : 10/15/06 20:31:19
|
// Generated : 11/10/06 05:37:20
|
// From : ../RTL/hostController/sendpacketarbiter.asf
|
// From : ../RTL/hostController/sendpacketarbiter.asf
|
// By : FSM2VHDL ver. 5.0.0.9
|
// By : FSM2VHDL ver. 5.0.0.9
|
|
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// sendpacketarbiter
|
//// sendpacketarbiter
|
//// ////
|
//// ////
|
//// This file is part of the usbhostslave opencores effort.
|
//// This file is part of the usbhostslave opencores effort.
|
//// http://www.opencores.org/cores/usbhostslave/ ////
|
//// http://www.opencores.org/cores/usbhostslave/ ////
|
//// ////
|
//// ////
|
//// Module Description: ////
|
//// Module Description: ////
|
////
|
////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
////
|
////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG ////
|
//// Copyright (C) 2004 Steve Fielding 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 ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
`include "timescale.v"
|
`include "timescale.v"
|
`include "usbConstants_h.v"
|
`include "usbConstants_h.v"
|
|
|
module sendPacketArbiter (HCTxGnt, HCTxReq, HC_PID, HC_SP_WEn, SOFTxGnt, SOFTxReq, SOF_SP_WEn, clk, rst, sendPacketPID, sendPacketWEnable);
|
module sendPacketArbiter (HCTxGnt, HCTxReq, HC_PID, HC_SP_WEn, SOFTxGnt, SOFTxReq, SOF_SP_WEn, clk, rst, sendPacketPID, sendPacketWEnable);
|
input HCTxReq;
|
input HCTxReq;
|
input [3:0] HC_PID;
|
input [3:0] HC_PID;
|
input HC_SP_WEn;
|
input HC_SP_WEn;
|
input SOFTxReq;
|
input SOFTxReq;
|
input SOF_SP_WEn;
|
input SOF_SP_WEn;
|
input clk;
|
input clk;
|
input rst;
|
input rst;
|
output HCTxGnt;
|
output HCTxGnt;
|
output SOFTxGnt;
|
output SOFTxGnt;
|
output [3:0] sendPacketPID;
|
output [3:0] sendPacketPID;
|
output sendPacketWEnable;
|
output sendPacketWEnable;
|
|
|
reg HCTxGnt, next_HCTxGnt;
|
reg HCTxGnt, next_HCTxGnt;
|
wire HCTxReq;
|
wire HCTxReq;
|
wire [3:0] HC_PID;
|
wire [3:0] HC_PID;
|
wire HC_SP_WEn;
|
wire HC_SP_WEn;
|
reg SOFTxGnt, next_SOFTxGnt;
|
reg SOFTxGnt, next_SOFTxGnt;
|
wire SOFTxReq;
|
wire SOFTxReq;
|
wire SOF_SP_WEn;
|
wire SOF_SP_WEn;
|
wire clk;
|
wire clk;
|
wire rst;
|
wire rst;
|
reg [3:0] sendPacketPID, next_sendPacketPID;
|
reg [3:0] sendPacketPID, next_sendPacketPID;
|
reg sendPacketWEnable, next_sendPacketWEnable;
|
reg sendPacketWEnable, next_sendPacketWEnable;
|
|
|
// diagram signals declarations
|
// diagram signals declarations
|
reg muxSOFNotHC, next_muxSOFNotHC;
|
reg muxSOFNotHC, next_muxSOFNotHC;
|
|
|
// BINARY ENCODED state machine: sendPktArb
|
// BINARY ENCODED state machine: sendPktArb
|
// State codes definitions:
|
// State codes definitions:
|
`define HC_ACT 2'b00
|
`define HC_ACT 2'b00
|
`define SOF_ACT 2'b01
|
`define SOF_ACT 2'b01
|
`define SARB_WAIT_REQ 2'b10
|
`define SARB_WAIT_REQ 2'b10
|
`define START_SARB 2'b11
|
`define START_SARB 2'b11
|
|
|
reg [1:0] CurrState_sendPktArb;
|
reg [1:0] CurrState_sendPktArb;
|
reg [1:0] NextState_sendPktArb;
|
reg [1:0] NextState_sendPktArb;
|
|
|
// Diagram actions (continuous assignments allowed only: assign ...)
|
// Diagram actions (continuous assignments allowed only: assign ...)
|
|
|
// hostController/SOFTransmit mux
|
// hostController/SOFTransmit mux
|
always @(muxSOFNotHC or SOF_SP_WEn or HC_SP_WEn or HC_PID)
|
always @(muxSOFNotHC or SOF_SP_WEn or HC_SP_WEn or HC_PID)
|
begin
|
begin
|
if (muxSOFNotHC == 1'b1)
|
if (muxSOFNotHC == 1'b1)
|
begin
|
begin
|
sendPacketWEnable <= SOF_SP_WEn;
|
sendPacketWEnable <= SOF_SP_WEn;
|
sendPacketPID <= `SOF;
|
sendPacketPID <= `SOF;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
sendPacketWEnable <= HC_SP_WEn;
|
sendPacketWEnable <= HC_SP_WEn;
|
sendPacketPID <= HC_PID;
|
sendPacketPID <= HC_PID;
|
end
|
end
|
end
|
end
|
|
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
// Machine: sendPktArb
|
// Machine: sendPktArb
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
//----------------------------------
|
//----------------------------------
|
// Next State Logic (combinatorial)
|
// Next State Logic (combinatorial)
|
//----------------------------------
|
//----------------------------------
|
always @ (HCTxReq or SOFTxReq or HCTxGnt or SOFTxGnt or muxSOFNotHC or CurrState_sendPktArb)
|
always @ (HCTxReq or SOFTxReq or HCTxGnt or SOFTxGnt or muxSOFNotHC or CurrState_sendPktArb)
|
begin : sendPktArb_NextState
|
begin : sendPktArb_NextState
|
NextState_sendPktArb <= CurrState_sendPktArb;
|
NextState_sendPktArb <= CurrState_sendPktArb;
|
// Set default values for outputs and signals
|
// Set default values for outputs and signals
|
next_HCTxGnt <= HCTxGnt;
|
next_HCTxGnt <= HCTxGnt;
|
next_SOFTxGnt <= SOFTxGnt;
|
next_SOFTxGnt <= SOFTxGnt;
|
next_muxSOFNotHC <= muxSOFNotHC;
|
next_muxSOFNotHC <= muxSOFNotHC;
|
case (CurrState_sendPktArb)
|
case (CurrState_sendPktArb)
|
`HC_ACT:
|
`HC_ACT:
|
if (HCTxReq == 1'b0)
|
if (HCTxReq == 1'b0)
|
begin
|
begin
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
next_HCTxGnt <= 1'b0;
|
next_HCTxGnt <= 1'b0;
|
end
|
end
|
`SOF_ACT:
|
`SOF_ACT:
|
if (SOFTxReq == 1'b0)
|
if (SOFTxReq == 1'b0)
|
begin
|
begin
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
next_SOFTxGnt <= 1'b0;
|
next_SOFTxGnt <= 1'b0;
|
end
|
end
|
`SARB_WAIT_REQ:
|
`SARB_WAIT_REQ:
|
if (SOFTxReq == 1'b1)
|
if (SOFTxReq == 1'b1)
|
begin
|
begin
|
NextState_sendPktArb <= `SOF_ACT;
|
NextState_sendPktArb <= `SOF_ACT;
|
next_SOFTxGnt <= 1'b1;
|
next_SOFTxGnt <= 1'b1;
|
next_muxSOFNotHC <= 1'b1;
|
next_muxSOFNotHC <= 1'b1;
|
end
|
end
|
else if (HCTxReq == 1'b1)
|
else if (HCTxReq == 1'b1)
|
begin
|
begin
|
NextState_sendPktArb <= `HC_ACT;
|
NextState_sendPktArb <= `HC_ACT;
|
next_HCTxGnt <= 1'b1;
|
next_HCTxGnt <= 1'b1;
|
next_muxSOFNotHC <= 1'b0;
|
next_muxSOFNotHC <= 1'b0;
|
end
|
end
|
`START_SARB:
|
`START_SARB:
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
NextState_sendPktArb <= `SARB_WAIT_REQ;
|
endcase
|
endcase
|
end
|
end
|
|
|
//----------------------------------
|
//----------------------------------
|
// Current State Logic (sequential)
|
// Current State Logic (sequential)
|
//----------------------------------
|
//----------------------------------
|
always @ (posedge clk)
|
always @ (posedge clk)
|
begin : sendPktArb_CurrentState
|
begin : sendPktArb_CurrentState
|
if (rst)
|
if (rst)
|
CurrState_sendPktArb <= `START_SARB;
|
CurrState_sendPktArb <= `START_SARB;
|
else
|
else
|
CurrState_sendPktArb <= NextState_sendPktArb;
|
CurrState_sendPktArb <= NextState_sendPktArb;
|
end
|
end
|
|
|
//----------------------------------
|
//----------------------------------
|
// Registered outputs logic
|
// Registered outputs logic
|
//----------------------------------
|
//----------------------------------
|
always @ (posedge clk)
|
always @ (posedge clk)
|
begin : sendPktArb_RegOutput
|
begin : sendPktArb_RegOutput
|
if (rst)
|
if (rst)
|
begin
|
begin
|
muxSOFNotHC <= 1'b0;
|
muxSOFNotHC <= 1'b0;
|
SOFTxGnt <= 1'b0;
|
SOFTxGnt <= 1'b0;
|
HCTxGnt <= 1'b0;
|
HCTxGnt <= 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
muxSOFNotHC <= next_muxSOFNotHC;
|
muxSOFNotHC <= next_muxSOFNotHC;
|
SOFTxGnt <= next_SOFTxGnt;
|
SOFTxGnt <= next_SOFTxGnt;
|
HCTxGnt <= next_HCTxGnt;
|
HCTxGnt <= next_HCTxGnt;
|
end
|
end
|
end
|
end
|
|
|
|
|