OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [BRAM.bsv] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 jamey.hick
import FIFO::*;
2
 
3
//One RAM.
4
interface BRAM#(type idx_type, type data_type);
5
 
6
  method Action read_req(idx_type idx);
7
 
8
  method ActionValue#(data_type) read_resp();
9
 
10
  method Action write(idx_type idx, data_type data);
11
 
12
endinterface
13
 
14
 
15
//Two RAMs.
16
interface BRAM_2#(type idx_type, type data_type);
17
 
18
  method Action read_req1(idx_type idx);
19
  method Action read_req2(idx_type idx);
20
 
21
  method ActionValue#(data_type) read_resp1();
22
  method ActionValue#(data_type) read_resp2();
23
 
24
  method Action write(idx_type idx, data_type data);
25
 
26
endinterface
27
 
28
//Three RAMs.
29
interface BRAM_3#(type idx_type, type data_type);
30
 
31
  method Action read_req1(idx_type idx);
32
  method Action read_req2(idx_type idx);
33
  method Action read_req3(idx_type idx);
34
 
35
  method ActionValue#(data_type) read_resp1();
36
  method ActionValue#(data_type) read_resp2();
37
  method ActionValue#(data_type) read_resp3();
38
 
39
  method Action write(idx_type idx, data_type data);
40
 
41
endinterface
42
 
43
 
44
module mkBRAM#(Integer low, Integer high)
45
  //interface:
46
              (BRAM#(idx_type, data_type))
47
  provisos
48
          (Bits#(idx_type, idx),
49
           Bits#(data_type, data),
50
           Literal#(idx_type));
51
 
52
  BRAM#(idx_type, data_type) m <- (valueof(data) == 0) ?
53
                                  mkBRAM_Zero() :
54
                                  mkBRAM_NonZero(low, high);
55
 
56
  return m;
57
endmodule
58
 
59
import "BVI" BRAM = module mkBRAM_NonZero#(Integer low, Integer high)
60
  //interface:
61
              (BRAM#(idx_type, data_type))
62
  provisos
63
          (Bits#(idx_type, idx),
64
           Bits#(data_type, data),
65
           Literal#(idx_type));
66
 
67
  default_clock clk(CLK);
68
 
69
  parameter addr_width = valueof(idx);
70
  parameter data_width = valueof(data);
71
  parameter lo = low;
72
  parameter hi = high;
73
 
74
  method DOUT read_resp() ready(DOUT_RDY) enable(DOUT_EN);
75
 
76
  method read_req(RD_ADDR) ready(RD_RDY) enable(RD_EN);
77
  method write(WR_ADDR, WR_VAL) enable(WR_EN);
78
 
79
  schedule read_req  CF (read_resp, write);
80
  schedule read_resp CF (read_req, write);
81
  schedule write     CF (read_req, read_resp);
82
 
83
  schedule read_req  C read_req;
84
  schedule read_resp C read_resp;
85
  schedule write     C write;
86
 
87
endmodule
88
 
89
module mkBRAM_Zero
90
  //interface:
91
              (BRAM#(idx_type, data_type))
92
  provisos
93
          (Bits#(idx_type, idx),
94
           Bits#(data_type, data),
95
           Literal#(idx_type));
96
 
97
  FIFO#(data_type) q <- mkFIFO();
98
 
99
  method Action read_req(idx_type i);
100
     q.enq(?);
101
  endmethod
102
 
103
  method Action write(idx_type i, data_type d);
104
    noAction;
105
  endmethod
106
 
107
  method ActionValue#(data_type) read_resp();
108
    q.deq();
109
    return q.first();
110
  endmethod
111
 
112
endmodule
113
 
114
module mkBRAM_Full
115
  //interface:
116
              (BRAM#(idx_type, data_type))
117
  provisos
118
          (Bits#(idx_type, idx),
119
           Bits#(data_type, data),
120
           Literal#(idx_type));
121
 
122
 
123
  BRAM#(idx_type, data_type) br <- mkBRAM(0, valueof(TExp#(idx)) - 1);
124
 
125
  return br;
126
 
127
endmodule
128
module mkBRAM_2#(Integer low, Integer high)
129
  //interface:
130
              (BRAM_2#(idx_type, data_type))
131
  provisos
132
          (Bits#(idx_type, idx),
133
           Bits#(data_type, data),
134
           Literal#(idx_type));
135
 
136
  BRAM#(idx_type, data_type) br1 <- mkBRAM(low, high);
137
  BRAM#(idx_type, data_type) br2 <- mkBRAM(low, high);
138
 
139
  method read_req1(idx) = br1.read_req(idx);
140
  method read_req2(idx) = br2.read_req(idx);
141
 
142
  method read_resp1() = br1.read_resp();
143
  method read_resp2() = br2.read_resp();
144
 
145
  method Action write(idx_type idx, data_type data);
146
 
147
    br1.write(idx, data);
148
    br2.write(idx, data);
149
 
150
  endmethod
151
 
152
endmodule
153
 
154
module mkBRAM_2_Full
155
  //interface:
156
              (BRAM_2#(idx_type, data_type))
157
  provisos
158
          (Bits#(idx_type, idx),
159
           Bits#(data_type, data),
160
           Literal#(idx_type));
161
 
162
 
163
  BRAM_2#(idx_type, data_type) br <- mkBRAM_2(0, valueof(TExp#(idx)) - 1);
164
 
165
  return br;
166
 
167
endmodule
168
 
169
module mkBRAM_3#(Integer low, Integer high)
170
  //interface:
171
              (BRAM_3#(idx_type, data_type))
172
  provisos
173
          (Bits#(idx_type, idx),
174
           Bits#(data_type, data),
175
           Literal#(idx_type));
176
 
177
  BRAM#(idx_type, data_type) br1 <- mkBRAM(low, high);
178
  BRAM#(idx_type, data_type) br2 <- mkBRAM(low, high);
179
  BRAM#(idx_type, data_type) br3 <- mkBRAM(low, high);
180
 
181
  method read_req1(idx) = br1.read_req(idx);
182
  method read_req2(idx) = br2.read_req(idx);
183
  method read_req3(idx) = br3.read_req(idx);
184
 
185
  method read_resp1() = br1.read_resp();
186
  method read_resp2() = br2.read_resp();
187
  method read_resp3() = br3.read_resp();
188
 
189
  method Action write(idx_type idx, data_type data);
190
 
191
    br1.write(idx, data);
192
    br2.write(idx, data);
193
    br3.write(idx, data);
194
 
195
  endmethod
196
 
197
endmodule
198
 
199
 
200
module mkBRAM_3_Full
201
  //interface:
202
              (BRAM_3#(idx_type, data_type))
203
  provisos
204
          (Bits#(idx_type, idx),
205
           Bits#(data_type, data),
206
           Literal#(idx_type));
207
 
208
 
209
  BRAM_3#(idx_type, data_type) br <- mkBRAM_3(0, valueof(TExp#(idx)) - 1);
210
 
211
  return br;
212
 
213
endmodule
214
 

powered by: WebSVN 2.1.0

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