VSYML Ocaml Meeting 2009

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

VHDL Symbolic simulator in

OCaml
Florent Ouchet florent.ouchet@imag.fr
TIMA Labs GINP UJ F CNRS VDS group
OCaml Meeting 2009
Grenoble France
04/02/2009
Florent Ouchet OCaml meeting 2009 Grenoble France
2
Outline
VSYML Vhdl Symbolic Simulator in ocaML:
Symbolic simulation goals
Why OCaml?
Application structure and limitations of OCaml in
this context
Perspectives
Conclusion
Florent Ouchet OCaml meeting 2009 Grenoble France
3
Symbolic simulation goals
Model is needed for:
Model checking: equivalence of IC
implementation and specification;
Other formal methods based on the model:
(ANR project FME
3
) analysis of error
consequences using formal methods.
Florent Ouchet OCaml meeting 2009 Grenoble France
4
Symbolic simulation goals
Integrated circuit synthesis flow:
Modeling level
Register
Transfert Level
Gate Level
Layout
Chips
FSM, complex types
Explicit time,behavioral
Boolean type
Drawing of transistors
and wires
Manual refinements
Automatic synthesis
Placing and routing
Manufacturing
Florent Ouchet OCaml meeting 2009 Grenoble France
5
Symbolic simulation goals
Existing symbolic simulators:
Modeling level
Register Transfert
Level
Gate Level
Layout
Chips
FSM, complex types
Explicit time,behavioral
Boolean type
Drawing of transistors
and wires
VOSS/Forte
(Intel CAD Labs)
Florent Ouchet OCaml meeting 2009 Grenoble France
6
Symbolic simulation goals
Existing symbolic simulators:
Modeling level
Register Transfert
Level
Gate Level
Layout
Chips
FSM, complex types
Explicit time,behavioral
Boolean type
Drawing of transistors
and wires
VSYML
Florent Ouchet OCaml meeting 2009 Grenoble France
7
Symbolic simulation goals
Integrated Circuit
Description
Design Under Test
(DUT)
X
t=0 ns
X
t=1 ns

Y
t=0 ns
Y
t=1 ns

X
t=0
+ Y
t=1
?
Description written in VHDL (IEEE Std 1076.1
TM
2007)
Symbolic values depend on the time.
Florent Ouchet OCaml meeting 2009 Grenoble France
8
Why OCaml?
Expression patterns:
X@1ns
1

unary_operator
X (not abs)
X
assoc_operator
Y (+ * and or xor xnor)
X
binary_operator
Y (nand nor ^= /= < > <= >=)
X
other_operator
Y (mod rem / -)
(total of 28 patterns)
Florent Ouchet OCaml meeting 2009 Grenoble France
9
Why OCaml?
type formula =
| FormulaSymbol of symbol
| FormulaImmediateInt of big_int
| FormulaUnaryOperator of (unary_operator*formula)
| FormulaAssociativeOperator of (assoc_operator*formula list)
| FormulaBinaryOperator of (binary_operator*formula*formula)
| FormulaOtherOperator of (other_operator*formula*formula list)
|
Florent Ouchet OCaml meeting 2009 Grenoble France
10
Why OCaml?
Known expression patterns are rewritten
(numeric evaluation);
As in the standard, the simulation
algorithm is intrinsically free of side
effects.
Florent Ouchet OCaml meeting 2009 Grenoble France
11
Why OCaml?
Process
A
Process
B
Process
C
The next value of each signal is computed from current values.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
12
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
13
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
14
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
15
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
16
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
17
Why OCaml?
Process
A
Process
B
Process
C
The processes are executed until the design is stabilized.
DUT
Florent Ouchet OCaml meeting 2009 Grenoble France
18
Why OCaml?
Strong type checking (compared to C,
Pascal): confidence in computations;
Lexer/parser generator;
Free software, its ancestor was written in
Mathematica;
Lightweight and easy to redist (J ava, C#, F#).
Florent Ouchet OCaml meeting 2009 Grenoble France
19
Application structure
VSYML
VHDL
source files
Design model
parameters
Standalone and automated application.
Florent Ouchet OCaml meeting 2009 Grenoble France
20
Application structure
Some facts:
Over 26500 lines of code
24 dedicated modules (types, basics, lexer,
parser, resources, evaluators, converters,
volume extrusion, top-level)
Florent Ouchet OCaml meeting 2009 Grenoble France
21
Application structure
Straightforward
conversion from BNF
rules (language spec)
No syntax for optional
tokens
Debugging conflicts is
a nightmare
VHDL source files
(thousands lines)
Lexer
(59 states, 1058 transitions)
Parser
(695 grammar rules,1318 states)
Abstract
syntax tree
Florent Ouchet OCaml meeting 2009 Grenoble France
22
Application structure
Some basic functions
are missing in OCaml
standard libraries
Issue 4662 closed as
wont fix
Abstract
syntax tree
Design elaboration
Simulation
structure tree
Florent Ouchet OCaml meeting 2009 Grenoble France
23
Application structure
A function to map a list of functions to the
same parameter:
(a -> b) list -> a -> b list
A function to remove the n first list
elements:
a list -> int -> a list
Florent Ouchet OCaml meeting 2009 Grenoble France
24
Application structure
Unbounded integers in
VHDL (32 bits at least -
"Time" requires 64 bits)
Simulation of design on
n bits
Big_int
Abstract
syntax tree
Design elaboration
Simulation
structure tree
Florent Ouchet OCaml meeting 2009 Grenoble France
25
Application structure
Big_int is an abstract
type
(=) (<) (>) on Big_int
raise runtime exceptions
Associative list functions
based on (=)
Abstract
syntax tree
Design elaboration
Simulation
structure tree
Florent Ouchet OCaml meeting 2009 Grenoble France
26
Application structure
Many executions of
the functional
structure with different
evaluation contexts
Simulation
structure tree
Simulation algorithm
Simulation results
Florent Ouchet OCaml meeting 2009 Grenoble France
27
Application structure
Signature of process simulation function:
process -> structure_context ->
evaluation_context -> changed_object list
Florent Ouchet OCaml meeting 2009 Grenoble France
28
Prototype of process simulation function:
process -> structure_context ->
evaluation_context -> changed_object list
Functors for efficiency (+50%)
Application structure
Florent Ouchet OCaml meeting 2009 Grenoble France
29
Application structure
Prototype of process simulation function:
process -> structure_context ->
evaluation_context -> changed_signal list
evaluation_context = {
simulation_time: Big_int;
currentvalues: (signal*formula) list; }
Test with array, hashtbl and references
Florent Ouchet OCaml meeting 2009 Grenoble France
30
Application structure
Some timings: FIR filter simulation, 1000
clock cycles.
Parsing
+ elab.
Simulation Output Process
memory
GC bytes
assoc 40 ms 9.60 s 1.20 s 2.4 Mo 1189 Mo
array 40 ms 1.82 s 1.20 s 2.4 Mo 910 Mo
hashtbl 40 ms 2.00 s 1.17 s 2.3 Mo 921 Mo
ref 40 ms 1.76 s 1.25 s 2.3 Mo 899 Mo
Florent Ouchet OCaml meeting 2009 Grenoble France
31
Application structure
Process
A
Process
B
Process
C
DUT
Load averaging for a multi-thread simulation.
Communication efficiency for a distributed simulation.
Florent Ouchet OCaml meeting 2009 Grenoble France
32
Perspectives
Spread the simulation over cores and
computers: an integrated circuit is a fixed
finite set of concurrent process
concurrent simulation but:
lots of rendez-vous and communications
Irregular load
Mathematics: loop invariants
Florent Ouchet OCaml meeting 2009 Grenoble France
33
Conclusion
Development for project FME
3
is now
finished.
Research prototype for parallel
computations?
Release to the public? CeCill Licence?
Florent Ouchet OCaml meeting 2009 Grenoble France
34
Questions?
Thanks for your attention

You might also like