Logic and Digital Circuits: from Practice to Theory

53
Logic and Digital Circuits: from Practice to Theory Gérard Berry http://www-sop.inria.fr/members/Gerard.Ber ry/ INR IA So ph ia -

description

Logic and Digital Circuits: from Practice to Theory. Gérard Berry http://www-sop.inria.fr/members/Gerard.Berry/. INRIA Sophia-Antipolis Collège de France, 2007-2008 and 2009-2010 Logic to the Rescue , Nancy, July 22 nd , 2011. Digital Circuits. PC microprocessors - PowerPoint PPT Presentation

Transcript of Logic and Digital Circuits: from Practice to Theory

Page 1: Logic and Digital Circuits: from  Practice  to  Theory

Logic and Digital Circuits: from Practice to Theory

Gérard Berryhttp://www-sop.inria.fr/members/Gerard.Berry/

INRIA Sophia-Antipolis

Collège

de France, 2007-

2008 and

2009-

2010

Logic to

the Rescue, Nancy,

July

22nd, 2011

Page 2: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 2

Digital Circuits

SoC = Systems on Chip

PC microprocessorstelephones, DVD, TV, GPS,...

Sorrce Intel

Page 3: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 3

Combinational Gates and Circuits

s a xor b xor c

s (a and b)

or (b and c) or (c and a)

ab

c

s

r

and or xor not (a and b) (not a) and b

ab

mux(c,a,b) =(c and a) or ((not c) and b) mux

cab

full adder

Page 4: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 4

Combinational propagation

GOTRY PASS

REQ OK

GET_TOKEN PASS_TOKEN

GO1

1

0

Since the network is acyclic, outputs stabilizein bounded time if inputs are kept constant

Stabilization time is determined by the critical path

Page 5: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 5

The Ripple-Carry Adder

++

a0b0

s0

++1

a

1b

1s

c1

++2a

2b2s

2c

3c

c = 00

For n bitstime n

Page 6: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 6

The von Neumann Logarithmic Adder

n

n

n+1

n+1a[n..2n-1]

b[n..2n-1]

a[0..n-1]

b[0..n-1]

s[0..n-1]

s’[0..n-1]n

n

n+1

n+1 0..n-1

0..n-1

s[n..2n]

n

01

n

s’[n..2n]01

Page 7: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 7

The von Neumann Logarithmic Adder

For n bitstime log(n)

Page 8: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 8

The Register

ra

a a0, a1, a2, ... r 0, a0, a1, a2, ... ra

a a0, a1, a2, ... r 1, a0, a1, a2, ... ra

a

rreg(a)

ck ck

Page 9: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 9

Sequential sampling

tick ! tick !clock

GOTRY PASS

REQ OK

GET_TOKEN PASS_TOKEN

GO1

1

0

Page 10: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 10

Sequential sampling

tick ! tick !clock

GOTRY PASS

REQ OK

GET_TOKEN PASS_TOKEN

GO1

1

0

0

0

0

Page 11: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 11

The Serial Adder

ab s ...00110

...01101...10011

6

13

19

Serial Adder

r

See the marvelous use of 2-adic numbers in“On Circuits and Numbers” by Jean Vuillemin

Page 12: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 12

Boolean Equation View

GOTRY PASS

REQ OK

GET_TOKEN PASS_TOKEN

GO1

1

0

OK REQ and GOPASS not REQ and GOGO TRY or GET_TOKENPASS_TOKEN reg(GET_TOKEN)

Waiting for the critical time solving the equations

Page 13: Logic and Digital Circuits: from  Practice  to  Theory

13G. Berry, Nancy 22/07/2011

Micro-Architecture breakdown OK?performance OK?

software modelingmodel-checkingtheorem proving

Architecture functionality OK?performance OK?marketing OK?

know-howreviewsExcel / C prototypes

circuits equivalentto source?

formal verification

RTL Logic Designrandom-directed testformal verification

functionality OK?speed / area OK?power OK?

DFT (test) test coverage~100% ?

ATPGSAT

Place&Route connections?electrically OK?timing OK?

Design RulesChecking (DRC)

Masks$ 1,000,000

Chips packaging, testingreally works?

ESTEREL

Page 14: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 14

Combinational Circuit Proof Network

GOTRY PASS

REQ OK

GET_TOKEN PASS_TOKEN

GO1

1

0

Each operator is a proof componentCircuit graph of all proofs of outputs from inputs

Page 15: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 15

Constructive Boolean Propagation Logic

I e 0

I e and e’ 0

I e’ 0

I e and e’ 0

I e 1

I e and e’ 1

I e’ 1

I e 1

I e or e’ 1

I e’ 1

I e or e’ 1

I e 0

I e or e’ 0

I e’ 0

I e 0

I not e 1

I e 1

I not e 0

• Input vector I inputs → {0,1}• Formulae: I e b

I I I(I)

X e I e b

I X b

I e or not e 1 ssi I e 0 or I e 1

Page 16: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 16

The ABRO Synchronization Example

Memory WriteR : requestA : addressB : dataO : write

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Emit O as soon A and B have arrivedReset this behavior each R

Page 17: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 17

The ABRO Synchronization Example

Emit O as soon A and B have arrivedReset this behavior each R

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Page 18: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 18

The ABRO Synchronization Example

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Emit O as soon A and B have arrivedReset this behavior each R

Page 19: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 19

The ABRO Synchronization Example

Emit O as soon A and B have arrivedReset this behavior each R

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Page 20: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 20

The ABRO Synchronization Example

Emit O as soon A and B have arrivedReset this behavior each R

Priority problems:what if A, B, R together?

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Page 21: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 21

Esterel Linear Specification

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; haltwhen R;end loop

A / B /

A /B /

A B /

Page 22: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 22

Esterel Linear Specification

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; emit O ; halt when R;end loop

A / B /

A / OB / O

A B / O

Page 23: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 23

Esterel Linear Specification

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; emit O ; halt when Rend loop

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

Page 24: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 24

Esterel Linear Specification

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; emit O ; halt when R;end loop

loop abort { await A || await B }; emit O ; halt when Rend loop

A / B /

A / OB / O

A B / O

R /

R /

R /

R /

copies = residualsEsterel = sharing of residuals

Page 25: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 25

Esterel SyncCharts Linear Specification

A / B /

R /

/ O

Hierarchical synchronousconcurrent automata

(Synchronous Statecharts)

loop abort { await A || await B }; emit O ; halt when Rend loop

Page 26: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 26

Linear vs. Exponential

flat automaton Hierarchical automatonlinear

exponential explosion!

Page 27: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 27

Logical (SoS) Semantics

pE

E’ 0 p’ qE

F’ l q’

p ; q E’ U F’ l q’E

pE

E’ k p’ k 0

p ; qE’ k

p’ ; qE

Page 28: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 28

Logical (SoS) Semantics

pE

E’ k p’ qE

F’ l q’

p | qE

E’ U F’ max(k,l) p’ | q’

await sE

E 0 0

s E

await sE

E 1 await s

s E

Page 29: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 29

The ABRO Circuit (Proof Network)

loop abort { await A || await B }; emit O ; halt when Rend loop

suppressed by optimization

Page 30: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 30

Optimizing Register Allocation

e1

e2

e3

e0

a

b

b

ab

b

• 1-hot encoding state number explostion

e0 10e1 11e2 01e3 00

e0 01e1 10e2 11e3 11

good bad

n! possibilities, no heuristics !

• log(n) bits for n states can blow up the logic

Page 31: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 31

R

Ocombinational logic

registers

I

The key: balancing logic and registersEsterel / SyncCharts structural encoding

Page 32: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 32

The Secret: Linear Specification!

One register per explicit wait good logic / register balance

The better the program is written,the more efficient the circuit is!

loop abort { await A || await B }; emit O ; halt when Rend loop

Page 33: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 33

Replacing Register by Logic

Question: can we replace a given register by logic?Registers r1, r2,..., rn, reachability predicate (r1, r2,..., rn)

1. Question for r1 – looks difficult:

f. b1, b2,..., bn. (b1, b2,..., bn) b1 f(b2,..., bn)

2. Logical rephrasing – algorithmically much easier:

(0, b2,..., bn) (1, b2,..., bn) 0

Very efficient BDD-algorithms (Madre-Coudert-Touati)Yields results always better than manual designs

3. Iteration + heuristics

Page 34: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 34

Cyclic Circuit from Resource Sharing

F

G

O = if C then F(G(I)) else G(F(I))

C

C

I O

C10

10

10

Cyclic combinational circuits can be exponentiallysmaller than acyclic circuits for the same function

Page 35: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 35

Symmetric Round-Robin Protocol

A

B

okreq

reqok

only one ok in req orderafter the register set to1

Page 36: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 36

Symmetric Round-Robin Protocol

A

B

okreq

reqok

The 1 registerchanges every cycle

Page 37: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 37

Symmetric Round-Robin Protocol (4)

okreq

req

ok

req

ok

reqok

Page 38: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 38

Symmetric Round-Robin Protocol

Beware of the combinational cycle !

okreq

reqok

Page 39: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 39

Symmetric Round-Robin Protocol

The cycle is sound ifat least a register is 1,

since it is cut at an or gate

okreq

reqok

1

Page 40: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 40

Symmetric Round-Robin Protocol

okreq

reqok

The cycle is unsound ifall registers are 0

Page 41: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 41

The Three Kinds of Cyclic Circuits

2. Electrically and logically unsoundX XX not X

combinational part of the cyclic round-robinif all register outputs are 0

1. Electrically and logically sound (possibly under input conditions) ex: combinational part of the cyclic round-robin

if at least one register output is 1

Page 42: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 42

The Three Kinds of Cyclic Circuits

3. Strange circuitsHamlet : ToBe ToBe or not ToBe

ToBe

• Electrically stabilizes to 1 for some gate and wire delays, but not for all delays !

• Logically computes 1 in classical logic, but computes nothing in constructive logic

Page 43: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 43

Cyclic Circuits Analysis

When does a circuit stabilize for all delays?Which logical view is correct?

How to relate logic to electricity?

Theorem: with the right electrical delay model, electrical stabilization for all delays logical constructivity definedness w.r.t. ternary simulation

Page 44: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 44

Ternary simulation

1. Interpret equations over 0, 1, with 0 and 1 (Scott’s information ordering)

2. Monotonically extend basic Boolean functions

0 1 10 0 11 1 1 1

0 1 10 0 11 1 1 1

0 11 0

undefinable inC, Java, ML !

3. Compute the least fixpoint of the equation system

Page 45: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 45

Theorem: constructive propagation ternary simulation

• Solves good cyclic examples• Correctly rejects Hamlet

no constructive propagationleast fixpoint is ToBe

Questions: • Do they characterize electrical behavior?• How to model continuous-time signals?• What is the electrical meaning of ?

uninitialized? unstable? metastable?non-deterministic? etc.

Page 46: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy

• Continous time in R+, discrete values in B {0,1}• Signal s: R+→B satisfying

– right-continuity: s(t) b >0. s[t,t+] b–non-Zenoness: finite number of changes for any [t,t’]

22/07/2011 46

Modeling Continuous Signals

i oDEL

DEL(i,o) (R+→B) (R+→B)

non-deterministic relation

Page 47: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 47

UI : Upbounded inertial delay model(Brzozowski-Seger 1995)

Inertiality: o cannot change without being unstable if o changes from not b to b at time t, then there exists > 0 s.t. i [t, t] b

Propagation: output cannot be unstable for time D without changing if i[t1,t2) b for t2 > t1+, then t[t1,t2] s.t. o[t,t2] b

i o

Page 48: Logic and Digital Circuits: from  Practice  to  Theory

48G. Berry, Nancy 22/07/2011

0 1 2 3 4 5 6 7

i

o

o

Page 49: Logic and Digital Circuits: from  Practice  to  Theory

49G. Berry, Nancy 22/07/2011

i

1

All wires UI-stabilize to 1, but constructive propagationand ternary simulation yield for them

Theorem (Shiple-Berry): if all wires and gates haveUI-delays, then constructiveness is equivalent toUI-stabilization

... but UI is non-compositional: delay→delay delay

2

Page 50: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 50

UN : Upbounded delay model(Mendler 2008)

Inertiality: outputs cannot change without unstable if o changes from not b to b at time t, then there exists > 0 s.t. i [t, t] b

i o

Propagation: output cannot be unstable for time D without changing if i[t1,t2) b for t2 > t1+, then t[t1,t2] s.t. o[t,t2] b

Page 51: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 51

The UN-logic

Page 52: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy 22/07/2011 52

UN is the Right Model (Mendler)

Theorem: for all circuits such that each combinational loop is cut by at least one UN-delay,

constructiveness UN-stabilisation

1. Deal with Horn-like clauses2. Define a simple entailment relation |3. Show equivalence between | and | for clauses4. Deduce that | performs electrical simulation5. Reduce to ternary simulation in the same logic

Constructiveness stabilization proved within the logic

Page 53: Logic and Digital Circuits: from  Practice  to  Theory

G. Berry, Nancy

• Logic is fundamental for circuit design– design with Boolean logic – model-check for verification– use Boolean algorithms for optimization

22/07/2011 53

Conclusion

• Logic is fundamental to understand the relation between logic design and implementation– electricity is fundamentally constructive– UN-logic unifies continous and Boolean model

• Yet to be studied– non-Boolean signals– metastability modeling– application to SW real / discrete time fields (Matlab?)