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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_06_alpha/] [RTL/] [busInterface/] [wishBoneBI.v] - Diff between revs 13 and 40

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

Rev 13 Rev 40
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// wishBoneBI.v                                                 ////
//// wishBoneBI.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>                   ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
`timescale 1ns / 1ps
`timescale 1ns / 1ps
 
 
`include "wishBoneBus_h.v"
`include "wishBoneBus_h.v"
 
 
 
 
module wishBoneBI (
module wishBoneBI (
  address, dataIn, dataOut, writeEn,
  address, dataIn, dataOut, writeEn,
  strobe_i,
  strobe_i,
  ack_o,
  ack_o,
  clk, rst,
  clk, rst,
  hostControlSel,
  hostControlSel,
  hostRxFifoSel, hostTxFifoSel,
  hostRxFifoSel, hostTxFifoSel,
  slaveControlSel,
  slaveControlSel,
  slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel,
  slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel,
  slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel,
  slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel,
  hostSlaveMuxSel,
  hostSlaveMuxSel,
  dataFromHostControl,
  dataFromHostControl,
  dataFromHostRxFifo,
  dataFromHostRxFifo,
  dataFromHostTxFifo,
  dataFromHostTxFifo,
  dataFromSlaveControl,
  dataFromSlaveControl,
  dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo,
  dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo,
  dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo,
  dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo,
  dataFromHostSlaveMux
  dataFromHostSlaveMux
   );
   );
input clk;
input clk;
input rst;
input rst;
input [7:0] address;
input [7:0] address;
input [7:0] dataIn;
input [7:0] dataIn;
output [7:0] dataOut;
output [7:0] dataOut;
input strobe_i;
input strobe_i;
output ack_o;
output ack_o;
input writeEn;
input writeEn;
output hostControlSel;
output hostControlSel;
output hostRxFifoSel;
output hostRxFifoSel;
output hostTxFifoSel;
output hostTxFifoSel;
output slaveControlSel;
output slaveControlSel;
output slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
output slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
output slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
output slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
output hostSlaveMuxSel;
output hostSlaveMuxSel;
input [7:0] dataFromHostControl;
input [7:0] dataFromHostControl;
input [7:0] dataFromHostRxFifo;
input [7:0] dataFromHostRxFifo;
input [7:0] dataFromHostTxFifo;
input [7:0] dataFromHostTxFifo;
input [7:0] dataFromSlaveControl;
input [7:0] dataFromSlaveControl;
input [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
input [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
input [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
input [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
input [7:0] dataFromHostSlaveMux;
input [7:0] dataFromHostSlaveMux;
 
 
 
 
wire clk;
wire clk;
wire rst;
wire rst;
wire [7:0] address;
wire [7:0] address;
wire [7:0] dataIn;
wire [7:0] dataIn;
reg [7:0] dataOut;
reg [7:0] dataOut;
wire writeEn;
wire writeEn;
wire strobe_i;
wire strobe_i;
reg ack_o;
reg ack_o;
reg hostControlSel;
reg hostControlSel;
reg hostRxFifoSel;
reg hostRxFifoSel;
reg hostTxFifoSel;
reg hostTxFifoSel;
reg slaveControlSel;
reg slaveControlSel;
reg slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
reg slaveEP0RxFifoSel, slaveEP1RxFifoSel, slaveEP2RxFifoSel, slaveEP3RxFifoSel;
reg slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
reg slaveEP0TxFifoSel, slaveEP1TxFifoSel, slaveEP2TxFifoSel, slaveEP3TxFifoSel;
reg hostSlaveMuxSel;
reg hostSlaveMuxSel;
wire [7:0] dataFromHostControl;
wire [7:0] dataFromHostControl;
wire [7:0] dataFromHostRxFifo;
wire [7:0] dataFromHostRxFifo;
wire [7:0] dataFromHostTxFifo;
wire [7:0] dataFromHostTxFifo;
wire [7:0] dataFromSlaveControl;
wire [7:0] dataFromSlaveControl;
wire [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
wire [7:0] dataFromEP0RxFifo, dataFromEP1RxFifo, dataFromEP2RxFifo, dataFromEP3RxFifo;
wire [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
wire [7:0] dataFromEP0TxFifo, dataFromEP1TxFifo, dataFromEP2TxFifo, dataFromEP3TxFifo;
wire [7:0] dataFromHostSlaveMux;
wire [7:0] dataFromHostSlaveMux;
 
 
//internal wires and regs
//internal wires and regs
reg ack_delayed;
reg ack_delayed;
reg ack_immediate;
reg ack_immediate;
 
 
//address decode and data mux
//address decode and data mux
always @(address or
always @(address or
  dataFromHostControl or
  dataFromHostControl or
  dataFromHostRxFifo or
  dataFromHostRxFifo or
  dataFromHostTxFifo or
  dataFromHostTxFifo or
  dataFromSlaveControl or
  dataFromSlaveControl or
  dataFromEP0RxFifo or
  dataFromEP0RxFifo or
  dataFromEP1RxFifo or
  dataFromEP1RxFifo or
  dataFromEP2RxFifo or
  dataFromEP2RxFifo or
  dataFromEP3RxFifo or
  dataFromEP3RxFifo or
  dataFromHostSlaveMux or
  dataFromHostSlaveMux or
  dataFromEP0TxFifo or
  dataFromEP0TxFifo or
  dataFromEP1TxFifo or
  dataFromEP1TxFifo or
  dataFromEP2TxFifo or
  dataFromEP2TxFifo or
  dataFromEP3TxFifo)
  dataFromEP3TxFifo)
begin
begin
  hostControlSel <= 1'b0;
  hostControlSel <= 1'b0;
  hostRxFifoSel <= 1'b0;
  hostRxFifoSel <= 1'b0;
  hostTxFifoSel <= 1'b0;
  hostTxFifoSel <= 1'b0;
  slaveControlSel <= 1'b0;
  slaveControlSel <= 1'b0;
  slaveEP0RxFifoSel <= 1'b0;
  slaveEP0RxFifoSel <= 1'b0;
  slaveEP0TxFifoSel <= 1'b0;
  slaveEP0TxFifoSel <= 1'b0;
  slaveEP1RxFifoSel <= 1'b0;
  slaveEP1RxFifoSel <= 1'b0;
  slaveEP1TxFifoSel <= 1'b0;
  slaveEP1TxFifoSel <= 1'b0;
  slaveEP2RxFifoSel <= 1'b0;
  slaveEP2RxFifoSel <= 1'b0;
  slaveEP2TxFifoSel <= 1'b0;
  slaveEP2TxFifoSel <= 1'b0;
  slaveEP3RxFifoSel <= 1'b0;
  slaveEP3RxFifoSel <= 1'b0;
  slaveEP3TxFifoSel <= 1'b0;
  slaveEP3TxFifoSel <= 1'b0;
  hostSlaveMuxSel <= 1'b0;
  hostSlaveMuxSel <= 1'b0;
  case (address & `ADDRESS_DECODE_MASK)
  case (address & `ADDRESS_DECODE_MASK)
    `HCREG_BASE : begin
    `HCREG_BASE : begin
      hostControlSel <= 1'b1;
      hostControlSel <= 1'b1;
      dataOut <= dataFromHostControl;
      dataOut <= dataFromHostControl;
    end
    end
    `HCREG_BASE_PLUS_0X10 : begin
    `HCREG_BASE_PLUS_0X10 : begin
      hostControlSel <= 1'b1;
      hostControlSel <= 1'b1;
      dataOut <= dataFromHostControl;
      dataOut <= dataFromHostControl;
    end
    end
    `HOST_RX_FIFO_BASE : begin
    `HOST_RX_FIFO_BASE : begin
      hostRxFifoSel <= 1'b1;
      hostRxFifoSel <= 1'b1;
      dataOut <= dataFromHostRxFifo;
      dataOut <= dataFromHostRxFifo;
    end
    end
    `HOST_TX_FIFO_BASE : begin
    `HOST_TX_FIFO_BASE : begin
      hostTxFifoSel <= 1'b1;
      hostTxFifoSel <= 1'b1;
      dataOut <= dataFromHostTxFifo;
      dataOut <= dataFromHostTxFifo;
    end
    end
    `SCREG_BASE : begin
    `SCREG_BASE : begin
      slaveControlSel <= 1'b1;
      slaveControlSel <= 1'b1;
      dataOut <= dataFromSlaveControl;
      dataOut <= dataFromSlaveControl;
    end
    end
    `SCREG_BASE_PLUS_0X10 : begin
    `SCREG_BASE_PLUS_0X10 : begin
      slaveControlSel <= 1'b1;
      slaveControlSel <= 1'b1;
      dataOut <= dataFromSlaveControl;
      dataOut <= dataFromSlaveControl;
    end
    end
    `EP0_RX_FIFO_BASE : begin
    `EP0_RX_FIFO_BASE : begin
      slaveEP0RxFifoSel <= 1'b1;
      slaveEP0RxFifoSel <= 1'b1;
      dataOut <= dataFromEP0RxFifo;
      dataOut <= dataFromEP0RxFifo;
    end
    end
    `EP0_TX_FIFO_BASE : begin
    `EP0_TX_FIFO_BASE : begin
      slaveEP0TxFifoSel <= 1'b1;
      slaveEP0TxFifoSel <= 1'b1;
      dataOut <= dataFromEP0TxFifo;
      dataOut <= dataFromEP0TxFifo;
    end
    end
    `EP1_RX_FIFO_BASE : begin
    `EP1_RX_FIFO_BASE : begin
      slaveEP1RxFifoSel <= 1'b1;
      slaveEP1RxFifoSel <= 1'b1;
      dataOut <= dataFromEP1RxFifo;
      dataOut <= dataFromEP1RxFifo;
    end
    end
    `EP1_TX_FIFO_BASE : begin
    `EP1_TX_FIFO_BASE : begin
      slaveEP1TxFifoSel <= 1'b1;
      slaveEP1TxFifoSel <= 1'b1;
      dataOut <= dataFromEP1TxFifo;
      dataOut <= dataFromEP1TxFifo;
    end
    end
    `EP2_RX_FIFO_BASE : begin
    `EP2_RX_FIFO_BASE : begin
      slaveEP2RxFifoSel <= 1'b1;
      slaveEP2RxFifoSel <= 1'b1;
      dataOut <= dataFromEP2RxFifo;
      dataOut <= dataFromEP2RxFifo;
    end
    end
    `EP2_TX_FIFO_BASE : begin
    `EP2_TX_FIFO_BASE : begin
      slaveEP2TxFifoSel <= 1'b1;
      slaveEP2TxFifoSel <= 1'b1;
      dataOut <= dataFromEP2TxFifo;
      dataOut <= dataFromEP2TxFifo;
    end
    end
    `EP3_RX_FIFO_BASE : begin
    `EP3_RX_FIFO_BASE : begin
      slaveEP3RxFifoSel <= 1'b1;
      slaveEP3RxFifoSel <= 1'b1;
      dataOut <= dataFromEP3RxFifo;
      dataOut <= dataFromEP3RxFifo;
    end
    end
    `EP3_TX_FIFO_BASE : begin
    `EP3_TX_FIFO_BASE : begin
      slaveEP3TxFifoSel <= 1'b1;
      slaveEP3TxFifoSel <= 1'b1;
      dataOut <= dataFromEP3TxFifo;
      dataOut <= dataFromEP3TxFifo;
    end
    end
    `HOST_SLAVE_CONTROL_BASE : begin
    `HOST_SLAVE_CONTROL_BASE : begin
      hostSlaveMuxSel <= 1'b1;
      hostSlaveMuxSel <= 1'b1;
      dataOut <= dataFromHostSlaveMux;
      dataOut <= dataFromHostSlaveMux;
    end
    end
    default:
    default:
      dataOut <= 8'h00;
      dataOut <= 8'h00;
  endcase
  endcase
end
end
 
 
//delayed ack
//delayed ack
always @(posedge clk) begin
always @(posedge clk) begin
  ack_delayed <= strobe_i;
  ack_delayed <= strobe_i;
end
end
 
 
//immediate ack
//immediate ack
always @(strobe_i) begin
always @(strobe_i) begin
  ack_immediate <= strobe_i;
  ack_immediate <= strobe_i;
end
end
 
 
//select between immediate and delayed ack
//select between immediate and delayed ack
always @(writeEn or address or ack_delayed or ack_immediate) begin
always @(writeEn or address or ack_delayed or ack_immediate) begin
  if (writeEn == 1'b0 &&
  if (writeEn == 1'b0 &&
      (address == `HOST_RX_FIFO_BASE + `FIFO_DATA_REG ||
      (address == `HOST_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `HOST_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `HOST_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP0_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP0_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP0_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP0_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP1_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP1_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP1_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP1_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP2_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP2_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP2_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP2_TX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP3_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP3_RX_FIFO_BASE + `FIFO_DATA_REG ||
       address == `EP3_TX_FIFO_BASE + `FIFO_DATA_REG) )
       address == `EP3_TX_FIFO_BASE + `FIFO_DATA_REG) )
  begin
  begin
    ack_o <= ack_delayed;
    ack_o <= ack_delayed;
  end
  end
  else
  else
  begin
  begin
    ack_o <= ack_immediate;
    ack_o <= ack_immediate;
  end
  end
end
end
 
 
 
 

powered by: WebSVN 2.1.0

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