Mercurial > pygar
comparison modules/bluespec/Pygar/core/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 |
comparison
equal
deleted
inserted
replaced
7:7393cd19371e | 8:74716e9a81cc |
---|---|
1 import RegFile::*; | |
2 import RWire::*; | |
3 import ProcTypes::*; | |
4 | |
5 //----------------------------------------------------------- | |
6 // Register file module | |
7 //----------------------------------------------------------- | |
8 | |
9 interface BRegFile #(type index_t, type data_t); | |
10 method Action upd(index_t addr, data_t data); | |
11 method data_t sub(index_t addr); | |
12 endinterface | |
13 | |
14 module mkBRegFile(RegFile#(index_t, data_t)) | |
15 provisos (Bits#(index_t, size_index), | |
16 Bits#(data_t, size_data), | |
17 Eq#(index_t), | |
18 Bounded#(index_t) ); | |
19 | |
20 RegFile#(index_t, data_t) rf <- mkRegFileWCF(minBound, maxBound); | |
21 RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire(); | |
22 | |
23 method Action upd (index_t r, data_t d); | |
24 rf.upd(r,d); | |
25 rw.wset(tuple2(r,d)); | |
26 endmethod | |
27 | |
28 method data_t sub (index_t r); | |
29 case (rw.wget()) matches | |
30 tagged Valid {.wr, .d} : | |
31 return (wr == r) ? d : rf.sub(r); | |
32 tagged Invalid : return rf.sub(r); | |
33 endcase | |
34 endmethod | |
35 | |
36 endmodule |