1 |
5 |
kfleming |
/*
|
2 |
|
|
Copyright (c) 2007 MIT
|
3 |
|
|
|
4 |
|
|
Permission is hereby granted, free of charge, to any person
|
5 |
|
|
obtaining a copy of this software and associated documentation
|
6 |
|
|
files (the "Software"), to deal in the Software without
|
7 |
|
|
restriction, including without limitation the rights to use,
|
8 |
|
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
|
|
copies of the Software, and to permit persons to whom the
|
10 |
|
|
Software is furnished to do so, subject to the following
|
11 |
|
|
conditions:
|
12 |
|
|
|
13 |
|
|
The above copyright notice and this permission notice shall be
|
14 |
|
|
included in all copies or substantial portions of the Software.
|
15 |
|
|
|
16 |
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17 |
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18 |
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19 |
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20 |
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21 |
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22 |
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23 |
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
24 |
|
|
|
25 |
|
|
Author: Kermin Fleming
|
26 |
|
|
*/
|
27 |
|
|
|
28 |
|
|
import BRAMInitiatorWires::*;
|
29 |
|
|
import BRAM::*;
|
30 |
|
|
|
31 |
|
|
interface BRAMInitiator#(type idx_type);
|
32 |
|
|
interface BRAM#(idx_type, Bit#(32)) bram;
|
33 |
|
|
interface BRAMInitiatorWires#(idx_type) bramInitiatorWires;
|
34 |
|
|
endinterface
|
35 |
|
|
|
36 |
|
|
interface BRAMInitiatorFlat#(type idx_type);
|
37 |
|
|
method ActionValue#(Bit#(32)) read_resp();
|
38 |
|
|
method Action read_req(idx_type idx);
|
39 |
|
|
method Action write(idx_type idx, Bit#(32) value);
|
40 |
|
|
method Bit#(1) bramCLK();
|
41 |
|
|
method Bit#(1) bramRST();
|
42 |
|
|
method idx_type bramAddr();
|
43 |
|
|
method Bit#(32) bramDout();
|
44 |
|
|
method Action bramDin(Bit#(32) value);
|
45 |
|
|
method Bit#(4) bramWEN();
|
46 |
|
|
method Bit#(1) bramEN();
|
47 |
|
|
endinterface
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
module mkBRAMInitiator (BRAMInitiator#(idx_type))
|
51 |
|
|
provisos
|
52 |
|
|
(Bits#(idx_type, idx),
|
53 |
|
|
Literal#(idx_type));
|
54 |
|
|
BRAMInitiatorFlat#(idx_type) bramFlat <- mkBRAMInitiatorFlat();
|
55 |
|
|
|
56 |
|
|
interface BRAM bram;
|
57 |
|
|
method write = bramFlat.write;
|
58 |
|
|
method read_req = bramFlat.read_req;
|
59 |
|
|
method read_resp = bramFlat.read_resp;
|
60 |
|
|
endinterface
|
61 |
|
|
|
62 |
|
|
interface BRAMInitiatorWires bramInitiatorWires;
|
63 |
|
|
method bramCLK = bramFlat.bramCLK;
|
64 |
|
|
method bramRST = bramFlat.bramRST;
|
65 |
|
|
method bramAddr = bramFlat.bramAddr;
|
66 |
|
|
method bramDout = bramFlat.bramDout;
|
67 |
|
|
method bramDin = bramFlat.bramDin;
|
68 |
|
|
method bramWEN = bramFlat.bramWEN;
|
69 |
|
|
method bramEN = bramFlat.bramEN;
|
70 |
|
|
endinterface
|
71 |
|
|
|
72 |
|
|
endmodule
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
import "BVI" BRAMInitiator = module mkBRAMInitiatorFlat
|
77 |
|
|
//interface:
|
78 |
|
|
(BRAMInitiatorFlat#(idx_type))
|
79 |
|
|
provisos
|
80 |
|
|
(Bits#(idx_type, idx),
|
81 |
|
|
Literal#(idx_type));
|
82 |
|
|
|
83 |
|
|
default_clock clk(CLK);
|
84 |
|
|
|
85 |
|
|
parameter addr_width = valueof(idx);
|
86 |
|
|
|
87 |
|
|
method DOUT read_resp() ready(DOUT_RDY) enable(DOUT_EN);
|
88 |
|
|
|
89 |
|
|
method read_req(RD_ADDR) ready(RD_RDY) enable(RD_EN);
|
90 |
|
|
method write(WR_ADDR, WR_VAL) enable(WR_EN);
|
91 |
|
|
|
92 |
|
|
method BRAM_CLK bramCLK();
|
93 |
|
|
method BRAM_RST bramRST();
|
94 |
|
|
method BRAM_Addr bramAddr();
|
95 |
|
|
method BRAM_Dout bramDout();
|
96 |
|
|
method bramDin(BRAM_Din) enable(BRAM_Dummy_Enable);
|
97 |
|
|
method BRAM_WEN bramWEN();
|
98 |
|
|
method BRAM_EN bramEN();
|
99 |
|
|
|
100 |
|
|
schedule read_req CF (read_resp, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
101 |
|
|
schedule read_resp CF (read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
102 |
|
|
schedule write CF (read_req, read_resp, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
103 |
|
|
// All the BRAM methods are CF
|
104 |
|
|
schedule bramCLK CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
105 |
|
|
schedule bramRST CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
106 |
|
|
schedule bramAddr CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
107 |
|
|
schedule bramDout CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
108 |
|
|
schedule bramDin CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
109 |
|
|
schedule bramWEN CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
110 |
|
|
schedule bramEN CF (read_resp, read_req, write, bramCLK, bramRST, bramAddr, bramDout, bramDin, bramWEN, bramEN);
|
111 |
|
|
|
112 |
|
|
schedule read_req C read_req;
|
113 |
|
|
schedule read_resp C read_resp;
|
114 |
|
|
schedule write C write;
|
115 |
|
|
|
116 |
|
|
endmodule
|