Line 40... |
Line 40... |
//// 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 ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// $Id: siereceiver.v,v 1.3 2004-12-31 14:40:43 sfielding Exp $
|
|
//
|
|
// CVS Revision History
|
|
//
|
|
// $Log: not supported by cvs2svn $
|
|
//
|
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
`include "usbSerialInterfaceEngine_h.v"
|
`include "usbSerialInterfaceEngine_h.v"
|
|
|
|
|
module SIEReceiver (clk, connectState, processRxBitRdyIn, processRxBitsWEn, rst, RxBitsOut, RxWireDataIn, RxWireDataWEn, SIERxRdyOut);
|
module SIEReceiver (clk, connectState, rst, RxWireDataIn, RxWireDataWEn);
|
input clk;
|
input clk;
|
input processRxBitRdyIn;
|
|
input rst;
|
input rst;
|
input [1:0]RxWireDataIn;
|
input [1:0]RxWireDataIn;
|
input RxWireDataWEn;
|
input RxWireDataWEn;
|
output [1:0]connectState;
|
output [1:0]connectState;
|
output processRxBitsWEn;
|
|
output [1:0]RxBitsOut;
|
|
output SIERxRdyOut;
|
|
|
|
wire clk;
|
wire clk;
|
reg [1:0]connectState, next_connectState;
|
reg [1:0]connectState, next_connectState;
|
wire processRxBitRdyIn;
|
|
reg processRxBitsWEn, next_processRxBitsWEn;
|
|
wire rst;
|
wire rst;
|
reg [1:0]RxBitsOut, next_RxBitsOut;
|
|
wire [1:0]RxWireDataIn;
|
wire [1:0]RxWireDataIn;
|
wire RxWireDataWEn;
|
wire RxWireDataWEn;
|
reg SIERxRdyOut, next_SIERxRdyOut;
|
|
|
|
// diagram signals declarations
|
// diagram signals declarations
|
reg [1:0]RxBits, next_RxBits;
|
reg [1:0]RxBits, next_RxBits;
|
reg [3:0]RXStMachCurrState, next_RXStMachCurrState;
|
reg [3:0]RXStMachCurrState, next_RXStMachCurrState;
|
reg [7:0]RXWaitCount, next_RXWaitCount;
|
reg [7:0]RXWaitCount, next_RXWaitCount;
|
Line 84... |
Line 70... |
`define WAIT_LS_CONN_CHK_RX_BITS 4'b0001
|
`define WAIT_LS_CONN_CHK_RX_BITS 4'b0001
|
`define LS_CONN_CHK_RX_BITS 4'b0010
|
`define LS_CONN_CHK_RX_BITS 4'b0010
|
`define DISCNCT_CHK_RXBITS 4'b0011
|
`define DISCNCT_CHK_RXBITS 4'b0011
|
`define WAIT_BIT 4'b0100
|
`define WAIT_BIT 4'b0100
|
`define START_SRX 4'b0101
|
`define START_SRX 4'b0101
|
`define LS_CONN_PROC_RX_BITS 4'b0110
|
`define FS_CONN_CHK_RX_BITS1 4'b0110
|
`define FS_CONN_CHK_RX_BITS1 4'b0111
|
`define WAIT_LS_DIS_CHK_RX_BITS 4'b0111
|
`define WAIT_LS_DIS_CHK_RX_BITS 4'b1000
|
`define WAIT_FS_DIS_CHK_RX_BITS2 4'b1000
|
`define WAIT_LS_DIS_PROC_RX_BITS 4'b1001
|
|
`define WAIT_FS_DIS_PROC_RX_BITS2 4'b1010
|
|
`define WAIT_FS_DIS_CHK_RX_BITS2 4'b1011
|
|
`define FS_CONN_PROC_RX_BITS1 4'b1100
|
|
|
|
reg [3:0]CurrState_rcvr, NextState_rcvr;
|
reg [3:0]CurrState_rcvr, NextState_rcvr;
|
|
|
|
|
// Machine: rcvr
|
// Machine: rcvr
|
|
|
// NextState logic (combinatorial)
|
// NextState logic (combinatorial)
|
always @ (RXWaitCount or processRxBitRdyIn or RxBits or RxWireDataWEn or RxWireDataIn or connectState or RXStMachCurrState or processRxBitsWEn or RxBitsOut or SIERxRdyOut or CurrState_rcvr)
|
always @ (RXWaitCount or RxBits or RxWireDataWEn or RxWireDataIn or connectState or RXStMachCurrState or CurrState_rcvr)
|
begin
|
begin
|
NextState_rcvr <= CurrState_rcvr;
|
NextState_rcvr <= CurrState_rcvr;
|
// Set default values for outputs and signals
|
// Set default values for outputs and signals
|
next_RXWaitCount <= RXWaitCount;
|
next_RXWaitCount <= RXWaitCount;
|
next_connectState <= connectState;
|
next_connectState <= connectState;
|
next_RXStMachCurrState <= RXStMachCurrState;
|
next_RXStMachCurrState <= RXStMachCurrState;
|
next_processRxBitsWEn <= processRxBitsWEn;
|
|
next_RxBitsOut <= RxBitsOut;
|
|
next_RxBits <= RxBits;
|
next_RxBits <= RxBits;
|
next_SIERxRdyOut <= SIERxRdyOut;
|
|
case (CurrState_rcvr) // synopsys parallel_case full_case
|
case (CurrState_rcvr) // synopsys parallel_case full_case
|
`WAIT_BIT:
|
`WAIT_BIT:
|
begin
|
begin
|
if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_LOW_SP_DISCONNECT_ST))
|
if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_LOW_SPEED_CONN_ST))
|
begin
|
begin
|
NextState_rcvr <= `WAIT_LS_DIS_CHK_RX_BITS;
|
NextState_rcvr <= `WAIT_LS_CONN_CHK_RX_BITS;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `CONNECT_FULL_SPEED_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `CONNECT_LOW_SPEED_ST))
|
begin
|
begin
|
NextState_rcvr <= `FS_CONN_CHK_RX_BITS1;
|
NextState_rcvr <= `LS_CONN_CHK_RX_BITS;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `CONNECT_LOW_SPEED_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `CONNECT_FULL_SPEED_ST))
|
begin
|
begin
|
NextState_rcvr <= `LS_CONN_CHK_RX_BITS;
|
NextState_rcvr <= `FS_CONN_CHK_RX_BITS1;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_LOW_SPEED_CONN_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_LOW_SP_DISCONNECT_ST))
|
begin
|
begin
|
NextState_rcvr <= `WAIT_LS_CONN_CHK_RX_BITS;
|
NextState_rcvr <= `WAIT_LS_DIS_CHK_RX_BITS;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_FULL_SPEED_CONN_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_FULL_SP_DISCONNECT_ST))
|
begin
|
begin
|
NextState_rcvr <= `WAIT_FS_CONN_CHK_RX_BITS;
|
NextState_rcvr <= `WAIT_FS_DIS_CHK_RX_BITS2;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `DISCONNECT_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `DISCONNECT_ST))
|
begin
|
begin
|
NextState_rcvr <= `DISCNCT_CHK_RXBITS;
|
NextState_rcvr <= `DISCNCT_CHK_RXBITS;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_FULL_SP_DISCONNECT_ST))
|
else if ((RxWireDataWEn == 1'b1) && (RXStMachCurrState == `WAIT_FULL_SPEED_CONN_ST))
|
begin
|
begin
|
NextState_rcvr <= `WAIT_FS_DIS_CHK_RX_BITS2;
|
NextState_rcvr <= `WAIT_FS_CONN_CHK_RX_BITS;
|
next_RxBits <= RxWireDataIn;
|
next_RxBits <= RxWireDataIn;
|
next_SIERxRdyOut <= 1'b0;
|
|
end
|
end
|
end
|
end
|
`START_SRX:
|
`START_SRX:
|
begin
|
begin
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
next_RXWaitCount <= 8'h00;
|
next_RXWaitCount <= 8'h00;
|
next_connectState <= `DISCONNECT;
|
next_connectState <= `DISCONNECT;
|
next_RxBits <= 2'b00;
|
next_RxBits <= 2'b00;
|
next_RxBitsOut <= 2'b00;
|
|
next_processRxBitsWEn <= 1'b0;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
end
|
end
|
`DISCNCT_CHK_RXBITS:
|
`DISCNCT_CHK_RXBITS:
|
begin
|
begin
|
if (RxBits == `ZERO_ONE)
|
if (RxBits == `ZERO_ONE)
|
begin
|
begin
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
next_RXStMachCurrState <= `WAIT_LOW_SPEED_CONN_ST;
|
next_RXStMachCurrState <= `WAIT_LOW_SPEED_CONN_ST;
|
next_RXWaitCount <= 8'h00;
|
next_RXWaitCount <= 8'h00;
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
else if (RxBits == `ONE_ZERO)
|
else if (RxBits == `ONE_ZERO)
|
begin
|
begin
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
next_RXStMachCurrState <= `WAIT_FULL_SPEED_CONN_ST;
|
next_RXStMachCurrState <= `WAIT_FULL_SPEED_CONN_ST;
|
next_RXWaitCount <= 8'h00;
|
next_RXWaitCount <= 8'h00;
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
else
|
else
|
begin
|
begin
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
end
|
end
|
`WAIT_FS_CONN_CHK_RX_BITS:
|
`WAIT_FS_CONN_CHK_RX_BITS:
|
begin
|
begin
|
if (RxBits == `ONE_ZERO)
|
if (RxBits == `ONE_ZERO)
|
Line 204... |
Line 170... |
else
|
else
|
begin
|
begin
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
end
|
end
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
`WAIT_LS_CONN_CHK_RX_BITS:
|
`WAIT_LS_CONN_CHK_RX_BITS:
|
begin
|
begin
|
if (RxBits == `ZERO_ONE)
|
if (RxBits == `ZERO_ONE)
|
begin
|
begin
|
Line 222... |
Line 187... |
else
|
else
|
begin
|
begin
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
next_RXStMachCurrState <= `DISCONNECT_ST;
|
end
|
end
|
NextState_rcvr <= `WAIT_BIT;
|
NextState_rcvr <= `WAIT_BIT;
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
`LS_CONN_CHK_RX_BITS:
|
`LS_CONN_CHK_RX_BITS:
|
begin
|
begin
|
if (processRxBitRdyIn == 1'b1)
|
NextState_rcvr <= `WAIT_BIT;
|
begin
|
|
NextState_rcvr <= `LS_CONN_PROC_RX_BITS;
|
|
if (RxBits == `SE0)
|
if (RxBits == `SE0)
|
begin
|
begin
|
next_RXStMachCurrState <= `WAIT_LOW_SP_DISCONNECT_ST;
|
next_RXStMachCurrState <= `WAIT_LOW_SP_DISCONNECT_ST;
|
next_RXWaitCount <= 0;
|
next_RXWaitCount <= 0;
|
end
|
end
|
next_processRxBitsWEn <= 1'b1;
|
|
next_RxBitsOut <= RxBits;
|
|
end
|
|
end
|
|
`LS_CONN_PROC_RX_BITS:
|
|
begin
|
|
next_processRxBitsWEn <= 1'b0;
|
|
NextState_rcvr <= `WAIT_BIT;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
`FS_CONN_CHK_RX_BITS1:
|
`FS_CONN_CHK_RX_BITS1:
|
begin
|
begin
|
if (processRxBitRdyIn == 1'b1)
|
NextState_rcvr <= `WAIT_BIT;
|
begin
|
|
NextState_rcvr <= `FS_CONN_PROC_RX_BITS1;
|
|
if (RxBits == `SE0)
|
if (RxBits == `SE0)
|
begin
|
begin
|
next_RXStMachCurrState <= `WAIT_FULL_SP_DISCONNECT_ST;
|
next_RXStMachCurrState <= `WAIT_FULL_SP_DISCONNECT_ST;
|
next_RXWaitCount <= 0;
|
next_RXWaitCount <= 0;
|
end
|
end
|
next_processRxBitsWEn <= 1'b1;
|
|
next_RxBitsOut <= RxBits;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
//early indication of ready
|
|
end
|
|
end
|
|
`FS_CONN_PROC_RX_BITS1:
|
|
begin
|
|
next_processRxBitsWEn <= 1'b0;
|
|
NextState_rcvr <= `WAIT_BIT;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
`WAIT_LS_DIS_CHK_RX_BITS:
|
`WAIT_LS_DIS_CHK_RX_BITS:
|
begin
|
begin
|
if (processRxBitRdyIn == 1'b1)
|
NextState_rcvr <= `WAIT_BIT;
|
begin
|
|
NextState_rcvr <= `WAIT_LS_DIS_PROC_RX_BITS;
|
|
if (RxBits == `SE0)
|
if (RxBits == `SE0)
|
begin
|
begin
|
next_RXWaitCount <= RXWaitCount + 1'b1;
|
next_RXWaitCount <= RXWaitCount + 1'b1;
|
if (RXWaitCount == `DISCONNECT_WAIT_TIME)
|
if (RXWaitCount == `DISCONNECT_WAIT_TIME)
|
begin
|
begin
|
Line 284... |
Line 222... |
end
|
end
|
else
|
else
|
begin
|
begin
|
next_RXStMachCurrState <= `CONNECT_LOW_SPEED_ST;
|
next_RXStMachCurrState <= `CONNECT_LOW_SPEED_ST;
|
end
|
end
|
next_processRxBitsWEn <= 1'b1;
|
|
end
|
|
end
|
|
`WAIT_LS_DIS_PROC_RX_BITS:
|
|
begin
|
|
next_processRxBitsWEn <= 1'b0;
|
|
NextState_rcvr <= `WAIT_BIT;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
|
`WAIT_FS_DIS_PROC_RX_BITS2:
|
|
begin
|
|
next_processRxBitsWEn <= 1'b0;
|
|
NextState_rcvr <= `WAIT_BIT;
|
|
next_SIERxRdyOut <= 1'b1;
|
|
end
|
end
|
`WAIT_FS_DIS_CHK_RX_BITS2:
|
`WAIT_FS_DIS_CHK_RX_BITS2:
|
begin
|
begin
|
if (processRxBitRdyIn == 1'b1)
|
NextState_rcvr <= `WAIT_BIT;
|
begin
|
|
NextState_rcvr <= `WAIT_FS_DIS_PROC_RX_BITS2;
|
|
if (RxBits == `SE0)
|
if (RxBits == `SE0)
|
begin
|
begin
|
next_RXWaitCount <= RXWaitCount + 1'b1;
|
next_RXWaitCount <= RXWaitCount + 1'b1;
|
if (RXWaitCount == `DISCONNECT_WAIT_TIME)
|
if (RXWaitCount == `DISCONNECT_WAIT_TIME)
|
begin
|
begin
|
Line 317... |
Line 239... |
end
|
end
|
else
|
else
|
begin
|
begin
|
next_RXStMachCurrState <= `CONNECT_FULL_SPEED_ST;
|
next_RXStMachCurrState <= `CONNECT_FULL_SPEED_ST;
|
end
|
end
|
next_processRxBitsWEn <= 1'b1;
|
|
end
|
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
|
|
// Current State Logic (sequential)
|
// Current State Logic (sequential)
|
Line 338... |
Line 258... |
always @ (posedge clk)
|
always @ (posedge clk)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
begin
|
begin
|
connectState <= `DISCONNECT;
|
connectState <= `DISCONNECT;
|
processRxBitsWEn <= 1'b0;
|
|
RxBitsOut <= 2'b00;
|
|
SIERxRdyOut <= 1'b1;
|
|
RXWaitCount <= 8'h00;
|
RXWaitCount <= 8'h00;
|
RXStMachCurrState <= `DISCONNECT_ST;
|
RXStMachCurrState <= `DISCONNECT_ST;
|
RxBits <= 2'b00;
|
RxBits <= 2'b00;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
connectState <= next_connectState;
|
connectState <= next_connectState;
|
processRxBitsWEn <= next_processRxBitsWEn;
|
|
RxBitsOut <= next_RxBitsOut;
|
|
SIERxRdyOut <= next_SIERxRdyOut;
|
|
RXWaitCount <= next_RXWaitCount;
|
RXWaitCount <= next_RXWaitCount;
|
RXStMachCurrState <= next_RXStMachCurrState;
|
RXStMachCurrState <= next_RXStMachCurrState;
|
RxBits <= next_RxBits;
|
RxBits <= next_RxBits;
|
end
|
end
|
end
|
end
|