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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_04_alpha/] [RTL/] [hostController/] [USBHostControlBI.v] - Diff between revs 8 and 40

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 8 Rev 40
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// USBHostControlBI.v                                           ////
//// USBHostControlBI.v                                           ////
////                                                              ////
////                                                              ////
//// This file is part of the usbhostslave opencores effort.
//// This file is part of the usbhostslave opencores effort.
//// <http://www.opencores.org/cores//>                           ////
//// <http://www.opencores.org/cores//>                           ////
////                                                              ////
////                                                              ////
//// Module Description:                                          ////
//// Module Description:                                          ////
//// 
//// 
////                                                              ////
////                                                              ////
//// To Do:                                                       ////
//// To Do:                                                       ////
//// 
//// 
////                                                              ////
////                                                              ////
//// Author(s):                                                   ////
//// Author(s):                                                   ////
//// - Steve Fielding, sfielding@base2designs.com                 ////
//// - Steve Fielding, sfielding@base2designs.com                 ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE. See the GNU Lesser General Public License for more  ////
//// PURPOSE. See the GNU Lesser General Public License for more  ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// 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: USBHostControlBI.v,v 1.2 2004-12-18 14:36:09 sfielding Exp $
// $Id: USBHostControlBI.v,v 1.2 2004-12-18 14:36:09 sfielding Exp $
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
// Revision 1.1.1.1  2004/10/11 04:00:56  sfielding
// Revision 1.1.1.1  2004/10/11 04:00:56  sfielding
// Created
// Created
//
//
//
//
 
 
`include "usbHostControl_h.v"
`include "usbHostControl_h.v"
 
 
module USBHostControlBI (address, dataIn, dataOut, writeEn,
module USBHostControlBI (address, dataIn, dataOut, writeEn,
  strobe_i,
  strobe_i,
  clk, rst,
  clk, rst,
  SOFSentIntOut, connEventIntOut, resumeIntOut, transDoneIntOut,
  SOFSentIntOut, connEventIntOut, resumeIntOut, transDoneIntOut,
  TxTransTypeReg, TxSOFEnableReg,
  TxTransTypeReg, TxSOFEnableReg,
  TxAddrReg, TxEndPReg, frameNumIn,
  TxAddrReg, TxEndPReg, frameNumIn,
  RxPktStatusIn, RxPIDIn,
  RxPktStatusIn, RxPIDIn,
  connectStateIn,
  connectStateIn,
  SOFSentIn, connEventIn, resumeIntIn, transDoneIn,
  SOFSentIn, connEventIn, resumeIntIn, transDoneIn,
  hostControlSelect,
  hostControlSelect,
  clrTransReq,
  clrTransReq,
  preambleEn,
  preambleEn,
  SOFSync,
  SOFSync,
  TxLineState,
  TxLineState,
  LineDirectControlEn,
  LineDirectControlEn,
  fullSpeedPol,
  fullSpeedPol,
  fullSpeedRate,
  fullSpeedRate,
  transReq
  transReq
  );
  );
input [3:0] address;
input [3:0] address;
input [7:0] dataIn;
input [7:0] dataIn;
input writeEn;
input writeEn;
input strobe_i;
input strobe_i;
input clk;
input clk;
input rst;
input rst;
output [7:0] dataOut;
output [7:0] dataOut;
output SOFSentIntOut;
output SOFSentIntOut;
output connEventIntOut;
output connEventIntOut;
output resumeIntOut;
output resumeIntOut;
output transDoneIntOut;
output transDoneIntOut;
 
 
output [1:0] TxTransTypeReg;
output [1:0] TxTransTypeReg;
output TxSOFEnableReg;
output TxSOFEnableReg;
output [6:0] TxAddrReg;
output [6:0] TxAddrReg;
output [3:0] TxEndPReg;
output [3:0] TxEndPReg;
input [10:0] frameNumIn;
input [10:0] frameNumIn;
input [7:0] RxPktStatusIn;
input [7:0] RxPktStatusIn;
input [3:0] RxPIDIn;
input [3:0] RxPIDIn;
input [1:0] connectStateIn;
input [1:0] connectStateIn;
input SOFSentIn;
input SOFSentIn;
input connEventIn;
input connEventIn;
input resumeIntIn;
input resumeIntIn;
input transDoneIn;
input transDoneIn;
input hostControlSelect;
input hostControlSelect;
input clrTransReq;
input clrTransReq;
output preambleEn;
output preambleEn;
output SOFSync;
output SOFSync;
output [1:0] TxLineState;
output [1:0] TxLineState;
output LineDirectControlEn;
output LineDirectControlEn;
output fullSpeedPol;
output fullSpeedPol;
output fullSpeedRate;
output fullSpeedRate;
output transReq;
output transReq;
 
 
wire [3:0] address;
wire [3:0] address;
wire [7:0] dataIn;
wire [7:0] dataIn;
wire writeEn;
wire writeEn;
wire strobe_i;
wire strobe_i;
wire clk;
wire clk;
wire rst;
wire rst;
reg [7:0] dataOut;
reg [7:0] dataOut;
 
 
reg SOFSentIntOut;
reg SOFSentIntOut;
reg connEventIntOut;
reg connEventIntOut;
reg resumeIntOut;
reg resumeIntOut;
reg transDoneIntOut;
reg transDoneIntOut;
 
 
reg [1:0] TxTransTypeReg;
reg [1:0] TxTransTypeReg;
reg TxSOFEnableReg;
reg TxSOFEnableReg;
reg [6:0] TxAddrReg;
reg [6:0] TxAddrReg;
reg [3:0] TxEndPReg;
reg [3:0] TxEndPReg;
wire [10:0] frameNumIn;
wire [10:0] frameNumIn;
wire [7:0] RxPktStatusIn;
wire [7:0] RxPktStatusIn;
wire [3:0] RxPIDIn;
wire [3:0] RxPIDIn;
wire [1:0] connectStateIn;
wire [1:0] connectStateIn;
 
 
wire SOFSentIn;
wire SOFSentIn;
wire connEventIn;
wire connEventIn;
wire resumeIntIn;
wire resumeIntIn;
wire transDoneIn;
wire transDoneIn;
wire hostControlSelect;
wire hostControlSelect;
wire clrTransReq;
wire clrTransReq;
reg preambleEn;
reg preambleEn;
reg SOFSync;
reg SOFSync;
reg [1:0] TxLineState;
reg [1:0] TxLineState;
reg LineDirectControlEn;
reg LineDirectControlEn;
reg fullSpeedPol;
reg fullSpeedPol;
reg fullSpeedRate;
reg fullSpeedRate;
reg transReq;
reg transReq;
 
 
//internal wire and regs
//internal wire and regs
reg [1:0] TxControlReg;
reg [1:0] TxControlReg;
reg [4:0] TxLineControlReg;
reg [4:0] TxLineControlReg;
reg clrSOFReq;
reg clrSOFReq;
reg clrConnEvtReq;
reg clrConnEvtReq;
reg clrResInReq;
reg clrResInReq;
reg clrTransDoneReq;
reg clrTransDoneReq;
reg SOFSentInt;
reg SOFSentInt;
reg connEventInt;
reg connEventInt;
reg resumeInt;
reg resumeInt;
reg transDoneInt;
reg transDoneInt;
reg [3:0] interruptMaskReg;
reg [3:0] interruptMaskReg;
reg setTransReq;
reg setTransReq;
 
 
//sync write demux
//sync write demux
always @(posedge clk)
always @(posedge clk)
begin
begin
  clrSOFReq <= 1'b0;
  clrSOFReq <= 1'b0;
  clrConnEvtReq <= 1'b0;
  clrConnEvtReq <= 1'b0;
  clrResInReq <= 1'b0;
  clrResInReq <= 1'b0;
  clrTransDoneReq <= 1'b0;
  clrTransDoneReq <= 1'b0;
  setTransReq <= 1'b0;
  setTransReq <= 1'b0;
  if (writeEn == 1'b1 && strobe_i == 1'b1 && hostControlSelect == 1'b1)
  if (writeEn == 1'b1 && strobe_i == 1'b1 && hostControlSelect == 1'b1)
  begin
  begin
    case (address)
    case (address)
      `TX_CONTROL_REG : begin
      `TX_CONTROL_REG : begin
        preambleEn <= dataIn[2];
        preambleEn <= dataIn[2];
        SOFSync <= dataIn[1];
        SOFSync <= dataIn[1];
        setTransReq <= dataIn[0];
        setTransReq <= dataIn[0];
      end
      end
      `TX_TRANS_TYPE_REG : TxTransTypeReg <= dataIn[1:0];
      `TX_TRANS_TYPE_REG : TxTransTypeReg <= dataIn[1:0];
      `TX_LINE_CONTROL_REG : TxLineControlReg <= dataIn[4:0];
      `TX_LINE_CONTROL_REG : TxLineControlReg <= dataIn[4:0];
      `TX_SOF_ENABLE_REG : TxSOFEnableReg <= dataIn[0];
      `TX_SOF_ENABLE_REG : TxSOFEnableReg <= dataIn[0];
      `TX_ADDR_REG : TxAddrReg <= dataIn[6:0];
      `TX_ADDR_REG : TxAddrReg <= dataIn[6:0];
      `TX_ENDP_REG : TxEndPReg <= dataIn[3:0];
      `TX_ENDP_REG : TxEndPReg <= dataIn[3:0];
      `INTERRUPT_STATUS_REG :  begin
      `INTERRUPT_STATUS_REG :  begin
        clrSOFReq <= dataIn[3];
        clrSOFReq <= dataIn[3];
        clrConnEvtReq <= dataIn[2];
        clrConnEvtReq <= dataIn[2];
        clrResInReq <= dataIn[1];
        clrResInReq <= dataIn[1];
        clrTransDoneReq <= dataIn[0];
        clrTransDoneReq <= dataIn[0];
      end
      end
      `INTERRUPT_MASK_REG  : interruptMaskReg <= dataIn[3:0];
      `INTERRUPT_MASK_REG  : interruptMaskReg <= dataIn[3:0];
    endcase
    endcase
  end
  end
end
end
 
 
//interrupt control
//interrupt control
always @(posedge clk)
always @(posedge clk)
begin
begin
  if (SOFSentIn == 1'b1)
  if (SOFSentIn == 1'b1)
    SOFSentInt <= 1'b1;
    SOFSentInt <= 1'b1;
  else if (clrSOFReq == 1'b1)
  else if (clrSOFReq == 1'b1)
    SOFSentInt <= 1'b0;
    SOFSentInt <= 1'b0;
 
 
  if (connEventIn == 1'b1)
  if (connEventIn == 1'b1)
    connEventInt <= 1'b1;
    connEventInt <= 1'b1;
  else if (clrConnEvtReq == 1'b1)
  else if (clrConnEvtReq == 1'b1)
    connEventInt <= 1'b0;
    connEventInt <= 1'b0;
 
 
  if (resumeIntIn == 1'b1)
  if (resumeIntIn == 1'b1)
    resumeInt <= 1'b1;
    resumeInt <= 1'b1;
  else if (clrResInReq == 1'b1)
  else if (clrResInReq == 1'b1)
    resumeInt <= 1'b0;
    resumeInt <= 1'b0;
 
 
  if (transDoneIn == 1'b1)
  if (transDoneIn == 1'b1)
    transDoneInt <= 1'b1;
    transDoneInt <= 1'b1;
  else if (clrTransDoneReq == 1'b1)
  else if (clrTransDoneReq == 1'b1)
    transDoneInt <= 1'b0;
    transDoneInt <= 1'b0;
end
end
 
 
//mask interrupts
//mask interrupts
always @(interruptMaskReg or transDoneInt or resumeInt or connEventInt or SOFSentInt) begin
always @(interruptMaskReg or transDoneInt or resumeInt or connEventInt or SOFSentInt) begin
  transDoneIntOut <= transDoneInt & interruptMaskReg[`TRANS_DONE_BIT];
  transDoneIntOut <= transDoneInt & interruptMaskReg[`TRANS_DONE_BIT];
  resumeIntOut <= resumeInt & interruptMaskReg[`RESUME_INT_BIT];
  resumeIntOut <= resumeInt & interruptMaskReg[`RESUME_INT_BIT];
  connEventIntOut <= connEventInt & interruptMaskReg[`CONNECTION_EVENT_BIT];
  connEventIntOut <= connEventInt & interruptMaskReg[`CONNECTION_EVENT_BIT];
  SOFSentIntOut <= SOFSentInt & interruptMaskReg[`SOF_SENT_BIT];
  SOFSentIntOut <= SOFSentInt & interruptMaskReg[`SOF_SENT_BIT];
end
end
 
 
//transaction request set/clear
//transaction request set/clear
always @(posedge clk)
always @(posedge clk)
begin
begin
  if (setTransReq == 1'b1)
  if (setTransReq == 1'b1)
    transReq <= 1'b1;
    transReq <= 1'b1;
  else if (clrTransReq == 1'b1)
  else if (clrTransReq == 1'b1)
    transReq <= 1'b0;
    transReq <= 1'b0;
end
end
 
 
//break out control signals
//break out control signals
always @(TxControlReg or TxLineControlReg) begin
always @(TxControlReg or TxLineControlReg) begin
  TxLineState <= TxLineControlReg[`TX_LINE_STATE_MSBIT:`TX_LINE_STATE_LSBIT];
  TxLineState <= TxLineControlReg[`TX_LINE_STATE_MSBIT:`TX_LINE_STATE_LSBIT];
  LineDirectControlEn <= TxLineControlReg[`DIRECT_CONTROL_BIT];
  LineDirectControlEn <= TxLineControlReg[`DIRECT_CONTROL_BIT];
  fullSpeedPol <= TxLineControlReg[`FULL_SPEED_LINE_POLARITY_BIT];
  fullSpeedPol <= TxLineControlReg[`FULL_SPEED_LINE_POLARITY_BIT];
  fullSpeedRate <= TxLineControlReg[`FULL_SPEED_LINE_RATE_BIT];
  fullSpeedRate <= TxLineControlReg[`FULL_SPEED_LINE_RATE_BIT];
end
end
 
 
// async read mux
// async read mux
always @(address or
always @(address or
  TxControlReg or TxTransTypeReg or TxLineControlReg or TxSOFEnableReg or
  TxControlReg or TxTransTypeReg or TxLineControlReg or TxSOFEnableReg or
  TxAddrReg or TxEndPReg or frameNumIn or
  TxAddrReg or TxEndPReg or frameNumIn or
  SOFSentInt or connEventInt or resumeInt or transDoneInt or
  SOFSentInt or connEventInt or resumeInt or transDoneInt or
  interruptMaskReg or RxPktStatusIn or RxPIDIn or connectStateIn or
  interruptMaskReg or RxPktStatusIn or RxPIDIn or connectStateIn or
  preambleEn or SOFSync or transReq)
  preambleEn or SOFSync or transReq)
begin
begin
  case (address)
  case (address)
      `TX_CONTROL_REG : dataOut <= {5'b00000, preambleEn, SOFSync, transReq} ;
      `TX_CONTROL_REG : dataOut <= {5'b00000, preambleEn, SOFSync, transReq} ;
      `TX_TRANS_TYPE_REG : dataOut <= {6'b000000, TxTransTypeReg};
      `TX_TRANS_TYPE_REG : dataOut <= {6'b000000, TxTransTypeReg};
      `TX_LINE_CONTROL_REG : dataOut <= {3'b000, TxLineControlReg};
      `TX_LINE_CONTROL_REG : dataOut <= {3'b000, TxLineControlReg};
      `TX_SOF_ENABLE_REG : dataOut <= {7'b0000000, TxSOFEnableReg};
      `TX_SOF_ENABLE_REG : dataOut <= {7'b0000000, TxSOFEnableReg};
      `TX_ADDR_REG : dataOut <= {1'b0, TxAddrReg};
      `TX_ADDR_REG : dataOut <= {1'b0, TxAddrReg};
      `TX_ENDP_REG : dataOut <= {4'h0, TxEndPReg};
      `TX_ENDP_REG : dataOut <= {4'h0, TxEndPReg};
      `FRAME_NUM_MSB_REG : dataOut <= frameNumIn[10:3];
      `FRAME_NUM_MSB_REG : dataOut <= frameNumIn[10:3];
      `FRAME_NUM_LSB_REG : dataOut <= {5'b00000, frameNumIn[2:0]};
      `FRAME_NUM_LSB_REG : dataOut <= {5'b00000, frameNumIn[2:0]};
      `INTERRUPT_STATUS_REG :  dataOut <= {4'h0, SOFSentInt, connEventInt, resumeInt, transDoneInt};
      `INTERRUPT_STATUS_REG :  dataOut <= {4'h0, SOFSentInt, connEventInt, resumeInt, transDoneInt};
      `INTERRUPT_MASK_REG  : dataOut <= {4'h0, interruptMaskReg};
      `INTERRUPT_MASK_REG  : dataOut <= {4'h0, interruptMaskReg};
      `RX_STATUS_REG  : dataOut <= RxPktStatusIn;
      `RX_STATUS_REG  : dataOut <= RxPktStatusIn;
      `RX_PID_REG  : dataOut <= {4'b0000, RxPIDIn};
      `RX_PID_REG  : dataOut <= {4'b0000, RxPIDIn};
      `RX_CONNECT_STATE_REG : dataOut <= {6'b000000, connectStateIn};
      `RX_CONNECT_STATE_REG : dataOut <= {6'b000000, connectStateIn};
      default: dataOut <= 8'h00;
      default: dataOut <= 8'h00;
  endcase
  endcase
end
end
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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