aboutsummaryrefslogtreecommitdiffstats
path: root/awlsim/core/cpu.pxd.in
blob: 3c2aa40784c41d4660e096fc22ee91bddb894115 (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
from awlsim.common.cython_support cimport *
from awlsim.common.cpuspecs cimport *
from awlsim.common.movingavg cimport *
from awlsim.core.statusword cimport *
from awlsim.core.callstack cimport *
from awlsim.core.lstack cimport *
from awlsim.core.offset cimport *
from awlsim.core.operators cimport *
from awlsim.core.memory cimport *
from awlsim.core.blocks cimport *
from awlsim.core.userdefinedtypes cimport *
from awlsim.core.datablocks cimport *
from awlsim.core.timers cimport *
from awlsim.core.counters cimport *
from awlsim.core.insnmeas cimport *
from awlsim.core.systemblocks.systemblocks cimport *


cdef class S7CPU(object):
	cdef public object cbCycleExit
	cdef public object cbCycleExitData
	cdef public object cbBlockExit
	cdef public object cbBlockExitData
	cdef public object cbPostInsn
	cdef public object cbPostInsnData
	cdef public object cbPeripheralRead
	cdef public object cbPeripheralReadData
	cdef public object cbPeripheralWrite
	cdef public object cbPeripheralWriteData
	cdef public object cbScreenUpdate
	cdef public object cbScreenUpdateData

	cdef public double now
	cdef public double __nowOffset

	cdef public S7CPUSpecs specs
	cdef public object conf
	cdef public object prog
	cdef public double cycleTimeLimit
	cdef public double __runtimeLimit
	cdef public _Bool __obTempPresetsEnabled
	cdef public _Bool __extendedInsnsEnabled
	cdef public dict __dateAndTimeWeekdayMap

	cdef public list __udts
	cdef public list __dbs
	cdef public list __obs
	cdef public OB __ob1
	cdef public dict obTempPresetHandlers
	cdef public list __fcs
	cdef public list __fbs
	cdef public list __sfcs
	cdef public dict __sfcsExtended
	cdef public list __sfbs
	cdef public dict __sfbsExtended
	cdef public uint32_t __udtsAlloc
	cdef public uint32_t __dbsAlloc
	cdef public uint32_t __obsAlloc
	cdef public uint32_t __fcsAlloc
	cdef public uint32_t __fbsAlloc
	cdef public uint32_t __sfcsAlloc
	cdef public uint32_t __sfbsAlloc

	cdef public S7StatusWord statusWord
	cdef public _Bool is4accu
	cdef public Accu accu1
	cdef public Accu accu2
	cdef public Accu accu3
	cdef public Accu accu4
	cdef public list timers
	cdef public list counters
	cdef public AwlMemory flags
	cdef public AwlMemory inputs
	cdef public AwlMemory outputs
	cdef public Addressregister ar1
	cdef public Addressregister ar2
	cdef public DB dbRegister
	cdef public DB diRegister
	cdef public DB db0

	cdef public _Bool mcrActive
	cdef public list mcrStack

	cdef public AwlOffset __clockMemByteOffset
	cdef public double __nextClockMemTime
	cdef public uint32_t __clockMemCount
	cdef public uint32_t __clockMemCountLCM

	cdef public int32_t relativeJump
	cdef public CallStackElem callStackTop
	cdef public uint32_t callStackDepth
	cdef public LStackAllocator activeLStack

	cdef public uint32_t __insnCount
	cdef public uint32_t __cycleCount
	cdef public double insnPerSecond
	cdef public double avgInsnPerCycle
	cdef public double cycleStartTime
	cdef public double minCycleTime
	cdef public double maxCycleTime
	cdef public double avgCycleTime
	cdef public MovingAvg __cycleTimeMovAvg
	cdef public double startupTime
	cdef public double __speedMeasureStartTime
	cdef public uint32_t __speedMeasureStartInsnCount
	cdef public uint32_t __speedMeasureStartCycleCount
	cdef public MovingAvg __timestampUpdMovAvg
	cdef public double __timestampUpdInter
	cdef public uint32_t __timestampUpdInterMask
	cdef public InsnMeas __insnMeas

	cdef UDT getUDT(self, uint16_t index)
	cdef DB getDB(self, uint16_t index)
	cdef CodeBlock getOB(self, uint16_t index)
	cdef CodeBlock getFC(self, uint16_t index)
	cdef CodeBlock getFB(self, uint16_t index)
	cdef CodeBlock getSFC(self, int32_t index)
	cdef CodeBlock getSFB(self, int32_t index)

	cdef void setMcrActive(self, _Bool active)
	cdef _Bool mcrIsOn(self)
	cdef mcrStackAppend(self, S7StatusWord statusWord)
	cdef mcrStackPop(self)

	cdef AwlMemoryObject fetch(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchIMM(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchIMM_DT(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchIMM_PTR(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchIMM_STR(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDBLG(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDBNO(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDILG(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDINO(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchAR2(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_Z(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_NZ(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_POS(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_NEG(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_POSZ(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_NEGZ(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchSTW_UO(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchE(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchA(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchM(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchL(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchVL(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDB(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchDI(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchPE(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchT(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchZ(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchNAMED_LOCAL(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchNAMED_LOCAL_PTR(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchNAMED_DBVAR(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchINDIRECT(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchVirtACCU(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchVirtAR(self, AwlOperator operator, uint32_t allowedWidths) except NULL
	cdef AwlMemoryObject __fetchVirtDBR(self, AwlOperator operator, uint32_t allowedWidths) except NULL

	cdef store(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeE(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeA(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeM(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeL(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeVL(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeDB(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeDI(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storePA(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeAR2(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeSTW(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeNAMED_LOCAL(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeNAMED_DBVAR(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)
	cdef __storeINDIRECT(self, AwlOperator operator, AwlMemoryObject memObj, uint32_t allowedWidths)

	cdef bytearray fetchOutputRange(self, uint32_t byteOffset, uint32_t byteCount)
	cdef uint8_t fetchOutputByte(self, uint32_t byteOffset)
	cdef bytearray fetchInputRange(self, uint32_t byteOffset, uint32_t byteCount)
	cdef uint8_t fetchInputByte(self, uint32_t byteOffset)
	cdef storeInputRange(self, uint32_t byteOffset, bytearray data)
	cdef storeInputByte(self, uint32_t byteOffset, uint8_t data)

	cdef updateTimestamp(self)
	cdef __cycleTimeExceed(self)
	cdef __checkRunTimeLimit(self)

	cdef runCycle(self)
	cdef __runOB(self, OB block)
	cdef void run_BE(self)
	cdef openDB(self, int32_t dbNumber, _Bool openDI)
	cdef run_AUF(self, AwlOperator dbOper)
	cdef void run_TDB(self)

	cdef Accu getAccu(self, uint32_t index)
	cdef Addressregister getAR(self, uint32_t index)
	cdef Timer getTimer(self, uint32_t index)
	cdef Counter getCounter(self, uint32_t index)

	cdef int32_t labelIdxToRelJump(self, uint32_t labelIndex)
	cdef void jumpToLabel(self, uint32_t labelIndex)
	cdef void jumpRelative(self, int32_t insnOffset)

	cdef run_CALL(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters, _Bool raw)
	cdef CallStackElem __call_FC(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_RAW_FC(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_FB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_RAW_FB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_SFC(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_RAW_SFC(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_SFB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_RAW_SFB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_INDIRECT(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_MULTI_FB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)
	cdef CallStackElem __call_MULTI_SFB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters)

	cdef AwlOperator __translateFCNamedLocalOper(self, AwlOperator operator, _Bool store)

	cdef makeCurrentDateAndTime(self, uint8_t *byteArray, uint32_t offset)

	cdef __dumpLStackFrame(self, prefix, LStackFrame *frame)
bues.ch cgit interface