-
Notifications
You must be signed in to change notification settings - Fork 0
/
functional_units.c
66 lines (60 loc) · 1.71 KB
/
functional_units.c
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
62
63
64
65
66
#include "definitions.h"
static int available_float_functional_units;
static int available_int_functional_units;
void initialize_functional_units()
{
available_float_functional_units = num_of_float_functional_units;
available_int_functional_units = num_of_int_functional_units;
}
bool there_are_free_functional_units(ASMinstr instr)
{
if(isSDinstrE(instr.instr.r.cmd) || isLDinstrE(instr.instr.r.cmd) || isRRinstrE(instr.instr.r.cmd) || isBinstrE(instr.instr.r.cmd))
{
if(available_int_functional_units > 0)
{
return true;
}
error(E_FUNC_UN, ACTION_PRINTMSG);
return false;
}
else
{
if(available_float_functional_units > 0)
return true;
}
error(E_FUNC_UN, ACTION_PRINTMSG);
return false;
}
void update_functional_units()
{
//The floating point units are pipelined
available_float_functional_units = num_of_float_functional_units;
}
bool get_functional_unit(ASMinstr instr)
{
if(isSDinstrE(instr.instr.r.cmd) || isLDinstrE(instr.instr.r.cmd) || isRRinstrE(instr.instr.r.cmd) || isBinstrE(instr.instr.r.cmd))
{
if(available_int_functional_units > 0)
{
available_int_functional_units--;
return true;
}
return false;
}
else
{
if(available_float_functional_units>0)
{
available_float_functional_units--;
return true;
}
}
return false;
}
void free_functional_unit(ASMinstr cmd)
{
if(isSDinstrE(cmd.instr.r.cmd) || isLDinstrE(cmd.instr.r.cmd) || isRRinstrE(cmd.instr.r.cmd) || isBinstrE(cmd.instr.r.cmd))
available_int_functional_units++;
else
available_float_functional_units++;
}