| Line 1... | Line 1... | 
      
        | //--------------------------------------------------------------------------------------------------
 |  
 | 
      
        | //
 | //////////////////////////////////////////////////////////////////////
 | 
      
        | // Title       : No Title
 | ////                                                              ////
 | 
      
        | // Design      : usbhostslave
 | //// sofcontroller
 | 
      
        | // 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\sofcontroller.v
 | // $Id: sofcontroller.v,v 1.2 2004-12-18 14:36:11 sfielding Exp $
 | 
      
        | // Generated   : 09/08/04 06:24:36
 |   | 
      
        | // From        : c:\projects\USBHostSlave\RTL\hostController\sofcontroller.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"
 | 
      
        |  
 |  
 | 
      
        | module SOFController (HCTxPortCntl, HCTxPortData, HCTxPortGnt, HCTxPortRdy, HCTxPortReq, HCTxPortWEn, SOFEnable, SOFTimerClr, SOFTimer, clk, rst);
 | module SOFController (clk, HCTxPortCntl, HCTxPortData, HCTxPortGnt, HCTxPortRdy, HCTxPortReq, HCTxPortWEn, rst, SOFEnable, SOFTimer, SOFTimerClr);
 | 
      
        |   | input   clk;
 | 
      
        | input   HCTxPortGnt;
 | input   HCTxPortGnt;
 | 
      
        | input   HCTxPortRdy;
 | input   HCTxPortRdy;
 | 
      
        |   | input   rst;
 | 
      
        | input   SOFEnable;
 | input   SOFEnable;
 | 
      
        | input   SOFTimerClr;
 | input   SOFTimerClr;
 | 
      
        | input   clk;
 |   | 
      
        | input   rst;
 |   | 
      
        | output  [7:0] HCTxPortCntl;
 | output  [7:0] HCTxPortCntl;
 | 
      
        | output  [7:0] HCTxPortData;
 | output  [7:0] HCTxPortData;
 | 
      
        | output  HCTxPortReq;
 | output  HCTxPortReq;
 | 
      
        | output  HCTxPortWEn;
 | output  HCTxPortWEn;
 | 
      
        | output  [15:0] SOFTimer;
 | output  [15:0] SOFTimer;
 | 
      
        |  
 |  
 | 
      
        |   | wire    clk;
 | 
      
        | reg     [7:0] HCTxPortCntl, next_HCTxPortCntl;
 | reg     [7:0] HCTxPortCntl, next_HCTxPortCntl;
 | 
      
        | reg     [7:0] HCTxPortData, next_HCTxPortData;
 | reg     [7:0] HCTxPortData, next_HCTxPortData;
 | 
      
        | wire    HCTxPortGnt;
 | wire    HCTxPortGnt;
 | 
      
        | wire    HCTxPortRdy;
 | wire    HCTxPortRdy;
 | 
      
        | reg     HCTxPortReq, next_HCTxPortReq;
 | reg     HCTxPortReq, next_HCTxPortReq;
 | 
      
        | reg     HCTxPortWEn, next_HCTxPortWEn;
 | reg     HCTxPortWEn, next_HCTxPortWEn;
 | 
      
        |   | wire    rst;
 | 
      
        | wire    SOFEnable;
 | wire    SOFEnable;
 | 
      
        | wire    SOFTimerClr;
 |   | 
      
        | reg     [15:0] SOFTimer, next_SOFTimer;
 | reg     [15:0] SOFTimer, next_SOFTimer;
 | 
      
        | wire    clk;
 | wire    SOFTimerClr;
 | 
      
        | wire    rst;
 |   | 
      
        |  
 |  
 | 
      
        | // BINARY ENCODED state machine: sofCntl
 | // BINARY ENCODED state machine: sofCntl
 | 
      
        | // State codes definitions:
 | // State codes definitions:
 | 
      
        | `define START_SC 3'b000
 | `define START_SC 3'b000
 | 
      
        | `define WAIT_SOF_EN 3'b001
 | `define WAIT_SOF_EN 3'b001
 | 
      
        | `define WAIT_SEND_RESUME 3'b010
 | `define WAIT_SEND_RESUME 3'b010
 | 
      
        | `define INC_TIMER 3'b011
 | `define INC_TIMER 3'b011
 | 
      
        | `define SC_WAIT_GNT 3'b100
 | `define SC_WAIT_GNT 3'b100
 | 
      
        | `define CLR_WEN 3'b101
 | `define CLR_WEN 3'b101
 | 
      
        |  
 |  
 | 
      
        | reg [2:0] CurrState_sofCntl;
 | reg [2:0]CurrState_sofCntl, NextState_sofCntl;
 | 
      
        | reg [2:0] NextState_sofCntl;
 |   | 
      
        |  
 |  
 | 
      
        |  
 |  
 | 
      
        | //--------------------------------------------------------------------
 |   | 
      
        | // Machine: sofCntl
 | // Machine: sofCntl
 | 
      
        | //--------------------------------------------------------------------
 |  
 | 
      
        | //----------------------------------
 |   | 
      
        | // NextState logic (combinatorial)
 | // NextState logic (combinatorial)
 | 
      
        | //----------------------------------
 | always @ (SOFTimerClr or SOFEnable or HCTxPortRdy or SOFTimer or HCTxPortGnt or HCTxPortCntl or HCTxPortData or HCTxPortWEn or HCTxPortReq or CurrState_sofCntl)
 | 
      
        | always @ (SOFTimerClr or SOFTimer or SOFEnable or HCTxPortRdy or HCTxPortGnt or HCTxPortReq or HCTxPortWEn or HCTxPortData or HCTxPortCntl or CurrState_sofCntl)
 | begin
 | 
      
        | begin : sofCntl_NextState
 |   | 
      
        |         NextState_sofCntl <= CurrState_sofCntl;
 |         NextState_sofCntl <= CurrState_sofCntl;
 | 
      
        |         // Set default values for outputs and signals
 |         // Set default values for outputs and signals
 | 
      
        |         next_HCTxPortReq <= HCTxPortReq;
 |   | 
      
        |         next_HCTxPortWEn <= HCTxPortWEn;
 |   | 
      
        |         next_HCTxPortData <= HCTxPortData;
 |   | 
      
        |         next_HCTxPortCntl <= HCTxPortCntl;
 |   | 
      
        |         next_SOFTimer <= SOFTimer;
 |         next_SOFTimer <= SOFTimer;
 | 
      
        |   |   next_HCTxPortCntl <= HCTxPortCntl;
 | 
      
        |   |   next_HCTxPortData <= HCTxPortData;
 | 
      
        |   |   next_HCTxPortWEn <= HCTxPortWEn;
 | 
      
        |   |   next_HCTxPortReq <= HCTxPortReq;
 | 
      
        |         case (CurrState_sofCntl) // synopsys parallel_case full_case
 |         case (CurrState_sofCntl) // synopsys parallel_case full_case
 | 
      
        |                 `START_SC:
 |                 `START_SC:
 | 
      
        |   |     begin
 | 
      
        |                         NextState_sofCntl <= `WAIT_SOF_EN;
 |                         NextState_sofCntl <= `WAIT_SOF_EN;
 | 
      
        |   |     end
 | 
      
        |                 `WAIT_SOF_EN:
 |                 `WAIT_SOF_EN:
 | 
      
        |   |     begin
 | 
      
        |                         if (SOFEnable == 1'b1)
 |                         if (SOFEnable == 1'b1)
 | 
      
        |                         begin
 |                         begin
 | 
      
        |                                 NextState_sofCntl <= `SC_WAIT_GNT;
 |                                 NextState_sofCntl <= `SC_WAIT_GNT;
 | 
      
        |                                 next_HCTxPortReq <= 1'b1;
 |                                 next_HCTxPortReq <= 1'b1;
 | 
      
        |                         end
 |                         end
 | 
      
        |   |     end
 | 
      
        |                 `WAIT_SEND_RESUME:
 |                 `WAIT_SEND_RESUME:
 | 
      
        |   |     begin
 | 
      
        |                         if (HCTxPortRdy == 1'b1)
 |                         if (HCTxPortRdy == 1'b1)
 | 
      
        |                         begin
 |                         begin
 | 
      
        |                                 NextState_sofCntl <= `CLR_WEN;
 |                                 NextState_sofCntl <= `CLR_WEN;
 | 
      
        |                                 next_HCTxPortWEn <= 1'b1;
 |                                 next_HCTxPortWEn <= 1'b1;
 | 
      
        |                                 next_HCTxPortData <= 8'h00;
 |                                 next_HCTxPortData <= 8'h00;
 | 
      
        |                                 next_HCTxPortCntl <= `TX_RESUME_START;
 |                                 next_HCTxPortCntl <= `TX_RESUME_START;
 | 
      
        |                         end
 |                         end
 | 
      
        |   |     end
 | 
      
        |                 `INC_TIMER:
 |                 `INC_TIMER:
 | 
      
        |                 begin
 |                 begin
 | 
      
        |                         next_HCTxPortReq <= 1'b0;
 |                         next_HCTxPortReq <= 1'b0;
 | 
      
        |                         if (SOFTimerClr == 1'b1)
 |                         if (SOFTimerClr == 1'b1)
 | 
      
        |                           next_SOFTimer <= 16'h0000;
 |                           next_SOFTimer <= 16'h0000;
 | 
      
        | Line 103... | Line 135... | 
      
        |                                 NextState_sofCntl <= `WAIT_SOF_EN;
 |                                 NextState_sofCntl <= `WAIT_SOF_EN;
 | 
      
        |                                 next_SOFTimer <= 16'h0000;
 |                                 next_SOFTimer <= 16'h0000;
 | 
      
        |                         end
 |                         end
 | 
      
        |                 end
 |                 end
 | 
      
        |                 `SC_WAIT_GNT:
 |                 `SC_WAIT_GNT:
 | 
      
        |   |     begin
 | 
      
        |                         if (HCTxPortGnt == 1'b1)
 |                         if (HCTxPortGnt == 1'b1)
 | 
      
        |   |       begin
 | 
      
        |                                 NextState_sofCntl <= `WAIT_SEND_RESUME;
 |                                 NextState_sofCntl <= `WAIT_SEND_RESUME;
 | 
      
        |   |       end
 | 
      
        |   |     end
 | 
      
        |                 `CLR_WEN:
 |                 `CLR_WEN:
 | 
      
        |                 begin
 |                 begin
 | 
      
        |                         next_HCTxPortWEn <= 1'b0;
 |                         next_HCTxPortWEn <= 1'b0;
 | 
      
        |                         NextState_sofCntl <= `INC_TIMER;
 |                         NextState_sofCntl <= `INC_TIMER;
 | 
      
        |                 end
 |                 end
 | 
      
        |         endcase
 |         endcase
 | 
      
        | end
 | end
 | 
      
        |  
 |  
 | 
      
        | //----------------------------------
 |   | 
      
        | // Current State Logic (sequential)
 | // Current State Logic (sequential)
 | 
      
        | //----------------------------------
 |   | 
      
        | always @ (posedge clk)
 | always @ (posedge clk)
 | 
      
        | begin : sofCntl_CurrentState
 | begin
 | 
      
        |         if (rst)
 |         if (rst)
 | 
      
        |                 CurrState_sofCntl <= `START_SC;
 |                 CurrState_sofCntl <= `START_SC;
 | 
      
        |         else
 |         else
 | 
      
        |                 CurrState_sofCntl <= NextState_sofCntl;
 |                 CurrState_sofCntl <= NextState_sofCntl;
 | 
      
        | end
 | end
 | 
      
        |  
 |  
 | 
      
        | //----------------------------------
 |   | 
      
        | // Registered outputs logic
 | // Registered outputs logic
 | 
      
        | //----------------------------------
 |   | 
      
        | always @ (posedge clk)
 | always @ (posedge clk)
 | 
      
        | begin : sofCntl_RegOutput
 | begin
 | 
      
        |         if (rst)
 |         if (rst)
 | 
      
        |         begin
 |         begin
 | 
      
        |                 SOFTimer <= 16'h0000;
 |                 SOFTimer <= 16'h0000;
 | 
      
        |                 HCTxPortCntl <= 8'h00;
 |                 HCTxPortCntl <= 8'h00;
 | 
      
        |                 HCTxPortData <= 8'h00;
 |                 HCTxPortData <= 8'h00;
 |