OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [usbhostslave/] [TxfifoBI_simlib.v] - Blame information for rev 509

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

Line No. Rev Author Line
1 408 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// TxfifoBI.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
`include "timescale.v"
45
`include "wishBoneBus_h.v"
46
 
47
module TxfifoBI_simlib (
48
  address, writeEn, strobe_i,
49
  busClk,
50
  usbClk,
51
  rstSyncToBusClk,
52
  fifoSelect,
53
  busDataIn,
54
  busDataOut,
55
  fifoWEn,
56
  forceEmptySyncToUsbClk,
57
  forceEmptySyncToBusClk,
58
  numElementsInFifo
59
  );
60
input [2:0] address;
61
input writeEn;
62
input strobe_i;
63
input busClk;
64
input usbClk;
65
input rstSyncToBusClk;
66
input [7:0] busDataIn;
67
output [7:0] busDataOut;
68
output fifoWEn;
69
output forceEmptySyncToUsbClk;
70
output forceEmptySyncToBusClk;
71
input [15:0] numElementsInFifo;
72
input fifoSelect;
73
 
74
 
75
wire [2:0] address;
76
wire writeEn;
77
wire strobe_i;
78
wire busClk;
79
wire usbClk;
80
wire rstSyncToBusClk;
81
wire [7:0] busDataIn;
82
wire [7:0] busDataOut;
83
reg fifoWEn;
84
wire forceEmptySyncToUsbClk;
85
wire forceEmptySyncToBusClk;
86
wire [15:0] numElementsInFifo;
87
wire fifoSelect;
88
 
89
reg forceEmptyReg;
90
reg forceEmpty;
91
reg forceEmptyToggle;
92
reg [2:0] forceEmptyToggleSyncToUsbClk;
93
 
94
//sync write
95
always @(posedge busClk)
96
begin
97
  if (writeEn == 1'b1 && fifoSelect == 1'b1 &&
98
  address == `FIFO_CONTROL_REG && strobe_i == 1'b1 && busDataIn[0] == 1'b1)
99
    forceEmpty <= 1'b1;
100
  else
101
    forceEmpty <= 1'b0;
102
end
103
 
104
//detect rising edge of 'forceEmpty', and generate toggle signal
105
always @(posedge busClk) begin
106
  if (rstSyncToBusClk == 1'b1) begin
107
    forceEmptyReg <= 1'b0;
108
    forceEmptyToggle <= 1'b0;
109
  end
110
  else begin
111
    if (forceEmpty == 1'b1)
112
      forceEmptyReg <= 1'b1;
113
    else
114
      forceEmptyReg <= 1'b0;
115
    if (forceEmpty == 1'b1 && forceEmptyReg == 1'b0)
116
      forceEmptyToggle <= ~forceEmptyToggle;
117
  end
118
end
119
assign forceEmptySyncToBusClk = (forceEmpty == 1'b1 && forceEmptyReg == 1'b0) ? 1'b1 : 1'b0;
120
 
121
// double sync across clock domains to generate 'forceEmptySyncToUsbClk'
122
always @(posedge usbClk) begin
123
    forceEmptyToggleSyncToUsbClk <= {forceEmptyToggleSyncToUsbClk[1:0], forceEmptyToggle};
124
end
125
assign forceEmptySyncToUsbClk = forceEmptyToggleSyncToUsbClk[2] ^ forceEmptyToggleSyncToUsbClk[1];
126
 
127
// async read mux
128
assign busDataOut = 8'h00;
129
//always @(address or fifoFull or numElementsInFifo)
130
//begin
131
//  case (address)
132
//      `FIFO_STATUS_REG : busDataOut <= {7'b0000000, fifoFull};
133
//      `FIFO_DATA_COUNT_MSB : busDataOut <= numElementsInFifo[15:8];
134
//      `FIFO_DATA_COUNT_LSB : busDataOut <= numElementsInFifo[7:0];
135
//      default: busDataOut <= 8'h00;
136
//  endcase
137
//end
138
 
139
//generate fifo write strobe
140
always @(address or writeEn or strobe_i or fifoSelect or busDataIn) begin
141
  if (address == `FIFO_DATA_REG &&   writeEn == 1'b1 &&
142
  strobe_i == 1'b1 &&   fifoSelect == 1'b1)
143
    fifoWEn <= 1'b1;
144
  else
145
    fifoWEn <= 1'b0;
146
end
147
 
148
 
149
endmodule

powered by: WebSVN 2.1.0

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