-
Notifications
You must be signed in to change notification settings - Fork 2
/
control.h
61 lines (51 loc) · 1.42 KB
/
control.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 CONTROLMOD_H
#define CONTROLMOD_H
/**
*
* Control module interface.
*/
#include <systemc.h>
/**
* Control module.
* Control module models the control unit of MIPS.
* - input ports
* - \c sc_uint<6> \c opcode - instruction opcode field
* - \c sc_uint<6> \c funct - instruction funct field
* - output ports
* - \c bool \c RegDst - selects if rd or rt is written
* - \c bool \c RegWrite - enables writing in Register file
* - \c bool \c MemRead - enables reading from Memory
* - \c bool \c MemWrite - enables writing to Memory
* - \c bool \c MemtoReg - Value to write in register comes from memory
* - \c sc_uint<6> \c ALUOp - selects ALU operation
* - \c bool \c ALUSrc - selects ALU second operand
* - \c bool \c Branch - active if instruction is beq
*/
SC_MODULE(control) {
sc_in< sc_uint<6> > opcode;
sc_in< sc_uint<6> > funct;
/* jbr (output) defined as:
* 0: No jump/branch
* 1: beq
* 2: bne
* 3: bgtz
* 4: blez
* 5: j
* 6: jr
*/
sc_out < sc_uint<3> > jbr;
sc_out< bool > RegDst;
sc_out< bool > MemRead;
sc_out< bool > MemtoReg;
sc_out< sc_uint<3> > ALUOp;
sc_out< bool > MemWrite;
sc_out< bool > ALUSrc;
sc_out< bool > RegWrite;
SC_CTOR(control)
{
SC_METHOD(entry);
sensitive << opcode << funct;
}
void entry();
};
#endif