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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [release/] [mkFrameBuffer.bsv] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 85 jamey.hick
// The MIT License
2
 
3
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
4
 
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
 
12
// The above copyright notice and this permission notice shall be included in
13
// all copies or substantial portions of the Software.
14
 
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
// THE SOFTWARE.
22 84 jamey.hick
//**********************************************************************
23
// Frame Buffer
24
//----------------------------------------------------------------------
25
//
26
//
27
//
28
 
29
package mkFrameBuffer;
30
 
31
import H264Types::*;
32
import IFrameBuffer::*;
33
import RegFile::*;
34
import GetPut::*;
35
import ClientServer::*;
36
import FIFO::*;
37
 
38
 
39
//-----------------------------------------------------------
40
// Register file module
41
//-----------------------------------------------------------
42
 
43
interface FBRFile2;
44
   method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
45
   method Bit#(32) load1( Bit#(FrameBufferSz) addr );
46
   method Bit#(32) load2( Bit#(FrameBufferSz) addr );
47
endinterface
48
 
49
module mkFBRFile2( FBRFile2 );
50
 
51
   RegFile#(Bit#(FrameBufferSz),Bit#(32)) rfile <- mkRegFile(0,frameBufferSize);
52
 
53
   method Action store( Bit#(FrameBufferSz) addr, Bit#(32) data );
54
      rfile.upd( addr, data );
55
   endmethod
56
 
57
   method Bit#(32) load1( Bit#(FrameBufferSz) addr );
58
      return rfile.sub(addr);
59
   endmethod
60
 
61
   method Bit#(32) load2( Bit#(FrameBufferSz) addr );
62
      return rfile.sub(addr);
63
   endmethod
64
 
65
endmodule
66
 
67
 
68
//----------------------------------------------------------------------
69
// Main module
70
//----------------------------------------------------------------------
71
 
72
module mkFrameBuffer( IFrameBuffer );
73
 
74
  //-----------------------------------------------------------
75
  // State
76
 
77
   FBRFile2 rfile2 <- mkFBRFile2;
78
 
79
   FIFO#(FrameBufferLoadReq)  loadReqQ1  <- mkFIFO();
80
   FIFO#(FrameBufferLoadResp) loadRespQ1 <- mkFIFO();
81
   FIFO#(FrameBufferLoadReq)  loadReqQ2  <- mkFIFO();
82
   FIFO#(FrameBufferLoadResp) loadRespQ2 <- mkFIFO();
83
   FIFO#(FrameBufferStoreReq) storeReqQ  <- mkFIFO();
84
 
85
   rule loading1 ( loadReqQ1.first() matches tagged FBLoadReq .addrt );
86
      if(addrt
87
         begin
88
            loadRespQ1.enq( tagged FBLoadResp rfile2.load1(addrt) );
89
            loadReqQ1.deq();
90
         end
91
      else
92
         $display( "ERROR FrameBuffer: loading1 outside range" );
93
   endrule
94
 
95
   rule loading2 ( loadReqQ2.first() matches tagged FBLoadReq .addrt );
96
      if(addrt
97
         begin
98
            loadRespQ2.enq( tagged FBLoadResp rfile2.load2(addrt) );
99
            loadReqQ2.deq();
100
         end
101
      else
102
         $display( "ERROR FrameBuffer: loading2 outside range" );
103
   endrule
104
 
105
   rule storing ( storeReqQ.first() matches tagged FBStoreReq { addr:.addrt,data:.datat} );
106
      if(addrt
107
         begin
108
            rfile2.store(addrt,datat);
109
            storeReqQ.deq();
110
         end
111
      else
112
         $display( "ERROR FrameBuffer: storing outside range" );
113
   endrule
114
 
115
   rule syncing ( loadReqQ1.first() matches tagged FBEndFrameSync &&& loadReqQ2.first() matches tagged FBEndFrameSync &&& storeReqQ.first() matches tagged FBEndFrameSync);
116
      loadReqQ1.deq();
117
      loadReqQ2.deq();
118
      storeReqQ.deq();
119
   endrule
120
 
121
 
122
   interface Server server_load1;
123
      interface Put request   = fifoToPut(loadReqQ1);
124
      interface Get response  = fifoToGet(loadRespQ1);
125
   endinterface
126
   interface Server server_load2;
127
      interface Put request   = fifoToPut(loadReqQ2);
128
      interface Get response  = fifoToGet(loadRespQ2);
129
   endinterface
130
   interface Put server_store = fifoToPut(storeReqQ);
131
 
132
endmodule
133
 
134
endpackage

powered by: WebSVN 2.1.0

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