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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostSlaveMux/] [hostSlaveMuxBI.v] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// hostSlaveMuxBI.v                                             ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// 
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// 
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Steve Fielding, sfielding@base2designs.com                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE. See the GNU Lesser General Public License for more  ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from <http://www.opencores.org/lgpl.shtml>                   ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44 9 sfielding
`timescale 1ns / 1ps
45 2 sfielding
 
46 9 sfielding
`include "usbHostSlave_h.v"
47
 
48 18 sfielding
module hostSlaveMuxBI (dataIn, dataOut, address, writeEn, strobe_i, busClk, usbClk,
49
  hostMode, hostSlaveMuxSel, rstFromWire, rstSyncToBusClkOut, rstSyncToUsbClkOut);
50 2 sfielding
 
51
input [7:0] dataIn;
52 9 sfielding
input address;
53 2 sfielding
input writeEn;
54
input strobe_i;
55 18 sfielding
input busClk;
56
input usbClk;
57 2 sfielding
output [7:0] dataOut;
58
input hostSlaveMuxSel;
59
output hostMode;
60 18 sfielding
input rstFromWire;
61
output rstSyncToBusClkOut;
62
output rstSyncToUsbClkOut;
63 2 sfielding
 
64
wire [7:0] dataIn;
65 9 sfielding
wire address;
66 2 sfielding
wire writeEn;
67
wire strobe_i;
68 18 sfielding
wire busClk;
69
wire usbClk;
70 2 sfielding
reg [7:0] dataOut;
71
wire hostSlaveMuxSel;
72
reg hostMode;
73 18 sfielding
wire rstFromWire;
74
reg rstSyncToBusClkOut;
75
reg rstSyncToUsbClkOut;
76 2 sfielding
 
77
//internal wire and regs
78 18 sfielding
reg [5:0] rstShift;
79
reg rstFromBus;
80
reg rstSyncToUsbClkFirst;
81 2 sfielding
 
82
//sync write demux
83 18 sfielding
always @(posedge busClk)
84 2 sfielding
begin
85 18 sfielding
  if (rstSyncToBusClkOut == 1'b1)
86 2 sfielding
    hostMode <= 1'b0;
87
  else begin
88 9 sfielding
    if (writeEn == 1'b1 && hostSlaveMuxSel == 1'b1 && strobe_i == 1'b1 && address == `HOST_SLAVE_CONTROL_REG )
89 5 sfielding
      hostMode <= dataIn[0];
90 18 sfielding
    end
91
    if (writeEn == 1'b1 && hostSlaveMuxSel == 1'b1 && strobe_i == 1'b1 && address == `HOST_SLAVE_CONTROL_REG && dataIn[1] == 1'b1 )
92
      rstFromBus <= 1'b1;
93
    else
94
      rstFromBus <= 1'b0;
95 2 sfielding
end
96
 
97
// async read mux
98 9 sfielding
always @(address or hostMode)
99 2 sfielding
begin
100 9 sfielding
  case (address)
101
    `HOST_SLAVE_CONTROL_REG: dataOut <= {7'h0, hostMode};
102
    `HOST_SLAVE_VERSION_REG: dataOut <= `USBHOSTSLAVE_VERSION_NUM;
103
  endcase
104 2 sfielding
end
105
 
106 18 sfielding
// reset control
107
//generate 'rstSyncToBusClk'
108
//assuming that 'busClk' < 5 * 'usbClk'. ie 'busClk' < 240MHz
109
always @(posedge busClk) begin
110
  if (rstFromWire == 1'b1 || rstFromBus == 1'b1)
111
    rstShift <= 6'b111111;
112
  else
113
    rstShift <= {1'b0, rstShift[5:1]};
114
end
115
 
116
always @(rstShift)
117
  rstSyncToBusClkOut <= rstShift[0];
118
 
119
// double sync across clock domains to generate 'forceEmptySyncToWrClk'
120
always @(posedge usbClk) begin
121
    rstSyncToUsbClkFirst <= rstSyncToBusClkOut;
122
    rstSyncToUsbClkOut <= rstSyncToUsbClkFirst;
123
end
124
 
125
endmodule

powered by: WebSVN 2.1.0

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