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 3

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

Line No. Rev Author Line
1 3 jamey.hick
import FIFO::*;
2
 
3
interface SRAM#(type idx_type, type data_type);
4
 
5
  method Action read_req(idx_type idx);
6
 
7
  method ActionValue#(data_type) read_resp();
8
 
9
  method Action write(idx_type idx, data_type data);
10
 
11
 
12
  method Bit#(18) address_out();
13
  method Bit#(32) data_out();
14
  method Action data_in(Bit#(32) data);
15
  method Bit#(1) data_tri();
16
  method Bit#(4) we_bytes_out();
17
  method Bit#(1) we_out();
18
  method Bit#(1) ce_out();
19
  method Bit#(1) oe_out();
20
  method Bit#(1) cen_out();
21
  method Bit#(1) adv_ld_out();
22
 
23
endinterface
24
 
25
 
26
module mkSRAM#(Integer low, Integer high)
27
  //interface:
28
              (SRAM#(idx_type, data_type))
29
  provisos
30
          (Bits#(idx_type, idx),
31
           Bitwise#(idx_type),
32
           Bits#(data_type, data),
33
           Bitwise#(data_type),
34
           Literal#(data_type),
35
           Literal#(idx_type));
36
 
37
  SRAM#(idx_type, data_type) m <- (valueof(data) == 0) ?
38
                                   mkSRAM_Zero() :
39
                                   mkSRAM_NonZero(low, high);
40
 
41
  return m;
42
endmodule
43
 
44
import "BVI" SRAM = module mkSRAM_NonZero#(Integer low, Integer high)
45
  //interface:
46
              (SRAM#(idx_type, data_type))
47
  provisos
48
          (Bits#(idx_type, idx),
49
           Bitwise#(idx_type),
50
           Bits#(data_type, data),
51
           Bitwise#(data_type),
52
           Literal#(data_type),
53
           Literal#(idx_type));
54
 
55
  default_clock clk(CLK);
56
  default_reset rst(RST_N);
57
 
58
  parameter addr_width = valueof(idx);
59
  parameter data_width = valueof(data);
60
  parameter lo = low;
61
  parameter hi = high;
62
 
63
  method DOUT read_resp() ready(DOUT_RDY) enable(DOUT_EN);
64
 
65
  method read_req(RD_ADDR) ready(RD_RDY) enable(RD_EN);
66
  method write(WR_ADDR, WR_VAL) enable(WR_EN);
67
 
68
  // All of these are physical wires and therefore always enabled/ready
69
  method ADDR_O address_out();
70
  method DATA_BUS_O data_out();
71
  method data_in(DATA_BUS_I) enable((*inhigh*) DUMMY_EN) ;
72
  method DATA_BUS_T data_tri();
73
  method WE_BYTES_N_O we_bytes_out();
74
  method WE_N_O we_out();
75
  method CE_N_O ce_out();
76
  method OE_N_O oe_out();
77
  method CEN_N_O cen_out();
78
  method ADV_LD_N_O adv_ld_out();
79
 
80
  schedule read_req  CF read_resp;
81
  schedule read_resp CF (read_req, write);
82
  schedule write     CF read_resp;
83
  schedule (read_req, write, read_resp) CF (address_out, data_out, data_in, data_tri,
84
                                            we_bytes_out, we_out, ce_out, oe_out,
85
                                            cen_out, adv_ld_out);
86
  schedule (address_out, data_out, data_in, data_tri,
87
            we_bytes_out, we_out, ce_out, oe_out,
88
            cen_out, adv_ld_out)
89
           CF
90
           (address_out, data_out, data_in, data_tri,
91
            we_bytes_out, we_out, ce_out, oe_out,
92
            cen_out, adv_ld_out, read_req, write, read_resp);
93
 
94
  //It may be dangerous not to have data_in conflict with itself.
95
  schedule data_in   C data_in;
96
  schedule read_req  C (read_req, write);
97
  schedule read_resp C read_resp;
98
  schedule write     C (write, read_req);
99
 
100
endmodule
101
 
102
module mkSRAM_Zero
103
  //interface:
104
              (SRAM#(idx_type, data_type))
105
    provisos
106
          (Bits#(idx_type, idx),
107
           Bitwise#(idx_type),
108
           Bits#(data_type, data),
109
           Bitwise#(data_type),
110
           Literal#(data_type),
111
           Literal#(idx_type));
112
 
113
  FIFO#(data_type) q <- mkSizedFIFO(4);
114
 
115
  method Action read_req(idx_type i);
116
     q.enq(?);
117
  endmethod
118
 
119
  method Action write(idx_type i, data_type d);
120
    noAction;
121
  endmethod
122
 
123
  method ActionValue#(data_type) read_resp();
124
    q.deq();
125
    return q.first();
126
  endmethod
127
 
128
  method Bit#(18) address_out();
129
    return ~0;
130
  endmethod
131
 
132
  method Bit#(32) data_out();
133
    return ~0;
134
  endmethod
135
 
136
  method Action data_in(Bit#(32) data);
137
    noAction;
138
  endmethod
139
 
140
  method Bit#(1) data_tri();
141
    return ~0;
142
  endmethod
143
 
144
  method Bit#(4) we_bytes_out();
145
    return ~0;
146
  endmethod
147
 
148
  method Bit#(1) we_out();
149
    return ~0;
150
  endmethod
151
 
152
  method Bit#(1) ce_out();
153
    return ~0;
154
  endmethod
155
 
156
  method Bit#(1) oe_out();
157
    return ~0;
158
  endmethod
159
 
160
  method Bit#(1) cen_out();
161
    return ~0;
162
  endmethod
163
 
164
  method Bit#(1) adv_ld_out();
165
    return ~0;
166
  endmethod
167
endmodule
168
 
169
module mkSRAM_Full
170
  //interface:
171
              (SRAM#(idx_type, data_type))
172
  provisos
173
          (Bits#(idx_type, idx),
174
           Bitwise#(idx_type),
175
           Bits#(data_type, data),
176
           Bitwise#(data_type),
177
           Literal#(data_type),
178
           Literal#(idx_type));
179
 
180
  SRAM#(idx_type, data_type) br <- mkSRAM(0, valueof(TExp#(idx)) - 1);
181
 
182
  return br;
183
 
184
endmodule
185
 

powered by: WebSVN 2.1.0

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