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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [serialInterfaceEngine/] [processTxByte.v] - Diff between revs 12 and 14

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

Rev 12 Rev 14
Line 44... Line 44...
//
//
`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, fullSpeedRate, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, TxByteCtrlIn, TxByteIn, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn);
module processTxByte (clk, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, TxByteCtrlIn, TxByteFullSpeedRateIn, TxByteIn, USBWireCtrl, USBWireData, USBWireFullSpeedRate, 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;
 
input   TxByteFullSpeedRateIn;
input   [7:0]TxByteIn;
input   [7:0]TxByteIn;
input   USBWireGnt;
input   USBWireGnt;
input   USBWireRdy;
input   USBWireRdy;
output  processTxByteRdy;
output  processTxByteRdy;
output  USBWireCtrl;
output  USBWireCtrl;
output  [1:0]USBWireData;
output  [1:0]USBWireData;
 
output  USBWireFullSpeedRate;
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;
wire    [7:0]TxByteCtrlIn;
wire    [7:0]TxByteCtrlIn;
 
wire    TxByteFullSpeedRateIn;
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;
 
reg     USBWireFullSpeedRate, next_USBWireFullSpeedRate;
wire    USBWireGnt;
wire    USBWireGnt;
wire    USBWireRdy;
wire    USBWireRdy;
reg     USBWireReq, next_USBWireReq;
reg     USBWireReq, next_USBWireReq;
reg     USBWireWEn, next_USBWireWEn;
reg     USBWireWEn, next_USBWireWEn;
 
 
// diagram signals declarations
// diagram signals declarations
reg  [3:0]i, next_i;
reg  [3:0]i, next_i;
reg  [7:0]TxByte, next_TxByte;
reg  [7:0]TxByte, next_TxByte;
reg  [7:0]TxByteCtrl, next_TxByteCtrl;
reg  [7:0]TxByteCtrl, next_TxByteCtrl;
 
reg TxByteFullSpeedRate, next_TxByteFullSpeedRate;
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:
Line 108... Line 111...
`define LS_START_SND_IDLE3 5'b10001
`define LS_START_SND_IDLE3 5'b10001
`define LS_START_SND_J1 5'b10010
`define LS_START_SND_J1 5'b10010
`define LS_START_SND_IDLE1 5'b10011
`define LS_START_SND_IDLE1 5'b10011
`define LS_START_SND_IDLE2 5'b10100
`define LS_START_SND_IDLE2 5'b10100
`define LS_START_FIN 5'b10101
`define LS_START_FIN 5'b10101
 
`define LS_START_W_RDY1 5'b10110
 
`define LS_START_W_RDY2 5'b10111
 
`define LS_START_W_RDY3 5'b11000
 
`define STOP_W_RDY1 5'b11001
 
`define STOP_W_RDY2 5'b11010
 
`define STOP_W_RDY3 5'b11011
 
`define STOP_W_RDY4 5'b11100
 
 
reg [4:0]CurrState_prcTxB, NextState_prcTxB;
reg [4:0]CurrState_prcTxB, 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 @ (processTxByteWEn or TxByteIn or TxByteCtrlIn or TxByteFullSpeedRateIn 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 USBWireFullSpeedRate or TxByteFullSpeedRate or CurrState_prcTxB)
begin
begin
  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;
Line 129... Line 139...
  next_i <= i;
  next_i <= i;
  next_TxByte <= TxByte;
  next_TxByte <= TxByte;
  next_TxByteCtrl <= TxByteCtrl;
  next_TxByteCtrl <= TxByteCtrl;
  next_TXLineState <= TXLineState;
  next_TXLineState <= TXLineState;
  next_TXOneCount <= TXOneCount;
  next_TXOneCount <= TXOneCount;
 
  next_USBWireFullSpeedRate <= USBWireFullSpeedRate;
 
  next_TxByteFullSpeedRate <= TxByteFullSpeedRate;
  case (CurrState_prcTxB)  // synopsys parallel_case full_case
  case (CurrState_prcTxB)  // synopsys parallel_case full_case
    `START_PTBY:
    `START_PTBY:
    begin
    begin
      next_processTxByteRdy <= 1'b0;
      next_processTxByteRdy <= 1'b0;
      next_USBWireData <= 2'b00;
      next_USBWireData <= 2'b00;
Line 142... Line 154...
      next_i <= 4'h0;
      next_i <= 4'h0;
      next_TxByte <= 8'h00;
      next_TxByte <= 8'h00;
      next_TxByteCtrl <= 8'h00;
      next_TxByteCtrl <= 8'h00;
      next_TXLineState <= 2'b0;
      next_TXLineState <= 2'b0;
      next_TXOneCount <= 4'h0;
      next_TXOneCount <= 4'h0;
 
      next_USBWireFullSpeedRate <= 1'b0;
 
      next_TxByteFullSpeedRate <= 1'b0;
      NextState_prcTxB <= `PTBY_WAIT_EN;
      NextState_prcTxB <= `PTBY_WAIT_EN;
    end
    end
    `PTBY_WAIT_EN:
    `PTBY_WAIT_EN:
    begin
    begin
      next_processTxByteRdy <= 1'b1;
      next_processTxByteRdy <= 1'b1;
Line 153... Line 167...
      begin
      begin
        NextState_prcTxB <= `PTBY_WAIT_GNT;
        NextState_prcTxB <= `PTBY_WAIT_GNT;
        next_processTxByteRdy <= 1'b0;
        next_processTxByteRdy <= 1'b0;
        next_TxByte <= TxByteIn;
        next_TxByte <= TxByteIn;
        next_TxByteCtrl <= TxByteCtrlIn;
        next_TxByteCtrl <= TxByteCtrlIn;
 
        next_TxByteFullSpeedRate <= TxByteFullSpeedRateIn;
 
        next_USBWireFullSpeedRate <= TxByteFullSpeedRateIn;
        next_TXOneCount <= 4'h0;
        next_TXOneCount <= 4'h0;
        next_TXLineState <= JBit;
        next_TXLineState <= JBit;
        next_USBWireReq <= 1'b1;
        next_USBWireReq <= 1'b1;
      end
      end
      else if (processTxByteWEn == 1'b1)
      else if (processTxByteWEn == 1'b1)
      begin
      begin
        NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
        NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
        next_processTxByteRdy <= 1'b0;
        next_processTxByteRdy <= 1'b0;
        next_TxByte <= TxByteIn;
        next_TxByte <= TxByteIn;
        next_TxByteCtrl <= TxByteCtrlIn;
        next_TxByteCtrl <= TxByteCtrlIn;
 
        next_TxByteFullSpeedRate <= TxByteFullSpeedRateIn;
 
        next_USBWireFullSpeedRate <= TxByteFullSpeedRateIn;
        next_i <= 4'h0;
        next_i <= 4'h0;
      end
      end
    end
    end
    `PTBY_WAIT_GNT:
    `PTBY_WAIT_GNT:
    begin
    begin
Line 175... Line 193...
        NextState_prcTxB <= `WAIT_RDY_WIRE;
        NextState_prcTxB <= `WAIT_RDY_WIRE;
      end
      end
    end
    end
    `WAIT_RDY_WIRE:
    `WAIT_RDY_WIRE:
    begin
    begin
      if ((USBWireRdy == 1'b1) && (fullSpeedRate == 1'b0))
      if ((USBWireRdy == 1'b1) && (TxByteFullSpeedRate  == 1'b0))
      begin
      begin
        NextState_prcTxB <= `LS_START_SND_IDLE1;
        NextState_prcTxB <= `LS_START_SND_IDLE1;
      end
      end
      else if (USBWireRdy == 1'b1)
      else if (USBWireRdy == 1'b1)
      begin
      begin
Line 275... Line 293...
      end
      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)
      NextState_prcTxB <= `STOP_W_RDY2;
      begin
 
        NextState_prcTxB <= `STOP_SND_J;
 
        next_USBWireWEn <= 1'b1;
 
        next_USBWireData <= `SE0;
 
        next_USBWireCtrl <= `DRIVE;
 
      end
 
    end
    end
    `STOP_SND_SE0_1:
    `STOP_SND_SE0_1:
    begin
    begin
      if (USBWireRdy == 1'b1)
      NextState_prcTxB <= `STOP_W_RDY1;
      begin
 
        NextState_prcTxB <= `STOP_SND_SE0_2;
 
        next_USBWireWEn <= 1'b1;
 
        next_USBWireData <= `SE0;
 
        next_USBWireCtrl <= `DRIVE;
 
      end
 
    end
    end
    `STOP_CHK:
    `STOP_CHK:
    begin
    begin
      if (TxByteCtrl == `DATA_STOP)
      if (TxByteCtrl == `DATA_STOP)
      begin
      begin
Line 307... Line 313...
      end
      end
    end
    end
    `STOP_SND_J:
    `STOP_SND_J:
    begin
    begin
      next_USBWireWEn <= 1'b0;
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `STOP_W_RDY3;
 
    end
 
    `STOP_SND_IDLE:
 
    begin
 
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `STOP_W_RDY4;
 
    end
 
    `STOP_FIN:
 
    begin
 
      next_USBWireWEn <= 1'b0;
 
      next_USBWireReq <= 1'b0;
 
      //release the wire
 
      NextState_prcTxB <= `PTBY_WAIT_EN;
 
    end
 
    `STOP_W_RDY1:
 
    begin
 
      if (USBWireRdy == 1'b1)
 
      begin
 
        NextState_prcTxB <= `STOP_SND_SE0_2;
 
        next_USBWireWEn <= 1'b1;
 
        next_USBWireData <= `SE0;
 
        next_USBWireCtrl <= `DRIVE;
 
      end
 
    end
 
    `STOP_W_RDY2:
 
    begin
 
      if (USBWireRdy == 1'b1)
 
      begin
 
        NextState_prcTxB <= `STOP_SND_J;
 
        next_USBWireWEn <= 1'b1;
 
        next_USBWireData <= `SE0;
 
        next_USBWireCtrl <= `DRIVE;
 
      end
 
    end
 
    `STOP_W_RDY3:
 
    begin
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `STOP_SND_IDLE;
        NextState_prcTxB <= `STOP_SND_IDLE;
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `DRIVE;
        next_USBWireCtrl <= `DRIVE;
      end
      end
    end
    end
    `STOP_SND_IDLE:
    `STOP_W_RDY4:
    begin
    begin
      next_USBWireWEn <= 1'b0;
 
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `STOP_FIN;
        NextState_prcTxB <= `STOP_FIN;
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `TRI_STATE;
        next_USBWireCtrl <= `TRI_STATE;
      end
      end
    end
    end
    `STOP_FIN:
    `LS_START_SND_IDLE3:
    begin
    begin
      next_USBWireWEn <= 1'b0;
      next_USBWireWEn <= 1'b0;
      next_USBWireReq <= 1'b0;
      NextState_prcTxB <= `LS_START_W_RDY2;
      //release the wire
 
      NextState_prcTxB <= `PTBY_WAIT_EN;
 
    end
    end
    `LS_START_SND_IDLE3:
    `LS_START_SND_J1:
    begin
    begin
      next_USBWireWEn <= 1'b0;
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `LS_START_W_RDY3;
 
    end
 
    `LS_START_SND_IDLE1:
 
    begin
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `LS_START_SND_J1;
        NextState_prcTxB <= `LS_START_SND_IDLE2;
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `TRI_STATE;
        next_USBWireCtrl <= `TRI_STATE;
      end
      end
    end
    end
    `LS_START_SND_J1:
    `LS_START_SND_IDLE2:
    begin
    begin
      next_USBWireWEn <= 1'b0;
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `LS_START_W_RDY1;
 
    end
 
    `LS_START_FIN:
 
    begin
 
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
 
      next_i <= 4'h0;
 
    end
 
    `LS_START_W_RDY1:
 
    begin
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `LS_START_FIN;
        NextState_prcTxB <= `LS_START_SND_IDLE3;
        //Drive the first JBit
 
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `DRIVE;
        next_USBWireCtrl <= `TRI_STATE;
      end
      end
    end
    end
    `LS_START_SND_IDLE1:
    `LS_START_W_RDY2:
    begin
    begin
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `LS_START_SND_IDLE2;
        NextState_prcTxB <= `LS_START_SND_J1;
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `TRI_STATE;
        next_USBWireCtrl <= `TRI_STATE;
      end
      end
    end
    end
    `LS_START_SND_IDLE2:
    `LS_START_W_RDY3:
    begin
    begin
      next_USBWireWEn <= 1'b0;
 
      if (USBWireRdy == 1'b1)
      if (USBWireRdy == 1'b1)
      begin
      begin
        NextState_prcTxB <= `LS_START_SND_IDLE3;
        NextState_prcTxB <= `LS_START_FIN;
 
        //Drive the first JBit
        next_USBWireWEn <= 1'b1;
        next_USBWireWEn <= 1'b1;
        next_USBWireData <= JBit;
        next_USBWireData <= JBit;
        next_USBWireCtrl <= `TRI_STATE;
        next_USBWireCtrl <= `DRIVE;
      end
 
    end
    end
    `LS_START_FIN:
 
    begin
 
      next_USBWireWEn <= 1'b0;
 
      NextState_prcTxB <= `SEND_BYTE_UPDATE_BYTE;
 
      next_i <= 4'h0;
 
    end
    end
  endcase
  endcase
end
end
 
 
// Current State Logic (sequential)
// Current State Logic (sequential)
Line 405... Line 451...
    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;
 
    USBWireFullSpeedRate <= 1'b0;
    i <= 4'h0;
    i <= 4'h0;
    TxByte <= 8'h00;
    TxByte <= 8'h00;
    TxByteCtrl <= 8'h00;
    TxByteCtrl <= 8'h00;
    TXLineState <= 2'b0;
    TXLineState <= 2'b0;
    TXOneCount <= 4'h0;
    TXOneCount <= 4'h0;
 
    TxByteFullSpeedRate <= 1'b0;
  end
  end
  else
  else
  begin
  begin
    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;
 
    USBWireFullSpeedRate <= next_USBWireFullSpeedRate;
    i <= next_i;
    i <= next_i;
    TxByte <= next_TxByte;
    TxByte <= next_TxByte;
    TxByteCtrl <= next_TxByteCtrl;
    TxByteCtrl <= next_TxByteCtrl;
    TXLineState <= next_TXLineState;
    TXLineState <= next_TXLineState;
    TXOneCount <= next_TXOneCount;
    TXOneCount <= next_TXOneCount;
 
    TxByteFullSpeedRate <= next_TxByteFullSpeedRate;
  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.