Mercurial > pygar
view modules/bluespec/Pygar/lab4/BRegFile.bsv @ 58:52f9a257c2ba pygar svn.59
[svn r59] LUTRAMing
author | punk |
---|---|
date | Mon, 10 May 2010 13:47:12 -0400 |
parents | 74716e9a81cc |
children | 92041177735c |
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 BRegFile #(type index_t, type data_t);15 method Action upd(index_t addr, data_t data);16 method data_t sub(index_t addr);17 endinterface19 module mkBRegFile(RegFile#(index_t, data_t))20 provisos (Bits#(index_t, size_index),21 Bits#(data_t, size_data),22 Eq#(index_t),23 Bounded#(index_t) );25 LUTRAM#(index_t, data_t) rf <- mkLUTRAM_RegFile();26 RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire();28 method Action upd (index_t r, data_t d);29 rf.upd(r,d);30 rw.wset(tuple2(r,d));31 endmethod33 method data_t sub (index_t r);34 case (rw.wget()) matches35 tagged Valid {.wr, .d} :36 return (wr == r) ? d : rf.sub(r);37 tagged Invalid : return rf.sub(r);38 endcase39 endmethod41 endmodule