diff modules/bluespec/Pygar/lab4/BRegFile.bsv @ 8:74716e9a81cc pygar svn.9

[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author rlm
date Fri, 23 Apr 2010 02:32:05 -0400
parents
children 52f9a257c2ba
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bluespec/Pygar/lab4/BRegFile.bsv	Fri Apr 23 02:32:05 2010 -0400
     1.3 @@ -0,0 +1,36 @@
     1.4 +import RegFile::*;
     1.5 +import RWire::*;
     1.6 +import ProcTypes::*;
     1.7 +
     1.8 +//-----------------------------------------------------------
     1.9 +// Register file module
    1.10 +//-----------------------------------------------------------
    1.11 +
    1.12 +interface BRegFile #(type index_t, type data_t);
    1.13 +   method Action upd(index_t addr, data_t data);
    1.14 +   method data_t sub(index_t addr);
    1.15 +endinterface
    1.16 +
    1.17 +module mkBRegFile(RegFile#(index_t, data_t)) 
    1.18 +   provisos (Bits#(index_t, size_index),
    1.19 +	     Bits#(data_t, size_data),
    1.20 +	     Eq#(index_t),
    1.21 +	     Bounded#(index_t) );
    1.22 +
    1.23 +   RegFile#(index_t, data_t) rf <- mkRegFileWCF(minBound, maxBound);
    1.24 +   RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire();
    1.25 +
    1.26 +   method Action upd (index_t r, data_t d);
    1.27 +      rf.upd(r,d);
    1.28 +      rw.wset(tuple2(r,d));
    1.29 +   endmethod
    1.30 +
    1.31 +   method data_t sub (index_t r);
    1.32 +      case (rw.wget()) matches
    1.33 +	 tagged Valid {.wr, .d} :
    1.34 +	    return (wr == r) ? d : rf.sub(r);
    1.35 +	 tagged Invalid : return rf.sub(r);
    1.36 +      endcase
    1.37 +   endmethod
    1.38 +   
    1.39 +endmodule