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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src_fpga/] [SRAM.bsv] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 83 jamey.hick
 
2
// The MIT License
3
 
4
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
5
 
6
// Permission is hereby granted, free of charge, to any person obtaining a copy
7
// of this software and associated documentation files (the "Software"), to deal
8
// in the Software without restriction, including without limitation the rights
9
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
// copies of the Software, and to permit persons to whom the Software is
11
// furnished to do so, subject to the following conditions:
12
 
13
// The above copyright notice and this permission notice shall be included in
14
// all copies or substantial portions of the Software.
15
 
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
// THE SOFTWARE.
23
 
24 3 jamey.hick
import FIFO::*;
25
 
26
interface SRAM#(type idx_type, type data_type);
27
 
28
  method Action read_req(idx_type idx);
29
 
30
  method ActionValue#(data_type) read_resp();
31
 
32
  method Action write(idx_type idx, data_type data);
33
 
34
 
35
  method Bit#(18) address_out();
36
  method Bit#(32) data_out();
37
  method Action data_in(Bit#(32) data);
38
  method Bit#(1) data_tri();
39
  method Bit#(4) we_bytes_out();
40
  method Bit#(1) we_out();
41
  method Bit#(1) ce_out();
42
  method Bit#(1) oe_out();
43
  method Bit#(1) cen_out();
44
  method Bit#(1) adv_ld_out();
45
 
46
endinterface
47
 
48
 
49
module mkSRAM#(Integer low, Integer high)
50
  //interface:
51
              (SRAM#(idx_type, data_type))
52
  provisos
53
          (Bits#(idx_type, idx),
54
           Bitwise#(idx_type),
55
           Bits#(data_type, data),
56
           Bitwise#(data_type),
57
           Literal#(data_type),
58
           Literal#(idx_type));
59
 
60
  SRAM#(idx_type, data_type) m <- (valueof(data) == 0) ?
61
                                   mkSRAM_Zero() :
62
                                   mkSRAM_NonZero(low, high);
63
 
64
  return m;
65
endmodule
66
 
67
import "BVI" SRAM = module mkSRAM_NonZero#(Integer low, Integer high)
68
  //interface:
69
              (SRAM#(idx_type, data_type))
70
  provisos
71
          (Bits#(idx_type, idx),
72
           Bitwise#(idx_type),
73
           Bits#(data_type, data),
74
           Bitwise#(data_type),
75
           Literal#(data_type),
76
           Literal#(idx_type));
77
 
78
  default_clock clk(CLK);
79
  default_reset rst(RST_N);
80
 
81
  parameter addr_width = valueof(idx);
82
  parameter data_width = valueof(data);
83
  parameter lo = low;
84
  parameter hi = high;
85
 
86
  method DOUT read_resp() ready(DOUT_RDY) enable(DOUT_EN);
87
 
88
  method read_req(RD_ADDR) ready(RD_RDY) enable(RD_EN);
89
  method write(WR_ADDR, WR_VAL) enable(WR_EN);
90
 
91
  // All of these are physical wires and therefore always enabled/ready
92
  method ADDR_O address_out();
93
  method DATA_BUS_O data_out();
94
  method data_in(DATA_BUS_I) enable((*inhigh*) DUMMY_EN) ;
95
  method DATA_BUS_T data_tri();
96
  method WE_BYTES_N_O we_bytes_out();
97
  method WE_N_O we_out();
98
  method CE_N_O ce_out();
99
  method OE_N_O oe_out();
100
  method CEN_N_O cen_out();
101
  method ADV_LD_N_O adv_ld_out();
102
 
103
  schedule read_req  CF read_resp;
104
  schedule read_resp CF (read_req, write);
105
  schedule write     CF read_resp;
106
  schedule (read_req, write, read_resp) CF (address_out, data_out, data_in, data_tri,
107
                                            we_bytes_out, we_out, ce_out, oe_out,
108
                                            cen_out, adv_ld_out);
109
  schedule (address_out, data_out, data_in, data_tri,
110
            we_bytes_out, we_out, ce_out, oe_out,
111
            cen_out, adv_ld_out)
112
           CF
113
           (address_out, data_out, data_in, data_tri,
114
            we_bytes_out, we_out, ce_out, oe_out,
115
            cen_out, adv_ld_out, read_req, write, read_resp);
116
 
117
  //It may be dangerous not to have data_in conflict with itself.
118
  schedule data_in   C data_in;
119
  schedule read_req  C (read_req, write);
120
  schedule read_resp C read_resp;
121
  schedule write     C (write, read_req);
122
 
123
endmodule
124
 
125
module mkSRAM_Zero
126
  //interface:
127
              (SRAM#(idx_type, data_type))
128
    provisos
129
          (Bits#(idx_type, idx),
130
           Bitwise#(idx_type),
131
           Bits#(data_type, data),
132
           Bitwise#(data_type),
133
           Literal#(data_type),
134
           Literal#(idx_type));
135
 
136
  FIFO#(data_type) q <- mkSizedFIFO(4);
137
 
138
  method Action read_req(idx_type i);
139
     q.enq(?);
140
  endmethod
141
 
142
  method Action write(idx_type i, data_type d);
143
    noAction;
144
  endmethod
145
 
146
  method ActionValue#(data_type) read_resp();
147
    q.deq();
148
    return q.first();
149
  endmethod
150
 
151
  method Bit#(18) address_out();
152
    return ~0;
153
  endmethod
154
 
155
  method Bit#(32) data_out();
156
    return ~0;
157
  endmethod
158
 
159
  method Action data_in(Bit#(32) data);
160
    noAction;
161
  endmethod
162
 
163
  method Bit#(1) data_tri();
164
    return ~0;
165
  endmethod
166
 
167
  method Bit#(4) we_bytes_out();
168
    return ~0;
169
  endmethod
170
 
171
  method Bit#(1) we_out();
172
    return ~0;
173
  endmethod
174
 
175
  method Bit#(1) ce_out();
176
    return ~0;
177
  endmethod
178
 
179
  method Bit#(1) oe_out();
180
    return ~0;
181
  endmethod
182
 
183
  method Bit#(1) cen_out();
184
    return ~0;
185
  endmethod
186
 
187
  method Bit#(1) adv_ld_out();
188
    return ~0;
189
  endmethod
190
endmodule
191
 
192
module mkSRAM_Full
193
  //interface:
194
              (SRAM#(idx_type, data_type))
195
  provisos
196
          (Bits#(idx_type, idx),
197
           Bitwise#(idx_type),
198
           Bits#(data_type, data),
199
           Bitwise#(data_type),
200
           Literal#(data_type),
201
           Literal#(idx_type));
202
 
203
  SRAM#(idx_type, data_type) br <- mkSRAM(0, valueof(TExp#(idx)) - 1);
204
 
205
  return br;
206
 
207
endmodule
208
 

powered by: WebSVN 2.1.0

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