-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsm.cpp
123 lines (100 loc) · 2.44 KB
/
fsm.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "fsm.h"
void FSM::setInputSize(const size_t inputSize)
{
m_inputSize = inputSize;
}
void FSM::setOutputSize(const size_t outputSize)
{
m_outputSize = outputSize;
}
void FSM::setSignalNames(const QString &inputSignalName, const QString &outputSignalName, const QString &clockSignalName, const QString &resetSignalName, const QString ¤tStateRegisterName, const QString &nextStateRegisterName)
{
m_inputSignalName = inputSignalName;
m_outputSignalName = outputSignalName;
m_clockSignalName = clockSignalName;
m_resetSignalName = resetSignalName;
m_currentStateRegisterName = currentStateRegisterName;
m_nextStateRegisterName = nextStateRegisterName;
}
QString FSM::getTimeUnit() const
{
return m_timeUnit;
}
QString FSM::getTimePrecisionUnit() const
{
return m_timePrecisionUnit;
}
QString FSM::getModuleName() const
{
return m_moduleName;
}
QString FSM::getInputSignalName() const
{
return m_inputSignalName;
}
QString FSM::getOutputSignalName() const
{
return m_outputSignalName;
}
QString FSM::getResetSignalName() const
{
return m_resetSignalName;
}
QString FSM::getClockSignalName() const
{
return m_clockSignalName;
}
QString FSM::getCurrentStateRegisterName() const
{
return m_currentStateRegisterName;
}
QString FSM::getNextStateRegisterName() const
{
return m_nextStateRegisterName;
}
size_t FSM::getInputSize() const
{
return m_inputSize;
}
size_t FSM::getOutputSize() const
{
return m_outputSize;
}
void FSM::setModuleName(const QString &moduleName)
{
m_moduleName = moduleName;
}
EdgeEnum FSM::getClockEgde() const
{
return m_clockEgde;
}
EdgeEnum FSM::getResetEdge() const
{
return m_resetEdge;
}
ResetModeEnum FSM::getResetMode() const
{
return m_resetMode;
}
const QString FSM::getTimeUnitString(UnitEnum unit)
{
switch (unit) {
case Seconds: return "s";
case Milliseconds: return "ms";
case Microseconds: return "us";
case Nanoseconds: return "ns";
case Picoseconds: return "ps";
case Femtoseconds: return "fs";
}
}
FSM::FSM(QObject *parent) : QObject(parent)
{
}
void FSM::setCodeSettings(EdgeEnum clockEgde, EdgeEnum resetEdge, ResetModeEnum resetMode, UnitEnum timeUnit, UnitEnum timePrecisionUnit)
{
m_clockEgde = clockEgde;
m_resetEdge = resetEdge;
m_resetMode = resetMode;
m_timeUnit = getTimeUnitString(timeUnit);
m_timePrecisionUnit = getTimeUnitString(timePrecisionUnit);
}