-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdh_hw_mult.cpp
85 lines (66 loc) · 1.45 KB
/
dh_hw_mult.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "systemc.h"
#include "digit.h"
#include "dh_hw_mult.h"
#include "hardware.h"
/* New Hardware Implementation */
enum fsm_state{
WAIT = 0,
EXECUTE,
UPDATE,
OUTPUT,
FINISH
};
fsm_state state = WAIT;
void dh_hw_mult::process_hw_mult()
{
for (;;)
{
switch(state)
{
case WAIT:
// std::cout << "wait state (hw_mult)" << std::endl;
default:
if (hw_mult_enable.read() == true)
{
ldrb.write(true);
ldrc.write(true);
ldra0.write(false);
ldra1.write(false);
state = EXECUTE;
}
break;
case EXECUTE:
// std::cout << "execute state (hw_mult)" << std::endl;
ldra0.write(true);
ldra1.write(true);
ldrb.write(false);
ldrc.write(false);
state = UPDATE;
//wait();
break;
case UPDATE:
ldra0.write(false);
ldra1.write(false);
state = OUTPUT;
break;
case OUTPUT:
// std::cout << "output state (hw_mult)" << std::endl;
// Write outputs state
out_data_low.write(a0_sig.read());
out_data_high.write(a1_sig.read());
hw_mult_done.write(true);
state = FINISH;
//wait();
break;
case FINISH:
// std::cout << "finish state (hw_mult)" << std::endl;
if (hw_mult_enable.read() == false)
{
hw_mult_done.write(false);
state = WAIT;
}
break;
}
wait(); // wait for a change of hw_mult_enable
}
}