-
Notifications
You must be signed in to change notification settings - Fork 2
/
hazard.h
52 lines (45 loc) · 1.54 KB
/
hazard.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
#ifndef HAZARDMOD_H
#define HAZARDMOD_H
/**
*
* hazard module interface.
*/
#include <systemc.h>
/**
* hazard module.
* hazard module is the hazard detection unit.
*
* - input ports
* - \c sc_uint<5> \c rs - first register being read
* - \c sc_uint<5> \c rt - second register being read
* - \c sc_uint<5> \c WriteReg_exe - register to be written (EXE)
* - \c sc_uint<5> \c WriteReg_mem - register to be written (MEM)
* - \c bool \c RegWrite_exe - control signal of writing registers (EXE)
* - \c bool \c RegWrite_mem - control signal of writing registers (MEM)
* - output ports
* - \c bool \c enable_pc - enables PC update
* - \c bool \c enable_ifid - enables IF/ID update
* - \c bool \c reset_idexe - resets IF/EXE
*/
SC_MODULE( hazard )
{
public:
sc_in< sc_uint<5> > rs;
sc_in< sc_uint<5> > rt;
sc_in< bool > MemRead_exe, MemRead_mem;
sc_in< sc_uint<5> > WriteReg_exe, WriteReg_mem, WriteReg_wb;
sc_in< bool > RegWrite_exe, RegWrite_mem, RegWrite_wb;
sc_in< bool > BranchTaken;
sc_out< bool > enable_pc, enable_ifid, enable_rfile, enable_id1id2, reset_id1id2, reset_idexe, reset_ifid, reset_exmem, reset_memwb;
SC_CTOR(hazard)
{
SC_METHOD(detect_hazard);
sensitive << rs << rt
<< WriteReg_exe << RegWrite_exe << WriteReg_wb
<< WriteReg_mem << RegWrite_mem << RegWrite_wb
<< MemRead_exe << MemRead_mem
<< BranchTaken;
}
void detect_hazard();
};
#endif