rlm@8
|
1 import RegFile::*;
|
rlm@8
|
2 import RWire::*;
|
rlm@8
|
3 import ProcTypes::*;
|
rlm@8
|
4
|
punk@58
|
5 `include "asim/provides/low_level_platform_interface.bsh"
|
punk@58
|
6 `include "asim/provides/soft_connections.bsh"
|
punk@58
|
7 `include "asim/provides/fpga_components.bsh"
|
punk@58
|
8 `include "asim/provides/common_services.bsh"
|
punk@58
|
9
|
rlm@8
|
10 //-----------------------------------------------------------
|
rlm@8
|
11 // Register file module
|
rlm@8
|
12 //-----------------------------------------------------------
|
rlm@8
|
13
|
rlm@8
|
14 interface BRegFile #(type index_t, type data_t);
|
rlm@8
|
15 method Action upd(index_t addr, data_t data);
|
rlm@8
|
16 method data_t sub(index_t addr);
|
rlm@8
|
17 endinterface
|
rlm@8
|
18
|
rlm@8
|
19 module mkBRegFile(RegFile#(index_t, data_t))
|
rlm@8
|
20 provisos (Bits#(index_t, size_index),
|
rlm@8
|
21 Bits#(data_t, size_data),
|
rlm@8
|
22 Eq#(index_t),
|
rlm@8
|
23 Bounded#(index_t) );
|
rlm@8
|
24
|
punk@58
|
25 LUTRAM#(index_t, data_t) rf <- mkLUTRAM_RegFile();
|
rlm@8
|
26 RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire();
|
rlm@8
|
27
|
rlm@8
|
28 method Action upd (index_t r, data_t d);
|
rlm@8
|
29 rf.upd(r,d);
|
rlm@8
|
30 rw.wset(tuple2(r,d));
|
rlm@8
|
31 endmethod
|
rlm@8
|
32
|
rlm@8
|
33 method data_t sub (index_t r);
|
rlm@8
|
34 case (rw.wget()) matches
|
rlm@8
|
35 tagged Valid {.wr, .d} :
|
rlm@8
|
36 return (wr == r) ? d : rf.sub(r);
|
rlm@8
|
37 tagged Invalid : return rf.sub(r);
|
rlm@8
|
38 endcase
|
rlm@8
|
39 endmethod
|
rlm@8
|
40
|
rlm@8
|
41 endmodule
|