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 |
//**********************************************************************
|
25 |
|
|
// Frame Buffer
|
26 |
|
|
//----------------------------------------------------------------------
|
27 |
|
|
//
|
28 |
|
|
//
|
29 |
|
|
//
|
30 |
|
|
|
31 |
|
|
package mkFrameBuffer;
|
32 |
|
|
|
33 |
|
|
import H264Types::*;
|
34 |
|
|
import IFrameBuffer::*;
|
35 |
|
|
import RegFile::*;
|
36 |
|
|
import GetPut::*;
|
37 |
|
|
import ClientServer::*;
|
38 |
|
|
import FIFO::*;
|
39 |
|
|
import FIFOF::*;
|
40 |
|
|
import mkRoundRobinMemScheduler::*;
|
41 |
|
|
import mkSRAMMemController::*;
|
42 |
|
|
import IMemClient::*;
|
43 |
|
|
import IMemController::*;
|
44 |
|
|
import IMemScheduler::*;
|
45 |
|
|
import ISRAMWires::*;
|
46 |
|
|
import IVgaController::*;
|
47 |
|
|
import SRAM::*;
|
48 |
|
|
import BlueSRAM::*;
|
49 |
|
|
import BlueBRAM::*;
|
50 |
|
|
|
51 |
|
|
//-----------------------------------------------------------
|
52 |
|
|
// Register file module
|
53 |
|
|
//-----------------------------------------------------------
|
54 |
|
|
|
55 |
|
|
interface FBRFile;
|
56 |
|
|
method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
|
57 |
|
|
method Bit#(32) load( Bit#(FrameBufferSz) addr );
|
58 |
|
|
endinterface
|
59 |
|
|
|
60 |
|
|
/*module mkFBRFile( FBRFile );
|
61 |
|
|
|
62 |
|
|
RegFile#(Bit#(FrameBufferSz),Bit#(32)) rfile <- mkRegFile(0,frameBufferSize);
|
63 |
|
|
|
64 |
|
|
method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
|
65 |
|
|
rfile.upd( addr, data );
|
66 |
|
|
endmethod
|
67 |
|
|
|
68 |
|
|
method Bit#(32) load( Bit#(FrameBufferSz) addr );
|
69 |
|
|
return rfile.sub(addr);
|
70 |
|
|
endmethod
|
71 |
|
|
|
72 |
|
|
endmodule*/
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
//----------------------------------------------------------------------
|
76 |
|
|
// Main module
|
77 |
|
|
//----------------------------------------------------------------------
|
78 |
|
|
|
79 |
|
|
module mkFrameBuffer( IFrameBuffer );
|
80 |
|
|
|
81 |
|
|
//-----------------------------------------------------------
|
82 |
|
|
// State
|
83 |
|
|
|
84 |
|
|
FIFOF#(FrameBufferLoadReq) loadReqQ <- mkFIFOF();
|
85 |
|
|
FIFOF#(FrameBufferLoadResp) loadRespQ <- mkFIFOF();
|
86 |
|
|
FIFOF#(FrameBufferStoreReq) storeReqQ <- mkFIFOF();
|
87 |
|
|
|
88 |
|
|
BlueSRAM#(Bit#(18), Bit#(32)) sram <- mkBlueSRAM_Full();
|
89 |
|
|
BlueBRAM#(Bit#(18), Bit#(32)) bram <- mkBlueBRAM_Full();
|
90 |
|
|
|
91 |
|
|
Reg#(Bit#(4)) outstandingReqs <- mkReg(0); // We make the true assumption that the memory controller
|
92 |
|
|
// only supports 2 outstanding requests per client.
|
93 |
|
|
|
94 |
|
|
rule read_request ( loadReqQ.first() matches tagged FBLoadReq .addrt );
|
95 |
|
|
if(addrt
|
96 |
|
|
begin
|
97 |
|
|
bram.read_req(truncate(unpack(addrt)));
|
98 |
|
|
loadReqQ.deq();
|
99 |
|
|
outstandingReqs <= outstandingReqs + 1;
|
100 |
|
|
$display("FBuff req , addr: %h, outstanding reqs: %d", addrt, outstandingReqs + 1);
|
101 |
|
|
end
|
102 |
|
|
else
|
103 |
|
|
$display( "ERROR FrameBuffer: loading outside range" );
|
104 |
|
|
endrule
|
105 |
|
|
|
106 |
|
|
rule read_response;
|
107 |
|
|
Bit#(32) resp_data <- bram.read_resp();
|
108 |
13 |
jamey.hick |
loadRespQ.enq(FBLoadResp (resp_data));
|
109 |
3 |
jamey.hick |
outstandingReqs <= outstandingReqs - 1;
|
110 |
|
|
$display("FBuff resp , data: %h outstanding reqs: %d", resp_data, outstandingReqs - 1);
|
111 |
|
|
endrule
|
112 |
|
|
|
113 |
|
|
rule storing ( storeReqQ.first() matches tagged FBStoreReq { addr:.addrt,data:.datat} );
|
114 |
|
|
if(addrt
|
115 |
|
|
begin
|
116 |
|
|
bram.write(addrt,datat);
|
117 |
|
|
storeReqQ.deq();
|
118 |
|
|
$display("FBuff, write req addr: %h data: %h", addrt, datat );
|
119 |
|
|
end
|
120 |
|
|
else
|
121 |
|
|
$display( "ERROR FrameBuffer: storing outside range" );
|
122 |
|
|
endrule
|
123 |
|
|
|
124 |
|
|
rule store_full(outstandingReqs > 0);
|
125 |
|
|
$display("FBuff: StoreQ.notfull(): %b .notempty(): %b",storeReqQ.notFull(),storeReqQ.notEmpty());
|
126 |
|
|
$display("FBuff: LoadRespQ.notfull(): %b .notempty(): %b",loadRespQ.notFull(),loadRespQ.notEmpty());
|
127 |
|
|
$display("FBuff: LoadReqQ.notfull(): %b .notempty(): %b",loadReqQ.notFull(),loadReqQ.notEmpty());
|
128 |
|
|
endrule
|
129 |
|
|
|
130 |
|
|
rule syncing ( loadReqQ.first() matches tagged FBEndFrameSync &&& storeReqQ.first() matches tagged FBEndFrameSync);
|
131 |
|
|
//if(outstandingReqs == 0)
|
132 |
|
|
// begin
|
133 |
|
|
loadReqQ.deq();
|
134 |
|
|
storeReqQ.deq();
|
135 |
|
|
// end
|
136 |
|
|
endrule
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
interface Server server_load;
|
140 |
|
|
interface Put request = fifoToPut(fifofToFifo(loadReqQ));
|
141 |
|
|
interface Get response = fifoToGet(fifofToFifo(loadRespQ));
|
142 |
|
|
endinterface
|
143 |
|
|
interface Put server_store = fifoToPut(fifofToFifo(storeReqQ));
|
144 |
|
|
|
145 |
|
|
interface ISRAMWires sram_controller;
|
146 |
|
|
method Bit#(18) address_out();
|
147 |
|
|
return sram.address_out();
|
148 |
|
|
endmethod
|
149 |
|
|
|
150 |
|
|
method Bit#(32) data_O();
|
151 |
|
|
return sram.data_out();
|
152 |
|
|
endmethod
|
153 |
|
|
|
154 |
|
|
method Action data_I(Bit#(32) data);
|
155 |
|
|
sram.data_in(data);
|
156 |
|
|
endmethod
|
157 |
|
|
|
158 |
|
|
method Bit#(1) data_T();
|
159 |
|
|
return sram.data_tri();
|
160 |
|
|
endmethod
|
161 |
|
|
|
162 |
|
|
method Bit#(4) we_bytes_out();
|
163 |
|
|
return sram.we_bytes_out();
|
164 |
|
|
endmethod
|
165 |
|
|
|
166 |
|
|
method Bit#(1) we_out();
|
167 |
|
|
return sram.we_out();
|
168 |
|
|
endmethod
|
169 |
|
|
|
170 |
|
|
method Bit#(1) ce_out();
|
171 |
|
|
return sram.ce_out();
|
172 |
|
|
endmethod
|
173 |
|
|
|
174 |
|
|
method Bit#(1) oe_out();
|
175 |
|
|
return sram.oe_out();
|
176 |
|
|
endmethod
|
177 |
|
|
|
178 |
|
|
method Bit#(1) cen_out();
|
179 |
|
|
return sram.cen_out();
|
180 |
|
|
endmethod
|
181 |
|
|
|
182 |
|
|
method Bit#(1) adv_ld_out();
|
183 |
|
|
return sram.adv_ld_out();
|
184 |
|
|
endmethod
|
185 |
|
|
endinterface
|
186 |
|
|
|
187 |
|
|
endmodule
|
188 |
|
|
|
189 |
|
|
endpackage
|