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: processTxByte.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"
|
`include "usbConstants_h.v"
|
`include "usbConstants_h.v"
|
|
|
module processTxByte (clk, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, TxByteCtrlIn, TxByteIn, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn);
|
module processTxByte (clk, fullSpeedRate, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, TxByteCtrlIn, TxByteIn, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn);
|
input clk;
|
input clk;
|
|
input fullSpeedRate;
|
input [1:0]JBit;
|
input [1:0]JBit;
|
input [1:0]KBit;
|
input [1:0]KBit;
|
input processTxByteWEn;
|
input processTxByteWEn;
|
input rst;
|
input rst;
|
input [7:0]TxByteCtrlIn;
|
input [7:0]TxByteCtrlIn;
|
Line 67... |
Line 62... |
output [1:0]USBWireData;
|
output [1:0]USBWireData;
|
output USBWireReq;
|
output USBWireReq;
|
output USBWireWEn;
|
output USBWireWEn;
|
|
|
wire clk;
|
wire clk;
|
|
wire fullSpeedRate;
|
wire [1:0]JBit;
|
wire [1:0]JBit;
|
wire [1:0]KBit;
|
wire [1:0]KBit;
|
reg processTxByteRdy, next_processTxByteRdy;
|
reg processTxByteRdy, next_processTxByteRdy;
|
wire processTxByteWEn;
|
wire processTxByteWEn;
|
wire rst;
|
wire rst;
|
Line 90... |
Line 86... |
reg [1:0]TXLineState, next_TXLineState;
|
reg [1:0]TXLineState, next_TXLineState;
|
reg [3:0]TXOneCount, next_TXOneCount;
|
reg [3:0]TXOneCount, next_TXOneCount;
|
|
|
// BINARY ENCODED state machine: prcTxB
|
// BINARY ENCODED state machine: prcTxB
|
// State codes definitions:
|
// State codes definitions:
|
`define START_PTBY 4'b0000
|
`define START_PTBY 5'b00000
|
`define PTBY_WAIT_EN 4'b0001
|
`define PTBY_WAIT_EN 5'b00001
|
`define SEND_BYTE_UPDATE_BYTE 4'b0010
|
`define SEND_BYTE_UPDATE_BYTE 5'b00010
|
`define SEND_BYTE_WAIT_RDY 4'b0011
|
`define SEND_BYTE_WAIT_RDY 5'b00011
|
`define SEND_BYTE_CHK 4'b0100
|
`define SEND_BYTE_CHK 5'b00100
|
`define SEND_BYTE_BIT_STUFF 4'b0101
|
`define SEND_BYTE_BIT_STUFF 5'b00101
|
`define SEND_BYTE_WAIT_RDY2 4'b0110
|
`define SEND_BYTE_WAIT_RDY2 5'b00110
|
`define SEND_BYTE_CHK_FIN 4'b0111
|
`define SEND_BYTE_CHK_FIN 5'b00111
|
`define PTBY_WAIT_GNT 4'b1000
|
`define PTBY_WAIT_GNT 5'b01000
|
`define STOP_SND_SE0_2 4'b1001
|
`define STOP_SND_SE0_2 5'b01001
|
`define STOP_SND_SE0_1 4'b1010
|
`define STOP_SND_SE0_1 5'b01010
|
`define STOP_CHK 4'b1011
|
`define STOP_CHK 5'b01011
|
`define STOP_SND_J 4'b1100
|
`define STOP_SND_J 5'b01100
|
`define STOP_SND_IDLE 4'b1101
|
`define STOP_SND_IDLE 5'b01101
|
`define STOP_FIN 4'b1110
|
`define STOP_FIN 5'b01110
|
|
`define WAIT_RDY_WIRE 5'b01111
|
|
`define WAIT_RDY_PKT 5'b10000
|
|
`define LS_START_SND_IDLE3 5'b10001
|
|
`define LS_START_SND_J1 5'b10010
|
|
`define LS_START_SND_IDLE1 5'b10011
|
|
`define LS_START_SND_IDLE2 5'b10100
|
|
`define LS_START_FIN 5'b10101
|
|
|
reg [3:0]CurrState_prcTxB, NextState_prcTxB;
|
reg [4:0]CurrState_prcTxB, NextState_prcTxB;
|
|
|
|
|
// Machine: prcTxB
|
// Machine: prcTxB
|
|
|
// NextState logic (combinatorial)
|
// NextState logic (combinatorial)
|
Line 167... |
Line 170... |
end
|
end
|
`PTBY_WAIT_GNT:
|
`PTBY_WAIT_GNT:
|
begin
|
begin
|
if (USBWireGnt == 1'b1)
|
if (USBWireGnt == 1'b1)
|
begin
|
begin
|
|
NextState_prcTxB <= `WAIT_RDY_WIRE;
|
|
end
|
|
end
|
|
`WAIT_RDY_WIRE:
|
|
begin
|
|
if ((USBWireRdy == 1'b1) && (fullSpeedRate == 1'b0))
|
|
begin
|
|
NextState_prcTxB <= `LS_START_SND_IDLE1;
|
|
end
|
|
else if (USBWireRdy == 1'b1)
|
|
begin
|
|
NextState_prcTxB <= `WAIT_RDY_PKT;
|
|
//actively drive the first J bit
|
|
next_USBWireData <= JBit;
|
|
next_USBWireCtrl <= `DRIVE;
|
|
next_USBWireWEn <= 1'b1;
|
|
end
|
|
end
|
|
`WAIT_RDY_PKT:
|
|
begin
|
|
next_USBWireWEn <= 1'b0;
|
NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
|
NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
|
next_i <= 4'h0;
|
next_i <= 4'h0;
|
end
|
end
|
end
|
|
`SEND_BYTE_UPDATE_BYTE:
|
`SEND_BYTE_UPDATE_BYTE:
|
begin
|
begin
|
next_i <= i + 1'b1;
|
next_i <= i + 1'b1;
|
next_TxByte <= {1'b0, TxByte[7:1] };
|
next_TxByte <= {1'b0, TxByte[7:1] };
|
if (TxByte[0] == 1'b1) //If this bit is 1, then
|
if (TxByte[0] == 1'b1) //If this bit is 1, then
|
Line 310... |
Line 333... |
next_USBWireWEn <= 1'b0;
|
next_USBWireWEn <= 1'b0;
|
next_USBWireReq <= 1'b0;
|
next_USBWireReq <= 1'b0;
|
//release the wire
|
//release the wire
|
NextState_prcTxB <= `PTBY_WAIT_EN;
|
NextState_prcTxB <= `PTBY_WAIT_EN;
|
end
|
end
|
|
`LS_START_SND_IDLE3:
|
|
begin
|
|
next_USBWireWEn <= 1'b0;
|
|
if (USBWireRdy == 1'b1)
|
|
begin
|
|
NextState_prcTxB <= `LS_START_SND_J1;
|
|
next_USBWireWEn <= 1'b1;
|
|
next_USBWireData <= JBit;
|
|
next_USBWireCtrl <= `TRI_STATE;
|
|
end
|
|
end
|
|
`LS_START_SND_J1:
|
|
begin
|
|
next_USBWireWEn <= 1'b0;
|
|
if (USBWireRdy == 1'b1)
|
|
begin
|
|
NextState_prcTxB <= `LS_START_FIN;
|
|
//Drive the first JBit
|
|
next_USBWireWEn <= 1'b1;
|
|
next_USBWireData <= JBit;
|
|
next_USBWireCtrl <= `DRIVE;
|
|
end
|
|
end
|
|
`LS_START_SND_IDLE1:
|
|
begin
|
|
if (USBWireRdy == 1'b1)
|
|
begin
|
|
NextState_prcTxB <= `LS_START_SND_IDLE2;
|
|
next_USBWireWEn <= 1'b1;
|
|
next_USBWireData <= JBit;
|
|
next_USBWireCtrl <= `TRI_STATE;
|
|
end
|
|
end
|
|
`LS_START_SND_IDLE2:
|
|
begin
|
|
next_USBWireWEn <= 1'b0;
|
|
if (USBWireRdy == 1'b1)
|
|
begin
|
|
NextState_prcTxB <= `LS_START_SND_IDLE3;
|
|
next_USBWireWEn <= 1'b1;
|
|
next_USBWireData <= JBit;
|
|
next_USBWireCtrl <= `TRI_STATE;
|
|
end
|
|
end
|
|
`LS_START_FIN:
|
|
begin
|
|
next_USBWireWEn <= 1'b0;
|
|
NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
|
|
next_i <= 4'h0;
|
|
end
|
endcase
|
endcase
|
end
|
end
|
|
|
// Current State Logic (sequential)
|
// Current State Logic (sequential)
|
always @ (posedge clk)
|
always @ (posedge clk)
|