42: A Component-Based Approach to Virtual
Prototyping of Heterogeneous Embedded Systems
Ph.D. Defense
Tayeb
bouhadiba
Directrice de th`
ese : Florence
maraninchi
Jury:
Marc
pouzet
Rapporteur
Lionel
seinturier
Rapporteur
Jean-Bernard
stefani
Examinateur
September 15th 2010
Bouhadiba - Ph.D. Defense 42 September 15th 2010 1 / 45
Embedded Systems
Consumer Electronics
Safety Critical Systems
Introduction & Sources of Inspiration Embedded Systems
Embedded Systems, Components & Heterogeneity
+
Software
Hardware
Bouhadiba - Ph.D. Defense 42 September 15th 2010 3 / 45
Embedded Systems, Components & Heterogeneity
+
Software
Hardware
Processors
Hardware IP’s
(Intellectual Properties)
Introduction & Sources of Inspiration Embedded Systems
Embedded Systems, Components & Heterogeneity
+
Software
Hardware
Processors
Hardware IP’s
(Intellectual Properties)
Bouhadiba - Ph.D. Defense 42 September 15th 2010 3 / 45
Embedded Systems, Components & Heterogeneity
+
Software
Hardware
Processors
Hardware IP’s
(Intellectual Properties)
Digital
Analog
Introduction & Sources of Inspiration Embedded Systems
Embedded Systems, Components & Heterogeneity
+
Software
Hardware
Processors
Hardware IP’s
(Intellectual Properties)
Digital
Analog
Synchronous
Asynchronous
Bouhadiba - Ph.D. Defense 42 September 15th 2010 3 / 45
Virtual Prototyping
Virtual Prototyping
=
An Executable Model Before the System is
Manufactured
Introduction & Sources of Inspiration Embedded Systems
Virtual Prototyping
Virtual Prototyping
=
An Executable Model Before the System is
Manufactured
Modeling
Bouhadiba - Ph.D. Defense 42 September 15th 2010 4 / 45
Introduction & Sources of Inspiration Embedded Systems
Virtual Prototyping
=
An Executable Model Before the System is
Manufactured
Software
Modeling
Introduction & Sources of Inspiration Embedded Systems
Virtual Prototyping
Virtual Prototyping
=
An Executable Model Before the System is
Manufactured
Software
Virtual Prototyping
Modeling
Bouhadiba - Ph.D. Defense 42 September 15th 2010 4 / 45
Introduction & Sources of Inspiration Embedded Systems
Virtual Prototyping
=
An Executable Model Before the System is
Manufactured
Software
Virtual Prototyping
Executability
Modeling
Introduction & Sources of Inspiration Virtual Prototyping of Embedded Systems
Contents
1
Introduction & Sources of Inspiration
Virtual Prototyping of Embedded Systems
Modeling Hardware/Software with Synchronous Languages
Ptolemy
Specifying Components: Contracts
2
Overview of 42 & Examples
[GPCE07]
3
Hardware Simulation by Interpreting Contracts
[COORD09]
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 5 / 45Introduction & Sources of Inspiration Virtual Prototyping of Embedded Systems
SystemC/TLM for Systems-on-a-Chip
Hardware Architecture
A SoC (System-on-a-Chip)
while(true) x = 42; while (xneq0) y = read(addrM + x); write(addrM , x); ... write(addrD+0x0, addrM); write(addrD+0x1, 42); write(addrD+0x4, 0x01); ... ...Embedded Software
Introduction & Sources of Inspiration Virtual Prototyping of Embedded Systems
SystemC/TLM for Systems-on-a-Chip
CPU
provides
(Transaction-Level Modeling)
TLM
Virtual Prototype
Early Available
while(true) x = 42; while (xneq0) y = read(addrM + x); write(addrM , x); ... write(addrD+0x0, addrM); write(addrD+0x1, 42); write(addrD+0x4, 0x01); ... ...Embedded Software
Bouhadiba - Ph.D. Defense 42 September 15th 2010 6 / 45
Introduction & Sources of Inspiration Virtual Prototyping of Embedded Systems
SystemC/TLM for Systems-on-a-Chip
CPU
provides
(Transaction-Level Modeling)
TLM
Virtual Prototype
while(true) x = 42; while (xneq0) y = read(addrM + x); write(addrM , x); ... write(addrD+0x0, addrM); write(addrD+0x1, 42); write(addrD+0x4, 0x01); ... ...Embedded Software
Introduction & Sources of Inspiration Virtual Prototyping of Embedded Systems
SystemC/TLM for Systems-on-a-Chip
CPU
provides
(Transaction-Level Modeling)
TLM
Virtual Prototype
Early Available
while(true) x = 42; while (xneq0) y = read(addrM + x); write(addrM , x); ... write(addrD+0x0, addrM); write(addrD+0x1, 42); write(addrD+0x4, 0x01); ... ...Embedded Software
Bouhadiba - Ph.D. Defense 42 September 15th 2010 6 / 45
Virtual Prototyping of Sensor Networks
Several sensors communicating by radio
Network lifetime depends on energy consumption
Use of virtual prototyping to study non-functional aspects
(e.g., energy)
CPU, Sensor, Memory, Radio,
Battery
Introduction & Sources of Inspiration Modeling Hardware/Software with Synchronous Languages
Contents
1
Introduction & Sources of Inspiration
Virtual Prototyping of Embedded Systems
Modeling Hardware/Software with Synchronous Languages
Ptolemy
Specifying Components: Contracts
2
Overview of 42 & Examples
[GPCE07]
3
Hardware Simulation by Interpreting Contracts
[COORD09]
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 8 / 45Introduction & Sources of Inspiration Modeling Hardware/Software with Synchronous Languages
Modeling HW/SW with Synchronous Languages
is Embedded in the ATV
PFS (Proximity Flight Safety)
ATV (Automated Transfer Vehicule)
Models via a Translation into Synchronous Programs”
[EMSOFT07]
Introduction & Sources of Inspiration Modeling Hardware/Software with Synchronous Languages
Modeling HW/SW with Synchronous Languages
The original model of the PFS
is written in AADL
(Architecture Analysis and Design Language)
(Not Executbale)
is Embedded in the ATV
PFS (Proximity Flight Safety)
ATV (Automated Transfer Vehicule)
“E. Jahier, N. Halbwachs, P. Raymond, X. Nicollin, D. Lesens, Virtual Execution of AADL
Models via a Translation into Synchronous Programs”
[EMSOFT07]
Bouhadiba - Ph.D. Defense 42 September 15th 2010 9 / 45
Modeling HW/SW with Synchronous Languages
Automatic Translation
into Lustre
PFS description in Lustre
Simulation
Automatic Testing
The original model of the PFS
is written in AADL
(Architecture Analysis and Design Language)
(Not Executbale)
is Embedded in the ATV
PFS (Proximity Flight Safety)
ATV (Automated Transfer Vehicule)
Introduction & Sources of Inspiration Ptolemy
Contents
1
Introduction & Sources of Inspiration
Virtual Prototyping of Embedded Systems
Modeling Hardware/Software with Synchronous Languages
Ptolemy
Specifying Components: Contracts
2
Overview of 42 & Examples
[GPCE07]
3
Hardware Simulation by Interpreting Contracts
[COORD09]
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 10 / 45Ptolemy
ptolemy.eecs.berkeley.edu
MoCC : Model of Computation and Communication
composite actor
hierarchical abstraction actor port external port
Components are actors
The director implements a MoCC
Hierarchical framework
∃
a catalogue of predefined MoCCs:
Synchronous Reactive, Discrete Event, Continuous Time, etc.
Introduction & Sources of Inspiration Specifying Components: Contracts
Contents
1
Introduction & Sources of Inspiration
Virtual Prototyping of Embedded Systems
Modeling Hardware/Software with Synchronous Languages
Ptolemy
Specifying Components: Contracts
2
Overview of 42 & Examples
[GPCE07]
3
Hardware Simulation by Interpreting Contracts
[COORD09]
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 12 / 45Classification of Contracts in the CBSE Community
(Component-Based Software Engineering)
Syntactic contracts
Interface Description languages
(Java-IDL, WSDL, IDL, etc.)
Behavioral contracts
pre and post conditions, assertions, etc.
(Design by Contracts
TM
, Eiffel, iContracts, etc.)
Synchronization contracts
Sequence of method-calls, Component synchronization, etc.
(PROCOL, Interface automata, Session types, etc.)
Quality of service contracts
Resource consumption, Image quality, etc.
Introduction & Sources of Inspiration Specifying Components: Contracts
Contracts in the Hardware Community
and the Synchronous Languages
Don’t care conditions
Hardware optimization
Conditional dependencies in Signal
Cycle analysis in synchronous circuits
Assume/Guarantee reasoning
Modular verification (K. McMillan)
Executable specifications for Lustre (L. Morel)
b
o’
o
i
b
i
o
o’
A
G
b
i
o’
o
?
?
o depends on i when b=true
Input (ib)=(01) never occurs
Bouhadiba - Ph.D. Defense 42 September 15th 2010 14 / 45
Observation & Motivations of 42
In each context of Virtual Prototyping of embedded systems, there exists a
notion of components and MoCCs related issues
42 aims at providing:
A
language-independent
component-based framework for modeling
hardware/software systems.
Support for a clean definition of components, and help enforcing the
FAMAPASAP
(Forget As Much As Possible As Soon As Possible)
principle.
Support for integration of
existing code and models
in open virtual
prototyping environments.
Overview of 42 & Examples[GPCE07] Components & Assemblies
Contents
1
Introduction & Sources of Inspiration
2
Overview of 42 & Examples
[GPCE07]
Components & Assemblies
Explicit Specification of Components (Contracts)
3
Hardware Simulation by Interpreting Contracts
[COORD09]
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 16 / 45
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Basic Components
0
1
0
1
0
1
0
1
0
1
oc1
oc2
Output Control Ports
oc1:
{
a, b, c
}
oc2:
{
T, F
}
Data Ports
Input
Input Control Ports
ic2
ic1
od3
od2
od1
Output
Data Ports
id3
id2
id1
M: internal memory
f o r
i c 1 do :
{
a := i d 1 ;
b := i d 2 ;
od1 := f ( a , b ) ;
o c 1 := ok ;
M := !M;
}
. . .
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Basic Components
step
atomic
A
tomic
0
1
0
1
0
1
0
1
0
1
oc1
oc2
Output Control Ports
oc1:
{
a, b, c
}
oc2:
{
T, F
}
Data Ports
Input
Input Control Ports
ic2
ic1
od3
od2
od1
Output
Data Ports
id3
id2
id1
M: internal memory
. . .
f o r
i c 1 do :
{
a := i d 1 ;
b := i d 2 ;
od1 := f ( a , b ) ;
o c 1 := ok ;
M := !M;
}
. . .
Bouhadiba - Ph.D. Defense 42 September 15th 2010 17 / 45
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 18 / 45
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 18 / 45
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 18 / 45
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 18 / 45
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Overview of 42 & Examples[GPCE07] Components & Assemblies
42 in a Nutshell: Assembling Components
C o n t r o l l e r
i s
{
v a r
M :
b o o l
;
f o r
OP
Gdo
:
{
/
∗
d e f i n e s
opg .
dw
,
d r ,
reqw
, . . . :
f i f o
( 1 , i n t ) ;
M :=
random
( ) ;
i f
(M)
{
PROD
.
op
;
r eqw
.
p u t
;
reqw
.
g e t
;
FIFO
.
op
;
gw
.
p u t
;
gw
.
g e t
;
a :=
FIFO
.
r e p o r t
;
/
∗
r e a d s o c .
i f
( a==ok )
{
/
∗
o u t p u t
c o n t r o l
PROD
.
op
;
dw
.
p u t
;
dw
.
g e t
;
FIFO
.
op
;
/
∗
a c t i v a t e s FIFO .
. . .
}
. . .
}
e l s e
{
CONS
.
op
;
r e q r
.
p u t
;
r e q r
.
g e t
;
FIFO
.
op
;
g r
.
p u t
;
g r
.
g e t
;
a :=
FIFO
.
r e p o r t
;
. . .
}
}
}
For each
OP
Gthe controller:
Activates PROD, CONS, FIFO through op
Reads their output control ports (report)
Manages a temporary memory (reqr, dr,...)
Sets global output values
0000000
0000000
1111111
1111111
controller
g
wreq
rreq
wd
wd
rg
r0101
01
0101
01
01
01
01
0101 01
01
0101
01
PROD
FIFO
CONS
op
op
Gop
op
report
report
report
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 18 / 45
Summary of 42 Basics
Summary of 42
Hierarchical
model =
⇒
modeling
heterogeneity
in the same spirit as Ptolemy
Controllers are expressed as
programs
identification of the basic primitives for describing MoCCs
Separation of
control/data
to enforce the FAMAPASAP
more details later
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
Control Contracts for 42 Components
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Data dependencies (
Required
,
Provided
)
Control information
Conditional activations.
Conditional data dependencies.
Bouhadiba - Ph.D. Defense 42 September 15th 2010 20 / 45
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
Control Contracts for 42 Components
ic1
ic2
ic1
ic2
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Control information
Conditional activations.
Conditional data dependencies.
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
Control Contracts for 42 Components
{
id1
}
{}
{
od2
}
{
id1
}
{
od2
}
{
id2
}
{
od1; od3=L
}
ic1
ic2
ic1
ic2
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Data dependencies (
Required
,
Provided
)
Control information
Conditional activations.
Conditional data dependencies.
Bouhadiba - Ph.D. Defense 42 September 15th 2010 20 / 45
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
Control Contracts for 42 Components
/α
=
oc
2
/α
=
oc
2
/β
=
oc
1
{
id1
}
{}
{
od2
}
{
id1
}
{
od2
}
{
id2
}
{
od1; od3=L
}
ic1
ic2
ic1
ic2
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Data dependencies (
Required
,
Provided
)
Control information
Conditional data dependencies.
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
Control Contracts for 42 Components
[
α
=
T
]
[
α
=
F
]
/α
=
oc
2
/α
=
oc
2
/β
=
oc
1
{
id1
}
{}
{
od2
}
{
id1
}
{
od2
}
{
id2
}
{
od1; od3=L
}
ic1
ic2
ic1
ic2
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Data dependencies (
Required
,
Provided
)
Control information
Conditional activations.
Conditional data dependencies.
Bouhadiba - Ph.D. Defense 42 September 15th 2010 20 / 45
Control Contracts for 42 Components
{
if (
β
=a) then od2;
}
[
α
=
T
]
[
α
=
F
]
/α
=
oc
2
/α
=
oc
2
/β
=
oc
1
{
id1
}
{}
{
od2
}
{
id1
}
{
od2
}
{
id2
}
{
od1; od3=L
}
ic1
ic2
ic1
ic2
0
1
0
1
0
0
1
1
0
1 0
1
id1
id2
id3
od1
od2
od3
step
atomic
internal memory
oc2
oc1
Output Control Ports
ic2
ic1
Input Control Ports
Output
Data
P
ort
s
Input
Data
P
orts
c1
c2
c0
oc2:
{
T, F
}
oc1:
{
a, b, c
}
Allowed activation sequences
Data dependencies (
Required
,
Provided
)
Control information
Conditional activations.
Conditional data dependencies.
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Testing controllers/components consistency
Contract Interpretation
Testing component/contract consistency
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 21 / 45
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Contract Interpretation
Testing component/contract consistency
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Testing controllers/components consistency
Contract Interpretation
Testing component/contract consistency
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 21 / 45
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Testing controllers/components consistency
Contract Interpretation
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Overview of 42 & Examples[GPCE07] Explicit Specification of Components (Contracts)
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Testing controllers/components consistency
Contract Interpretation
Testing component/contract consistency
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Bouhadiba - Ph.D. Defense 42 September 15th 2010 21 / 45
What are 42 Contracts used for?
42 contracts (+ the Architecture Description Language)
Testing controllers/components consistency
Contract Interpretation
Testing component/contract consistency
?
?
0000000
1111111
controller
00
00
11
11
00
00
11
11
00
00
11
11
0101
01
01
01
01
0
0
1
1
0
0
1
10
0
1
1
0
0
1
1
PROD
op
report
FIFO
op
report
CONS
op
report
Hardware Simulation by Interpreting Contracts[COORD09]
Contents
1
Introduction & Sources of Inspiration
2
Overview of 42 & Examples
[GPCE07]
3
Hardware Simulation by Interpreting Contracts
[COORD09]
Contract Interpretation
Contract Interpretation for Hardware Simulation
Executing Embedded Software on Hardware Models
4
Using 42 Together with Existing Approaches
[EMSOFT09]
5
Some Related Work
6
Summary
Bouhadiba - Ph.D. Defense 42 September 15th 2010 22 / 45
Contract Interpretation: Principle
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
[α
=
n
]
{}
op
/α
=
end
{}
Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation
Contract Interpretation: Principle
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
The controller maintains:
The current state of each contract
The set of available data
The values of the variables(α)
[α
=
n
]
{}
op
/α
=
end
{}
Bouhadiba - Ph.D. Defense 42 September 15th 2010 23 / 45
Contract Interpretation: Principle
available=
{}
available=
{}
A.op
a2
available=
{}
α
=
y
b1
a2
A.op
B.op
b2
a1
α
=
⊥
α
=
n
b1
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
For each global activation :
Depending on the available data it selects a
component and activates it
The set of available data is updated
The output controls are given
non-deterministic values
[α
=
n
]
{}
op
/α
=
end
{}
Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation
Contract Interpretation: Principle
available=
{
a
}
A.op
a3 b1
A.op
B.op
b2
available=
{
a
}
a3
B.op
a1 b3
available=
{
b
}
a1 b3
available=
{
a
}
A.op
B.op
a3 b3
available=
{
a
,
b
}
A.op
α
=
⊥
α
=
⊥
α
=
⊥
α
=
⊥
α
=
y
available=
{}
available=
{}
A.op
a2
available=
{}
α
=
y
b1
a2
A.op
B.op
b2
a1
α
=
⊥
α
=
n
b1
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
[α
=
n
]
{}
op
/α
=
end
{}
Bouhadiba - Ph.D. Defense 42 September 15th 2010 23 / 45
Contract Interpretation: Principle
Example execution path
available=
{
a
}
A.op
a3 b1
A.op
B.op
b2
available=
{
a
}
a3
B.op
a1 b3
available=
{
b
}
a1 b3
available=
{
a
}
A.op
B.op
a3 b3
available=
{
a
,
b
}
A.op
α
=
⊥
α
=
y
available=
{}
available=
{}
A.op
a2
available=
{}
α
=
y
b1
a2
A.op
B.op
b2
a1
α
=
⊥
α
=
n
b1
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
[α
=
n
]
{}
op
/α
=
end
{}
Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation
Contract Interpretation: Principle
A.op
Example execution path
available=
{
a
}
A.op
a3 b1
A.op
B.op
b2
available=
{
a
}
a3
B.op
a1 b3
available=
{
b
}
a1 b3
available=
{
a
}
A.op
B.op
a3 b3
available=
{
a
,
b
}
A.op
α
=
⊥
α
=
⊥
α
=
⊥
α
=
⊥
α
=
y
available=
{}
available=
{}
A.op
a2
available=
{}
α
=
y
b1
a2
A.op
B.op
b2
a1
α
=
⊥
α
=
n
b1
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
[α
=
n
]
{}
op
/α
=
end
{}
Bouhadiba - Ph.D. Defense 42 September 15th 2010 23 / 45
Contract Interpretation: Principle
requires b
X
A.op
Example execution path
available=
{
a
}
A.op
a3 b1
A.op
B.op
b2
available=
{
a
}
a3
B.op
a1 b3
available=
{
b
}
a1 b3
available=
{
a
}
A.op
B.op
a3 b3
available=
{
a
,
b
}
A.op
α
=
⊥
α
=
y
available=
{}
available=
{}
A.op
a2
available=
{}
α
=
y
b1
a2
A.op
B.op
b2
a1
α
=
⊥
α
=
n
b1
α
=
⊥
available=
b1
{}
a1
a2
a
b
op
op
end
A
op
end
B
ctrl Async
a3
a1
Contract A
b2
b3
b1
{}
op
{}
{}
op
{
b
}
{
a
}
op
{}
Contract B
{
b
}
op
{}
[
α
=
y
]
{}
op
{
a
}
{}
op
/α
=
end
{}
[α
=
n
]
{}
op
/α
=
end
{}
Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Bouhadiba - Ph.D. Defense 42 September 15th 2010 24 / 45
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Bouhadiba - Ph.D. Defense 42 September 15th 2010 24 / 45
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Bouhadiba - Ph.D. Defense 42 September 15th 2010 24 / 45
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }b
a
c
d
Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }ok
b
a
c
d
Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Bouhadiba - Ph.D. Defense 42 September 15th 2010 24 / 45
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }ok
ok
b
a
c
d
Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }ok
ok
b
a
c
d
Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)bug
X
(Synchronization)
// wait interrupt() ;
Bouhadiba - Ph.D. Defense 42 September 15th 2010 24 / 45
Modeling Hardware with 42: Case Study
Embedded Software
#d e f i n e w i d t h 240 #d e f i n e h e i g h t 240 #d e f i n e g r e e n 0x0000AABB . . . i n t main ( ) { w h i l e ( 1 ) { //∗w r i t i n g t h e g r e e n i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( g r e e n ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e b l u e i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( b l u e ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; //∗w r i t i n g t h e r e d i m a g e∗/ f o r ( i n t x =0; x<w i d t h ∗ h e i g h t ) w r i t e m e m( r e d ) ; w r i t e l c d( 0 x01 , 0 x1 ) ; w a i t i n t e r r u p t( ) ; } }ok
ok
b
a
c
d
Interrupt
MEM
CPUstatus
data
address
r/w
BUS
address
r/w
status
data
data
address
r/w
LCDstatus
(display)X
bug
(Data)
24bug
X
(Synchronization)
// wait interrupt() ;
Hardware Simulation by Interpreting Contracts[COORD09] Contract Interpretation for Hardware Simulation
Modeling Hardware with 42: The 42 Model
0
0
1
1
0
1
0
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
1
0
0
1
1
00
11
00
00
11
11
0
0
1
1
0
1
00
00
11
11
0
0
1
1
00
00
11
11
resp
LTacd
Lop
report
report
op
BUS
intr
op
resp
Cop
acd
Ctarget
report
0resp
Macd
Mop
resp
Lacd
LTCPU
LCD
MEM
Interpreter
Contract
Bouhadiba - Ph.D. Defense 42 September 15th 2010 25 / 45
Modeling Hardware with 42: The contracts (CPU)
c4
c4’
c0
c3
c1
c2
c3’
c1’
c2’
{
intr=t
}
op
{}
{
intr=t
}
op
{}
{
intr=t
}
op
{}
{
intr=t
}
op
{}
{
intr=t
}
op
{}
{}
op/α=report
{}
[α=MT]
{}
op
{
acdC
; target=M
}
[α=MT]
{}
op
{
acdC
; target=M
}
{
intr=t
}
op
{}
{
respC
}
op/α=report; report’=IT
{}
{}
op/α=report
{}
{
intr=t
}
op
{}
{
respC
}
op/α=report; report’=IT
{}
{
re