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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkFrameBuffer.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 2 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
 
40
 
41
//-----------------------------------------------------------
42
// Register file module
43
//-----------------------------------------------------------
44
 
45
interface FBRFile2;
46
   method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
47
   method Bit#(32) load1( Bit#(FrameBufferSz) addr );
48
   method Bit#(32) load2( Bit#(FrameBufferSz) addr );
49
endinterface
50
 
51
module mkFBRFile2( FBRFile2 );
52
 
53
   RegFile#(Bit#(FrameBufferSz),Bit#(32)) rfile <- mkRegFile(0,frameBufferSize);
54
 
55
   method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
56
      rfile.upd( addr, data );
57
   endmethod
58
 
59
   method Bit#(32) load1( Bit#(FrameBufferSz) addr );
60
      return rfile.sub(addr);
61
   endmethod
62
 
63
   method Bit#(32) load2( Bit#(FrameBufferSz) addr );
64
      return rfile.sub(addr);
65
   endmethod
66
 
67
endmodule
68
 
69
 
70
//----------------------------------------------------------------------
71
// Main module
72
//----------------------------------------------------------------------
73
 
74
module mkFrameBuffer( IFrameBuffer );
75
 
76
  //-----------------------------------------------------------
77
  // State
78
 
79
   FBRFile2 rfile2 <- mkFBRFile2;
80
 
81
   FIFO#(FrameBufferLoadReq)  loadReqQ1  <- mkFIFO();
82
   FIFO#(FrameBufferLoadResp) loadRespQ1 <- mkFIFO();
83
   FIFO#(FrameBufferLoadReq)  loadReqQ2  <- mkFIFO();
84
   FIFO#(FrameBufferLoadResp) loadRespQ2 <- mkFIFO();
85
   FIFO#(FrameBufferStoreReq) storeReqQ  <- mkFIFO();
86
 
87
   rule loading1 ( loadReqQ1.first() matches tagged FBLoadReq .addrt );
88
      if(addrt
89
         begin
90 62 jamey.hick
            loadRespQ1.enq( tagged FBLoadResp rfile2.load1(addrt) );
91 2 jamey.hick
            loadReqQ1.deq();
92
         end
93
      else
94
         $display( "ERROR FrameBuffer: loading1 outside range" );
95
   endrule
96
 
97
   rule loading2 ( loadReqQ2.first() matches tagged FBLoadReq .addrt );
98
      if(addrt
99
         begin
100 62 jamey.hick
            loadRespQ2.enq( tagged FBLoadResp rfile2.load2(addrt) );
101 2 jamey.hick
            loadReqQ2.deq();
102
         end
103
      else
104
         $display( "ERROR FrameBuffer: loading2 outside range" );
105
   endrule
106
 
107
   rule storing ( storeReqQ.first() matches tagged FBStoreReq { addr:.addrt,data:.datat} );
108
      if(addrt
109
         begin
110
            rfile2.store(addrt,datat);
111
            storeReqQ.deq();
112
         end
113
      else
114
         $display( "ERROR FrameBuffer: storing outside range" );
115
   endrule
116
 
117
   rule syncing ( loadReqQ1.first() matches tagged FBEndFrameSync &&& loadReqQ2.first() matches tagged FBEndFrameSync &&& storeReqQ.first() matches tagged FBEndFrameSync);
118
      loadReqQ1.deq();
119
      loadReqQ2.deq();
120
      storeReqQ.deq();
121
   endrule
122
 
123
 
124
   interface Server server_load1;
125
      interface Put request   = fifoToPut(loadReqQ1);
126
      interface Get response  = fifoToGet(loadRespQ1);
127
   endinterface
128
   interface Server server_load2;
129
      interface Put request   = fifoToPut(loadReqQ2);
130
      interface Get response  = fifoToGet(loadRespQ2);
131
   endinterface
132
   interface Put server_store = fifoToPut(storeReqQ);
133
 
134
endmodule
135
 
136
endpackage

powered by: WebSVN 2.1.0

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