-
Notifications
You must be signed in to change notification settings - Fork 2
/
regfile.h
61 lines (51 loc) · 1.44 KB
/
regfile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef REGFILEMOD_H
#define REGFILEMOD_H
/**
*
* Regfile module interface.
*/
#include <systemc.h>
#include "mem32.h"
/**
* Regfile module.
* Regfile module models the integer register bank of MIPS.
* Synchronous on writes, assinchronous on read.
*
* - input ports
* - \c sc_uint<5> \c reg1 - id1 of register to read
* - \c sc_uint<5> \c reg2 - id2 of register to read
* - \c sc_uint<5> \c regwrite - id of register to write
* - \c sc_uint<32> \c datawr - value to write
* - \c bool \c wr - write enable
* - \c bool \c clk - clock
* - \c bool \c reset - reset
* - output ports
* - \c sc_uint<32> \c data1 - value of register id1
* - \c sc_uint<32> \c data2 - value of register id2
*/
class regfile : public sc_module, public mem32
{
public:
sc_in< sc_uint<5> > reg1;
sc_in< sc_uint<5> > reg2;
sc_in< sc_uint<5> > regwrite;
sc_in< sc_uint<32> > datawr;
sc_in<bool> wr;
sc_in<bool> clk;
sc_in<bool> reset;
sc_in<bool> enable;
sc_out< sc_uint<32> > data1;
sc_out< sc_uint<32> > data2;
sc_signal< sc_uint<5> > s_reg1, s_reg2;
SC_CTOR(regfile)
{
SC_METHOD(regfile_access);
sensitive_pos << clk;
sensitive << s_reg1 << s_reg2;
init_regs();
}
void init_regs();
void dump();
void regfile_access();
};
#endif