Mercurial > pygar
view modules/bluespec/Pygar/lab4/BRegFile.bsv @ 62:90fa9b289aab pygar svn.63
[svn r63] synthesis boundaries
author | punk |
---|---|
date | Mon, 10 May 2010 21:00:49 -0400 |
parents | 6179c07c21d7 |
children | 1d5cbb5343d2 |
line wrap: on
line source
1 import RegFile::*;2 import RWire::*;3 import ProcTypes::*;5 `include "asim/provides/low_level_platform_interface.bsh"6 `include "asim/provides/soft_connections.bsh"7 `include "asim/provides/fpga_components.bsh"8 `include "asim/provides/common_services.bsh"10 //-----------------------------------------------------------11 // Register file module12 //-----------------------------------------------------------14 interface BRFile;15 method Action wr( Rindx rindx, Bit#(32) data );16 method Action Value Bit#(32) rd1( Rindx rindx );17 method Action Value Bit#(32) rd2( Rindx rindx );18 endinterface20 (* doc = "synthesis attribute ram_style mkBRegFile distributed;" *)21 (* synthesize *)22 module mkBRegFile(BRFile)23 provisos (Bits#(index_t, size_index),24 Bits#(data_t, size_data),25 Eq#(index_t),26 Bounded#(index_t) );28 LUTRAM#(index_t, data_t) rf <- mkLUTRAMU_RegFile();29 RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire();31 method Action wr( Rindx rindx, Bit#(32) data );32 rf.upd( rindx, data );33 rw.wset(tuple2(rindex,data));34 endmethod36 method Bit#(32) rd1 (Rindx r);37 if (r == 0) return 0;38 else begin39 case (rw.wget()) matches40 tagged Valid {.wr, .d} :41 return (wr == r) ? d : rf.sub(r);42 tagged Invalid : return rf.sub(r);43 endcase44 end45 endmethod47 method Bit#(32) rd2 (Rindx r);48 if (r == 0) return 0;49 else begin50 case (rw.wget()) matches51 tagged Valid {.wr, .d} :52 return (wr == r) ? d : rf.sub(r);53 tagged Invalid : return rf.sub(r);54 endcase55 end56 endmethod58 endmodule