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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [serialInterfaceEngine/] [processRxBit.v] - Diff between revs 40 and 44

Show entire file | Details | Blame | View Log

Rev 40 Rev 44
Line 49... Line 49...
//
//
`include "timescale.v"
`include "timescale.v"
`include "usbSerialInterfaceEngine_h.v"
`include "usbSerialInterfaceEngine_h.v"
 
 
 
 
module processRxBit (JBit, KBit, RxBitsIn, RxCtrlOut, RxDataOut, RxWireActive, clk, processRxBitRdy, processRxBitsWEn, processRxByteRdy, processRxByteWEn, resumeDetected, rst);
module processRxBit (JBit, KBit, RxBitsIn, RxCtrlOut, RxDataOut, RxWireActive, clk, processRxBitRdy, processRxBitsWEn, processRxByteRdy, processRxByteWEn, resumeDetected, rst, fullSpeedBitRate);
input   [1:0] JBit;
input   [1:0] JBit;
input   [1:0] KBit;
input   [1:0] KBit;
input   [1:0] RxBitsIn;
input   [1:0] RxBitsIn;
input   RxWireActive;
input   RxWireActive;
input   clk;
input   clk;
Line 63... Line 63...
output  [7:0] RxCtrlOut;
output  [7:0] RxCtrlOut;
output  [7:0] RxDataOut;
output  [7:0] RxDataOut;
output  processRxBitRdy;
output  processRxBitRdy;
output  processRxByteWEn;
output  processRxByteWEn;
output  resumeDetected;
output  resumeDetected;
 
input fullSpeedBitRate;
 
 
wire    [1:0] JBit;
wire    [1:0] JBit;
wire    [1:0] KBit;
wire    [1:0] KBit;
wire    [1:0] RxBitsIn;
wire    [1:0] RxBitsIn;
reg     [7:0] RxCtrlOut, next_RxCtrlOut;
reg     [7:0] RxCtrlOut, next_RxCtrlOut;
Line 87... Line 88...
reg  [3:0]RXSameBitCount, next_RXSameBitCount;
reg  [3:0]RXSameBitCount, next_RXSameBitCount;
reg  [1:0]RxBits, next_RxBits;
reg  [1:0]RxBits, next_RxBits;
reg  bitStuffError, next_bitStuffError;
reg  bitStuffError, next_bitStuffError;
reg  [1:0]oldRXBits, next_oldRXBits;
reg  [1:0]oldRXBits, next_oldRXBits;
reg  [4:0]resumeWaitCnt, next_resumeWaitCnt;
reg  [4:0]resumeWaitCnt, next_resumeWaitCnt;
 
reg  [7:0]delayCnt, next_delayCnt;
 
 
// BINARY ENCODED state machine: prRxBit
// BINARY ENCODED state machine: prRxBit
// State codes definitions:
// State codes definitions:
`define START 4'b0000
`define START 4'b0000
`define IDLE_FIRST_BIT 4'b0001
`define IDLE_FIRST_BIT 4'b0001
Line 105... Line 107...
`define DATA_RX_ERROR_CHK_RES 4'b1010
`define DATA_RX_ERROR_CHK_RES 4'b1010
`define RES_END_CHK1 4'b1011
`define RES_END_CHK1 4'b1011
`define IDLE_WAIT_PRB_RDY 4'b1100
`define IDLE_WAIT_PRB_RDY 4'b1100
`define DATA_RX_WAIT_PRB_RDY 4'b1101
`define DATA_RX_WAIT_PRB_RDY 4'b1101
`define DATA_RX_ERROR_WAIT_RDY 4'b1110
`define DATA_RX_ERROR_WAIT_RDY 4'b1110
 
`define LOW_SPEED_EOP_DELAY 4'b1111
 
 
reg [3:0] CurrState_prRxBit;
reg [3:0] CurrState_prRxBit;
reg [3:0] NextState_prRxBit;
reg [3:0] NextState_prRxBit;
 
 
 
 
Line 116... Line 119...
// Machine: prRxBit
// Machine: prRxBit
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//----------------------------------
//----------------------------------
// Next State Logic (combinatorial)
// Next State Logic (combinatorial)
//----------------------------------
//----------------------------------
always @ (RxBitsIn or RxBits or oldRXBits or RXSameBitCount or RXBitCount or RXByte or JBit or KBit or resumeWaitCnt or processRxBitsWEn or RXBitStMachCurrState or RxWireActive or processRxByteRdy or bitStuffError or processRxByteWEn or RxCtrlOut or RxDataOut or resumeDetected or processRxBitRdy or CurrState_prRxBit)
always @ (*)
begin : prRxBit_NextState
begin : prRxBit_NextState
  NextState_prRxBit <= CurrState_prRxBit;
  NextState_prRxBit <= CurrState_prRxBit;
  // Set default values for outputs and signals
  // Set default values for outputs and signals
  next_processRxByteWEn <= processRxByteWEn;
  next_processRxByteWEn <= processRxByteWEn;
  next_RxCtrlOut <= RxCtrlOut;
  next_RxCtrlOut <= RxCtrlOut;
Line 132... Line 135...
  next_RXBitCount <= RXBitCount;
  next_RXBitCount <= RXBitCount;
  next_oldRXBits <= oldRXBits;
  next_oldRXBits <= oldRXBits;
  next_RXByte <= RXByte;
  next_RXByte <= RXByte;
  next_bitStuffError <= bitStuffError;
  next_bitStuffError <= bitStuffError;
  next_resumeWaitCnt <= resumeWaitCnt;
  next_resumeWaitCnt <= resumeWaitCnt;
 
  next_delayCnt <= delayCnt;
  next_processRxBitRdy <= processRxBitRdy;
  next_processRxBitRdy <= processRxBitRdy;
  case (CurrState_prRxBit)
  case (CurrState_prRxBit)
    `START:
    `START:
    begin
    begin
      next_processRxByteWEn <= 1'b0;
      next_processRxByteWEn <= 1'b0;
Line 216... Line 220...
      next_processRxBitRdy <= 1'b1;
      next_processRxBitRdy <= 1'b1;
    end
    end
    `DATA_RX_CHK_SE0:
    `DATA_RX_CHK_SE0:
    begin
    begin
      next_bitStuffError <= 1'b0;
      next_bitStuffError <= 1'b0;
      if (RxBits == `SE0)
      if (RxBits == `SE0) begin
 
        if (fullSpeedBitRate == 1'b0) begin
 
          NextState_prRxBit <= `LOW_SPEED_EOP_DELAY;
 
          next_delayCnt <= 8'h00;
 
        end
 
        else
        NextState_prRxBit <= `DATA_RX_WAIT_PRB_RDY;
        NextState_prRxBit <= `DATA_RX_WAIT_PRB_RDY;
 
      end
      else
      else
      begin
      begin
        NextState_prRxBit <= `DATA_RX_DATA_DESTUFF;
        NextState_prRxBit <= `DATA_RX_DATA_DESTUFF;
        if (RxBits == oldRXBits)                 //if the current 'RxBits' are the same as the old 'RxBits', then
        if (RxBits == oldRXBits)                 //if the current 'RxBits' are the same as the old 'RxBits', then
        begin
        begin
Line 345... Line 355...
          //clear resume detected flag
          //clear resume detected flag
      end
      end
      NextState_prRxBit <= `WAIT_BITS;
      NextState_prRxBit <= `WAIT_BITS;
      next_processRxBitRdy <= 1'b1;
      next_processRxBitRdy <= 1'b1;
    end
    end
 
    `LOW_SPEED_EOP_DELAY:
 
    begin
 
      //turn around time must be at least 2 low speed bit periods
 
      next_delayCnt <= delayCnt + 1'b1;
 
      if (delayCnt == `LS_OVER_SAMPLE_RATE * 2)
 
        NextState_prRxBit <= `DATA_RX_WAIT_PRB_RDY;
 
    end
  endcase
  endcase
end
end
 
 
//----------------------------------
//----------------------------------
// Current State Logic (sequential)
// Current State Logic (sequential)
Line 374... Line 391...
    RXBitCount <= 4'h0;
    RXBitCount <= 4'h0;
    oldRXBits <= 2'b00;
    oldRXBits <= 2'b00;
    RXByte <= 8'h00;
    RXByte <= 8'h00;
    bitStuffError <= 1'b0;
    bitStuffError <= 1'b0;
    resumeWaitCnt <= 5'h0;
    resumeWaitCnt <= 5'h0;
 
    delayCnt <= 8'h00;
    processRxByteWEn <= 1'b0;
    processRxByteWEn <= 1'b0;
    RxCtrlOut <= 8'h00;
    RxCtrlOut <= 8'h00;
    RxDataOut <= 8'h00;
    RxDataOut <= 8'h00;
    resumeDetected <= 1'b0;
    resumeDetected <= 1'b0;
    processRxBitRdy <= 1'b1;
    processRxBitRdy <= 1'b1;
Line 390... Line 408...
    RXBitCount <= next_RXBitCount;
    RXBitCount <= next_RXBitCount;
    oldRXBits <= next_oldRXBits;
    oldRXBits <= next_oldRXBits;
    RXByte <= next_RXByte;
    RXByte <= next_RXByte;
    bitStuffError <= next_bitStuffError;
    bitStuffError <= next_bitStuffError;
    resumeWaitCnt <= next_resumeWaitCnt;
    resumeWaitCnt <= next_resumeWaitCnt;
 
    delayCnt <= next_delayCnt;
    processRxByteWEn <= next_processRxByteWEn;
    processRxByteWEn <= next_processRxByteWEn;
    RxCtrlOut <= next_RxCtrlOut;
    RxCtrlOut <= next_RxCtrlOut;
    RxDataOut <= next_RxDataOut;
    RxDataOut <= next_RxDataOut;
    resumeDetected <= next_resumeDetected;
    resumeDetected <= next_resumeDetected;
    processRxBitRdy <= next_processRxBitRdy;
    processRxBitRdy <= next_processRxBitRdy;
  end
  end
end
end
 
 
endmodule
endmodule
 No newline at end of file
 No newline at end of file
 
 
 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.