annotate core/src/BRegFile.bsv @ 32:0c775e733b81 pygar svn.33

[svn r33] audio core benchmark script added and the benchmark setup is half-way to working
author punk
date Mon, 03 May 2010 09:53:56 -0400
parents 91a1f76ddd62
children
rev   line source
punk@1 1 import RegFile::*;
punk@1 2 import RWire::*;
punk@1 3 import ProcTypes::*;
punk@1 4
punk@1 5 //-----------------------------------------------------------
punk@1 6 // Register file module
punk@1 7 //-----------------------------------------------------------
punk@1 8
punk@1 9 interface BRegFile #(type index_t, type data_t);
punk@1 10 method Action upd(index_t addr, data_t data);
punk@1 11 method data_t sub(index_t addr);
punk@1 12 endinterface
punk@1 13
punk@1 14 module mkBRegFile(RegFile#(index_t, data_t))
punk@1 15 provisos (Bits#(index_t, size_index),
punk@1 16 Bits#(data_t, size_data),
punk@1 17 Eq#(index_t),
punk@1 18 Bounded#(index_t) );
punk@1 19
punk@1 20 RegFile#(index_t, data_t) rf <- mkRegFileWCF(minBound, maxBound);
punk@1 21 RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire();
punk@1 22
punk@1 23 method Action upd (index_t r, data_t d);
punk@1 24 rf.upd(r,d);
punk@1 25 rw.wset(tuple2(r,d));
punk@1 26 endmethod
punk@1 27
punk@1 28 method data_t sub (index_t r);
punk@1 29 case (rw.wget()) matches
punk@1 30 tagged Valid {.wr, .d} :
punk@1 31 return (wr == r) ? d : rf.sub(r);
punk@1 32 tagged Invalid : return rf.sub(r);
punk@1 33 endcase
punk@1 34 endmethod
punk@1 35
punk@1 36 endmodule