Upload
others
View
16
Download
0
Embed Size (px)
Citation preview
An Open Source Tool for Performing Coupled OpenModelica – FPGA Simulations
Adam LangeEngineering contractor
Lange Turbo
1
2
3
sensors4
sensors
controller
5
actuators
sensors
controller
6
actuators
sensors
controller
7
OpenModelica
Initial System Model
actuators
sensors
controller
8
OpenModelica
Initial System Model
actuators
sensors
controller
Step 1: System design and feasibility study
Creativity
Equations
Design iterations
9
OpenModelica
Initial System Model
Physical Prototype
actuators
sensors
controller
10
OpenModelica
Initial System Model
Physical Prototype
actuators
sensors
controller
(with a FPGA !)
11
OpenModelica
Initial System Model
Physical Prototype
actuators
sensors
controller
12
OpenModelica
Initial System Model
Physical Prototype
actuators
sensors
controller
borrow
actuators
3D print
13
OpenModelica
Initial System Model
Physical Prototype
actuators
sensors
controller
borrow
actuators
3D print
(with a FPGA !)
14
Main Control Algoritm
SensorInterface
∙ Polls the sensors∙ Produces outputs at any time
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
15
RegisterTransferLevelAbstraction
MainControlAlgorithm.v
SensorInterface.v
Controller.v
sensorinterface
datareadyvalid
sensor16
RegisterTransfer
AbstractionSensorInterface.v
Controller.v
17
RegisterTransfer
AbstractionSensorInterface.v
Controller.v
C-to-verilog
High Level Synthesis
C-to-verilog
High Level
Synthesis
18
RegisterTransfer
AbstractionSensorInterface.v
Controller.v
Modelica-to-RTL
High Level Synthesis??
Modelica-to-RTL
High Level
Synthesis??
19
RegisterTransferLevelAbstraction
MainControlAlgorithm.v
SensorInterface.v
Controller.v
sensorinterface
datareadyvalid
sensor20
MainControlAlgorithm.v
Controller
Vendor Tools~5-10 min
FPGA
21
Main Control Algoritm
SensorInterface
RegisterTransferLevelAbstraction
∙ Polls the sensors∙ Produces outputs at any time
MainControlAlgorithm.v
SensorInterface.v
Controller.v
Controller
Vendor Tools~5-10 min
FPGA
C-to-verilog
High Level Synthesis
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
22
Main Control Algoritm
SensorInterface
∙ Polls the sensors∙ Produces outputs at any time
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
23
Main Control Algoritm
SensorInterface
∙ Polls the sensors∙ Produces outputs at any time
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
dataacquisition
dataacquisition
dataacquisition
dataacquisition
24
Main Control Algoritm
SensorInterface
∙ Polls the sensors∙ Produces outputs at any time
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
probe
dataacquisition
dataacquisition
dataacquisition
dataacquisition
25
Main Control Algoritm
SensorInterface
RegisterTransferLevelAbstraction
∙ Polls the sensors∙ Produces outputs at any time
MainControlAlgorithm.v
SensorInterface.v
Controller.v
Controller
Vendor Tools~5-10 min
FPGA
C-to-verilog
High Level Synthesis
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
probe
dataacquisition
dataacquisition
dataacquisition
dataacquisition
26
actuators
sensors
controller
27
Main Control Algoritm
SensorInterface
RegisterTransferLevelAbstraction
∙ Polls the sensors∙ Produces outputs at any time
MainControlAlgorithm.v
SensorInterface.v
Controller.v
Controller
Vendor Tools~5-10 min
FPGA
C-to-verilog
High Level Synthesis
C-to-verilog
High Level
Synthesis
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
probe
dataacquisition
dataacquisition
dataacquisition
dataacquisition
28
Main Control Algoritm
SensorInterface
RegisterTransferLevelAbstraction
∙ Polls the sensors∙ Produces outputs at any time
MainControlAlgorithm.v
testbench.v
Assumedideal
outputinterface
datareadyvalid
datareadyvalid
sensorinterface
timer
trigger
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
datareadyvalid
booleanoutputs
sensor
sensorinterface
trigger
datareadyvalid
sensor
probe
dataacquisition
dataacquisition
dataacquisition
dataacquisition
29
run controller simulation until controllerneeds to read a sensor
Earth time →
Run OpenModelica for Δt1 seconds of simulation time
Events are re-created using whenevents
Δt0
When the controllersimulation runs, events are stored.
Δt1
Controller simulation time →
physics simulation time →
OpenModelica
Icarus Verilog and Cocotb
tsim = ta
Controller sensor reading
Controller output event
← send event queue
← send Δt0
sen
d se
nso
r valu
es →
tsim = ta
30
run controller simulation until controllerneeds to read a sensor
Earth time →
Δt0
Controller simulation time →
Icarus Verilog and Cocotb
tsim = ta← send event queue
← send Δt0
d sen
sor va
lues →
31
run controller simulation until controllerneeds to read a sensor
Δt0
Controller simulation time →
Icarus Verilog and Cocotb
tsim = ta
Event occured!Store event time andvalue of the controler outputs.
store event!
store event!
t = t1t = t2
t = t3
32
run controller simulation until controllerneeds to read a sensor
Δt0
Controller simulation time →
Icarus Verilog and Cocotb
tsim = ta
Event occured!Store event time andvalue of the controler outputs.
store event!
store event!
t = t1t = t2
t = t3
33
run controller simulation until controllerneeds to read a sensor
Δt0
tsim = ta
Event occured!Store event time andvalue of the controler outputs.
store event!
store event! Controller requeststhat the sensors arepolled
t = t1t = t2
t = t3
A blocking functionsends event info tomodelica.
34
run controller simulation until controllerneeds to read a sensor
Δt0
When the controllersimulation runs, events are stored.
e controler outputs.
store event!
store event! Controller requeststhat the sensors arepolled
t = t3
A blocking functionsends event info tomodelica.
35
← send event queue
← send Δt0
sen
d se
nso
r valu
es →
36
Run OpenModelica for Δt1 seconds of simulation time
sen
d se
nso
r valu
es →
sim = ta Modelica when eventis triggered at t = t1
and controller output values are set
when event for outputwhen event for output
t = t2t = t8
when event triggersan impure function callat Δt1 , where controllerrequested to poll sensors
modelica execution is blockby the function
37
Run OpenModelica for Δt of simulation time
ics simulation time →
sim = ta Modelica when eventis triggered at t = t1
and controller output values are set
when event for outputt = t2
38
Run OpenModelica for Δt of simulation time
sim = ta Modelica when eventis triggered at t = t1
and controller output values are set
when event for outputwhen event for output
t = t2t = t
39
Run OpenModelica for Δt1 seconds of simulation time
when event for outputwhen event for output
t = t8
when event triggersan impure function callat Δt1 , where controllerrequested to poll sensors
40
OpenModelica for Δt1 seconds Events are re-created usinevents
when event triggersan impure function callat Δt1 , where controllerrequested to poll sensors
modelica execution is blockedby the function
41
run controller simulation until controllerneeds to read a sensor
Run OpenModelica for Δt1 seconds of simulation time
Events are re-created using whenevents
Δt0
When the controllersimulation runs, events are stored.
Δt1
simulation time →
mulation time →
rilog and Cocotb
Controller sensor rea
Controller output eve
← send event queue
← send Δt0
sen
d se
nso
r valu
es →
42
run controller simulation until controllerneeds to read a sensor
Earth time →
Run OpenModelica for Δt1 seconds of simulation time
Events are re-created using whenevents
Δt0
When the controllersimulation runs, events are stored.
Δt1
Controller simulation time →
physics simulation time →
OpenModelica
Icarus Verilog and Cocotb
tsim = ta
Controller sensor reading
Controller output event
← send event queue
← send Δt0
sen
d se
nso
r valu
es →
tsim = ta
43
Event occured!Store event time andvalue of the controler outputs.
store event!
store event! Controller requeststhat the sensors arepolled
t = t1t = t2
t = t3
A blocking functionsends event info tomodelica.
OpenModelicaPython script
web socket
generatedc library
generatedmodelicamodel
Icarus Verilogsimulator
generatedpython module
input file(JSON format)
code generator
CocotbSystemmodel
44
Event occured!Store event time andvalue of the controler outputs.
store event!
store event! Controller requeststhat the sensors arepolled
t = t1t = t2
t = t3
A blocking functionsends event info tomodelica.
Python script
web socket
Icarus Verilogsimulator
generatedpython module
input file(JSON format)
Cocotb
MainControlAlgorithm.v
testbench.v
45
https://github.com/adamLange/hdlModelicaInterfaceGen