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

Subversion Repositories bluespec-h264

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

powered by: WebSVN 2.1.0

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