OpenCores
URL https://opencores.org/ocsvn/usbhostslave/usbhostslave/trunk

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_01_01/] [RTL/] [serialInterfaceEngine/] [processTxByte.v] - Diff between revs 2 and 5

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 5
Line 1... Line 1...
//--------------------------------------------------------------------------------------------------
 
//
//////////////////////////////////////////////////////////////////////
// Title       : No Title
////                                                              ////
// Design      : usbhostslave
//// processTxByte
// Author      : Steve
////                                                              ////
// Company     : Base2Designs
//// This file is part of the usbhostslave opencores effort.
//
//// http://www.opencores.org/cores/usbhostslave/                 ////
//-------------------------------------------------------------------------------------------------
////                                                              ////
 
//// Module Description:                                          ////
 
//// 
 
////                                                              ////
 
//// To Do:                                                       ////
 
//// 
 
////                                                              ////
 
//// Author(s):                                                   ////
 
//// - Steve Fielding, sfielding@base2designs.com                 ////
 
////                                                              ////
 
//////////////////////////////////////////////////////////////////////
 
////                                                              ////
 
//// Copyright (C) 2004 Steve Fielding 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                     ////
 
////                                                              ////
 
//////////////////////////////////////////////////////////////////////
//
//
// File        : c:\projects\USBHostSlave\Aldec\usbhostslave\usbhostslave\compile\processTxByte.v
// $Id: processTxByte.v,v 1.2 2004-12-18 14:36:16 sfielding Exp $
// Generated   : 08/29/04 21:36:09
 
// From        : c:\projects\USBHostSlave\RTL\serialInterfaceEngine\processTxByte.asf
 
// By          : FSM2VHDL ver. 4.0.3.8
 
//
//
//-------------------------------------------------------------------------------------------------
// CVS Revision History
//
//
// Description : 
// $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 (JBit, KBit, TxByteCtrlIn, TxByteIn, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn, clk, processTxByteRdy, processTxByteWEn, rst);
module processTxByte (clk, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, TxByteCtrlIn, TxByteIn, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn);
 
input   clk;
input   [1:0] JBit;
input   [1:0] JBit;
input   [1:0] KBit;
input   [1:0] KBit;
 
input   processTxByteWEn;
 
input   rst;
input   [7:0] TxByteCtrlIn;
input   [7:0] TxByteCtrlIn;
input   [7:0] TxByteIn;
input   [7:0] TxByteIn;
input   USBWireGnt;
input   USBWireGnt;
input   USBWireRdy;
input   USBWireRdy;
input   clk;
output  processTxByteRdy;
input   processTxByteWEn;
 
input   rst;
 
output  USBWireCtrl;
output  USBWireCtrl;
output  [1:0] USBWireData;
output  [1:0] USBWireData;
output  USBWireReq;
output  USBWireReq;
output  USBWireWEn;
output  USBWireWEn;
output  processTxByteRdy;
 
 
 
 
wire    clk;
wire    [1:0] JBit;
wire    [1:0] JBit;
wire    [1:0] KBit;
wire    [1:0] KBit;
 
reg     processTxByteRdy, next_processTxByteRdy;
 
wire    processTxByteWEn;
 
wire    rst;
wire    [7:0] TxByteCtrlIn;
wire    [7:0] TxByteCtrlIn;
wire    [7:0] TxByteIn;
wire    [7:0] TxByteIn;
reg     USBWireCtrl, next_USBWireCtrl;
reg     USBWireCtrl, next_USBWireCtrl;
reg     [1:0] USBWireData, next_USBWireData;
reg     [1:0] USBWireData, next_USBWireData;
wire    USBWireGnt;
wire    USBWireGnt;
wire    USBWireRdy;
wire    USBWireRdy;
reg     USBWireReq, next_USBWireReq;
reg     USBWireReq, next_USBWireReq;
reg     USBWireWEn, next_USBWireWEn;
reg     USBWireWEn, next_USBWireWEn;
wire    clk;
 
reg     processTxByteRdy, next_processTxByteRdy;
 
wire    processTxByteWEn;
 
wire    rst;
 
 
 
// diagram signals declarations
// diagram signals declarations
 
reg  [3:0]i, next_i;
 
reg  [7:0]TxByte, next_TxByte;
 
reg  [7:0]TxByteCtrl, next_TxByteCtrl;
reg  [1:0]TXLineState, next_TXLineState;
reg  [1:0]TXLineState, next_TXLineState;
reg  [3:0]TXOneCount, next_TXOneCount;
reg  [3:0]TXOneCount, next_TXOneCount;
reg  [7:0]TxByteCtrl, next_TxByteCtrl;
 
reg  [7:0]TxByte, next_TxByte;
 
reg  [3:0]i, next_i;
 
 
 
// BINARY ENCODED state machine: prcTxB
// BINARY ENCODED state machine: prcTxB
// State codes definitions:
// State codes definitions:
`define START_PTBY 4'b0000
`define START_PTBY 4'b0000
`define PTBY_WAIT_EN 4'b0001
`define PTBY_WAIT_EN 4'b0001
Line 76... Line 106...
`define STOP_CHK 4'b1011
`define STOP_CHK 4'b1011
`define STOP_SND_J 4'b1100
`define STOP_SND_J 4'b1100
`define STOP_SND_IDLE 4'b1101
`define STOP_SND_IDLE 4'b1101
`define STOP_FIN 4'b1110
`define STOP_FIN 4'b1110
 
 
reg [3:0] CurrState_prcTxB;
reg [3:0]CurrState_prcTxB, NextState_prcTxB;
reg [3:0] NextState_prcTxB;
 
 
 
 
 
//--------------------------------------------------------------------
 
// Machine: prcTxB
// Machine: prcTxB
//--------------------------------------------------------------------
 
//----------------------------------
 
// NextState logic (combinatorial)
// NextState logic (combinatorial)
//----------------------------------
always @ (processTxByteWEn or TxByteIn or TxByteCtrlIn or i or TxByte or TXOneCount or KBit or JBit or USBWireRdy or TXLineState or USBWireGnt or TxByteCtrl or processTxByteRdy or USBWireData or USBWireCtrl or USBWireReq or USBWireWEn or CurrState_prcTxB)
always @ (TxByteIn or TxByteCtrlIn or JBit or i or TxByte or TXOneCount or TXLineState or KBit or processTxByteWEn or USBWireGnt or USBWireRdy or TxByteCtrl or processTxByteRdy or USBWireData or USBWireCtrl or USBWireReq or USBWireWEn or CurrState_prcTxB)
begin
begin : prcTxB_NextState
 
        NextState_prcTxB <= CurrState_prcTxB;
        NextState_prcTxB <= CurrState_prcTxB;
        // Set default values for outputs and signals
        // Set default values for outputs and signals
        next_processTxByteRdy <= processTxByteRdy;
        next_processTxByteRdy <= processTxByteRdy;
        next_USBWireData <= USBWireData;
        next_USBWireData <= USBWireData;
        next_USBWireCtrl <= USBWireCtrl;
        next_USBWireCtrl <= USBWireCtrl;
Line 138... Line 164...
                                next_TxByteCtrl <= TxByteCtrlIn;
                                next_TxByteCtrl <= TxByteCtrlIn;
                                next_i <= 4'h0;
                                next_i <= 4'h0;
                        end
                        end
                end
                end
                `PTBY_WAIT_GNT:
                `PTBY_WAIT_GNT:
 
    begin
                        if (USBWireGnt == 1'b1)
                        if (USBWireGnt == 1'b1)
                        begin
                        begin
                                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 154... Line 182...
                            //increment 'TXOneCount'
                            //increment 'TXOneCount'
                        else                                        //else this is a zero bit
                        else                                        //else this is a zero bit
                        begin
                        begin
                          next_TXOneCount <= 4'h1;
                          next_TXOneCount <= 4'h1;
                            //reset 'TXOneCount'
                            //reset 'TXOneCount'
                          if (TXLineState == JBit) next_TXLineState <= KBit;
      if (TXLineState == JBit)
 
      next_TXLineState <= KBit;
                            //toggle the line state
                            //toggle the line state
                          else next_TXLineState <= JBit;
      else
 
      next_TXLineState <= JBit;
                        end
                        end
                        NextState_prcTxB <= `SEND_BYTE_WAIT_RDY;
                        NextState_prcTxB <= `SEND_BYTE_WAIT_RDY;
                end
                end
                `SEND_BYTE_WAIT_RDY:
                `SEND_BYTE_WAIT_RDY:
 
    begin
                        if (USBWireRdy == 1'b1)
                        if (USBWireRdy == 1'b1)
                        begin
                        begin
                                NextState_prcTxB <= `SEND_BYTE_CHK;
                                NextState_prcTxB <= `SEND_BYTE_CHK;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireData <= TXLineState;
                                next_USBWireData <= TXLineState;
                                next_USBWireCtrl <= `DRIVE;
                                next_USBWireCtrl <= `DRIVE;
                        end
                        end
 
    end
                `SEND_BYTE_CHK:
                `SEND_BYTE_CHK:
                begin
                begin
                        next_USBWireWEn <= 1'b0;
                        next_USBWireWEn <= 1'b0;
                        if (TXOneCount == 4'h6)
                        if (TXOneCount == 4'h6)
 
      begin
                                NextState_prcTxB <= `SEND_BYTE_BIT_STUFF;
                                NextState_prcTxB <= `SEND_BYTE_BIT_STUFF;
 
      end
                        else if (i != 4'h8)
                        else if (i != 4'h8)
 
      begin
                                NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
                                NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
 
      end
                        else
                        else
 
      begin
                                NextState_prcTxB <= `STOP_CHK;
                                NextState_prcTxB <= `STOP_CHK;
                end
                end
 
    end
                `SEND_BYTE_BIT_STUFF:
                `SEND_BYTE_BIT_STUFF:
                begin
                begin
                        next_TXOneCount <= 4'h1;
                        next_TXOneCount <= 4'h1;
                        //reset 'TXOneCount'
                        //reset 'TXOneCount'
                        if (TXLineState == JBit) next_TXLineState <= KBit;
      if (TXLineState == JBit)
 
      next_TXLineState <= KBit;
                        //toggle the line state
                        //toggle the line state
                        else next_TXLineState <= JBit;
      else
 
      next_TXLineState <= JBit;
                        NextState_prcTxB <= `SEND_BYTE_WAIT_RDY2;
                        NextState_prcTxB <= `SEND_BYTE_WAIT_RDY2;
                end
                end
                `SEND_BYTE_WAIT_RDY2:
                `SEND_BYTE_WAIT_RDY2:
 
    begin
                        if (USBWireRdy == 1'b1)
                        if (USBWireRdy == 1'b1)
                        begin
                        begin
                                NextState_prcTxB <= `SEND_BYTE_CHK_FIN;
                                NextState_prcTxB <= `SEND_BYTE_CHK_FIN;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireData <= TXLineState;
                                next_USBWireData <= TXLineState;
                                next_USBWireCtrl <= `DRIVE;
                                next_USBWireCtrl <= `DRIVE;
                        end
                        end
 
    end
                `SEND_BYTE_CHK_FIN:
                `SEND_BYTE_CHK_FIN:
                begin
                begin
                        next_USBWireWEn <= 1'b0;
                        next_USBWireWEn <= 1'b0;
                        if (i == 4'h8)
                        if (i == 4'h8)
 
      begin
                                NextState_prcTxB <= `STOP_CHK;
                                NextState_prcTxB <= `STOP_CHK;
 
      end
                        else
                        else
 
      begin
                                NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
                                NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
                end
                end
 
    end
                `STOP_SND_SE0_2:
                `STOP_SND_SE0_2:
                begin
                begin
                        next_USBWireWEn <= 1'b0;
                        next_USBWireWEn <= 1'b0;
                        if (USBWireRdy == 1'b1)
                        if (USBWireRdy == 1'b1)
                        begin
                        begin
Line 215... Line 261...
                                next_USBWireData <= `SE0;
                                next_USBWireData <= `SE0;
                                next_USBWireCtrl <= `DRIVE;
                                next_USBWireCtrl <= `DRIVE;
                        end
                        end
                end
                end
                `STOP_SND_SE0_1:
                `STOP_SND_SE0_1:
 
    begin
                        if (USBWireRdy == 1'b1)
                        if (USBWireRdy == 1'b1)
                        begin
                        begin
                                NextState_prcTxB <= `STOP_SND_SE0_2;
                                NextState_prcTxB <= `STOP_SND_SE0_2;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireWEn <= 1'b1;
                                next_USBWireData <= `SE0;
                                next_USBWireData <= `SE0;
                                next_USBWireCtrl <= `DRIVE;
                                next_USBWireCtrl <= `DRIVE;
                        end
                        end
 
    end
                `STOP_CHK:
                `STOP_CHK:
 
    begin
                        if (TxByteCtrl == `DATA_STOP)
                        if (TxByteCtrl == `DATA_STOP)
 
      begin
                                NextState_prcTxB <= `STOP_SND_SE0_1;
                                NextState_prcTxB <= `STOP_SND_SE0_1;
 
      end
                        else
                        else
 
      begin
                                NextState_prcTxB <= `PTBY_WAIT_EN;
                                NextState_prcTxB <= `PTBY_WAIT_EN;
 
      end
 
    end
                `STOP_SND_J:
                `STOP_SND_J:
                begin
                begin
                        next_USBWireWEn <= 1'b0;
                        next_USBWireWEn <= 1'b0;
                        if (USBWireRdy == 1'b1)
                        if (USBWireRdy == 1'b1)
                        begin
                        begin
Line 259... Line 313...
                        NextState_prcTxB <= `PTBY_WAIT_EN;
                        NextState_prcTxB <= `PTBY_WAIT_EN;
                end
                end
        endcase
        endcase
end
end
 
 
//----------------------------------
 
// Current State Logic (sequential)
// Current State Logic (sequential)
//----------------------------------
 
always @ (posedge clk)
always @ (posedge clk)
begin : prcTxB_CurrentState
begin
        if (rst)
        if (rst)
                CurrState_prcTxB <= `START_PTBY;
                CurrState_prcTxB <= `START_PTBY;
        else
        else
                CurrState_prcTxB <= NextState_prcTxB;
                CurrState_prcTxB <= NextState_prcTxB;
end
end
 
 
//----------------------------------
 
// Registered outputs logic
// Registered outputs logic
//----------------------------------
 
always @ (posedge clk)
always @ (posedge clk)
begin : prcTxB_RegOutput
begin
        if (rst)
        if (rst)
        begin
        begin
                i <= 4'h0;
 
                TxByte <= 8'h00;
 
                TxByteCtrl <= 8'h00;
 
                TXLineState <= 2'b0;
 
                TXOneCount <= 4'h0;
 
                processTxByteRdy <= 1'b0;
                processTxByteRdy <= 1'b0;
                USBWireData <= 2'b00;
                USBWireData <= 2'b00;
                USBWireCtrl <= `TRI_STATE;
                USBWireCtrl <= `TRI_STATE;
                USBWireReq <= 1'b0;
                USBWireReq <= 1'b0;
                USBWireWEn <= 1'b0;
                USBWireWEn <= 1'b0;
 
    i <= 4'h0;
 
    TxByte <= 8'h00;
 
    TxByteCtrl <= 8'h00;
 
    TXLineState <= 2'b0;
 
    TXOneCount <= 4'h0;
        end
        end
        else
        else
        begin
        begin
                i <= next_i;
 
                TxByte <= next_TxByte;
 
                TxByteCtrl <= next_TxByteCtrl;
 
                TXLineState <= next_TXLineState;
 
                TXOneCount <= next_TXOneCount;
 
                processTxByteRdy <= next_processTxByteRdy;
                processTxByteRdy <= next_processTxByteRdy;
                USBWireData <= next_USBWireData;
                USBWireData <= next_USBWireData;
                USBWireCtrl <= next_USBWireCtrl;
                USBWireCtrl <= next_USBWireCtrl;
                USBWireReq <= next_USBWireReq;
                USBWireReq <= next_USBWireReq;
                USBWireWEn <= next_USBWireWEn;
                USBWireWEn <= next_USBWireWEn;
 
    i <= next_i;
 
    TxByte <= next_TxByte;
 
    TxByteCtrl <= next_TxByteCtrl;
 
    TXLineState <= next_TXLineState;
 
    TXOneCount <= next_TXOneCount;
        end
        end
end
end
 
 
endmodule
endmodule
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.