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

Subversion Repositories bluespec_md6

[/] [bluespec_md6/] [trunk/] [lib/] [bsv/] [BRAMFIFO/] [BRAMFIFO.bsv] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kfleming
//----------------------------------------------------------------------//
2
// The MIT License
3
//
4
// Copyright (c) 2008 Kermin Fleming, kfleming@mit.edu
5
//
6
// Permission is hereby granted, free of charge, to any person
7
// obtaining a copy of this software and associated documentation
8
// files (the "Software"), to deal in the Software without
9
// restriction, including without limitation the rights to use,
10
// copy, modify, merge, publish, distribute, sublicense, and/or sell
11
// copies of the Software, and to permit persons to whom the
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be
15
// included in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
// OTHER DEALINGS IN THE SOFTWARE.
25
//----------------------------------------------------------------------//
26
 
27
import FIFO::*;
28
import FIFOF::*;
29
import FIFOF_::*;
30
 
31
/***
32
 *
33
 * This module serves as a simple bluespec wrapper for
34
 * the verilog based BRAMFIFO.  The imported methods support
35
 * the standard FIFOF and FIFO classes.  It should be noted that
36
 * the underlying verilog implementation is gaurded.
37
 *
38
 ***/
39
 
40
 
41
module mkBRAMFIFO#(Integer count) (FIFO#(fifo_type))
42
  provisos
43
          (Bits#(fifo_type, fifo_size));
44
  FIFOF#(fifo_type) fifo <- mkBRAMFIFOF(count);
45
 
46
  method Action enq(fifo_type data);
47
    fifo.enq(data);
48
  endmethod
49
 
50
  method Action deq();
51
    fifo.deq();
52
  endmethod
53
 
54
  method fifo_type first();
55
    return fifo.first();
56
  endmethod
57
 
58
  method Action clear();
59
    fifo.clear();
60
  endmethod
61
 
62
endmodule
63
 
64
module mkBRAMFIFOF#(Integer count) (FIFOF#(fifo_type))
65
  provisos
66
          (Bits#(fifo_type, fifo_size));
67
  `ifdef BLUESIM
68
     FIFOF#(fifo_type) fifo <- mkSizedFIFOF(count);
69
  `else
70
     error("How did we get here?");
71
     FIFOF#(fifo_type) fifo <- mkBRAMFIFOFIndirect(count);
72
  `endif
73
  return fifo;
74
endmodule
75
 
76
module mkBRAMFIFOFIndirect#(Integer count) (FIFOF#(fifo_type))
77
  provisos
78
          (Bits#(fifo_type, fifo_size));
79
 
80
  FIFOF_#(fifo_type) fifo <- mkBRAMFIFOF_(count);
81
 
82
  method Action enq(fifo_type data) if(fifo.i_notFull);
83
    fifo.enq(data);
84
  endmethod
85
 
86
  method Action deq() if(fifo.i_notEmpty);
87
    fifo.deq();
88
  endmethod
89
 
90
  method fifo_type first() if(fifo.i_notEmpty);
91
    return fifo.first();
92
  endmethod
93
 
94
  method Bool notFull;
95
    return fifo.notFull;
96
  endmethod
97
 
98
  method Bool notEmpty;
99
    return fifo.notEmpty;
100
  endmethod
101
 
102
  method Action clear();
103
    fifo.clear();
104
  endmethod
105
 
106
 
107
endmodule
108
 
109
 
110
import "BVI" BRAMFIFOF = module mkBRAMFIFOF_#(Integer count)
111
  //interface:
112
              (FIFOF_#(fifo_type))
113
  provisos
114
          (Bits#(fifo_type, fifo_size));
115
 
116
  default_clock clk(CLK);
117
 
118
  parameter                   log_data_count = log2(count);
119
  parameter                   data_count = count;
120
  parameter                   data_width = valueOf(fifo_size);
121
 
122
  method enq((* reg *)D_IN) enable(ENQ);
123
  method deq() enable(DEQ);
124
  method (* reg *)D_OUT first;
125
  method FULL_N   notFull;
126
  method FULL_N i_notFull;
127
  method (* reg *)EMPTY_N   notEmpty;
128
  method (* reg *)EMPTY_N i_notEmpty;
129
  method clear() enable(CLR);
130
 
131
  schedule deq CF (enq, i_notEmpty, i_notFull) ;
132
  schedule enq CF (deq, first, i_notEmpty, i_notFull) ;
133
  schedule (first, notEmpty, notFull) CF
134
             (first, i_notEmpty, i_notFull, notEmpty, notFull) ;
135
  schedule (i_notEmpty, i_notFull) CF
136
              (clear, first, i_notEmpty, i_notFull, notEmpty, notFull) ;
137
  schedule (clear, deq, enq) SBR clear ;
138
  schedule first SB (clear, deq) ;
139
  schedule (notEmpty, notFull) SB (clear, deq, enq) ;
140
 
141
 
142
  /*schedule first SB (deq,enq,clear);
143
  schedule first CF (first,notFull,notEmpty);
144
 
145
  schedule notFull SB (deq,enq,clear);
146
  schedule notFull CF (first,notFull,notEmpty);
147
 
148
  schedule notEmpty SB (deq,enq,clear);
149
  schedule notEmpty CF (first,notFull,notEmpty);
150
 
151
  schedule deq CF enq;
152
  schedule deq SB clear;
153
  schedule deq C  deq;
154
 
155
  schedule enq CF deq;
156
  schedule enq SB clear;
157
  schedule enq C  enq;
158
 
159
  schedule clear C clear;*/
160
 
161
endmodule
162
 
163
 

powered by: WebSVN 2.1.0

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