Combinatorial Circuits
Combinatorial Circuits
Combinatorial Circuits
1. Combinatorial circuits:
Boolean Algebra/Functions/Expressions
2. Combinatorial Circuits in Chisel
6:0
Control
Unit
PCSrc
ResultSrc
MemWrite
3. Number representations
ALUControl2:
4. Arithmetic Circuits:
op
14:12 0
funct3 ALUSrc
30
funct75 ImmSrc1:0
CLK CLK
CLK
19:15 WE3 SrcA Zero WE
0 PCNext PC Instr A1 RD1 0
A RD ReadData
ALU
1 ALUResult
A RD 1
PCTarget
ImmExt
31:7
Extend
PCPlus4
+
Result
4
1. Combinatorial circuits:
Boolean Algebra/Functions/Expressions
2. Combinatorial Circuits in Chisel
6:0
Control
Unit
PCSrc
ResultSrc
MemWrite
3. Number representations
ALUControl2:
4. Arithmetic Circuits:
op
14:12 0
funct3 ALUSrc
30
funct75 ImmSrc1:0
CLK CLK
CLK
19:15 WE3 SrcA Zero WE
0 PCNext PC Instr A1 RD1 0
A RD ReadData
ALU
1 ALUResult
A RD 1
PCTarget
ImmExt
31:7
Extend
PCPlus4
+
Result
4
Boolean expressions
ib e
e s cr
d
can be
Boolean functions converted
im into each
p le
me other
mo nt
Boolean algebra d el
Rules for the manipulation
of Boolean functions Circuits
Boolean calculus 4
Contruction of Boolean expressions
from truth tables
1. Consider all rows for which the
function is 1.
x1 x2 x3 s
0 0 0 0
2. Construct the minterm for the 0 0 1 0
valuation of x1, x2 und x3 in the 0 1 0 0
row as follows: 0 1 1 1
– if xi is 1 Þ xi 1 0 0 0
– if xi is 0 Þ xi’ 1 0 1 1
1 1 0 1
3. Combine all minterms by a 1 1 1 1
disjunction
Approach:
• Find implementations for simple Boolean functions
• Compose these to implement more complex functions
à leads to hierarchical models
source source
5 V = logical 1
p-type transistor
[0 V, 5 V]
n-type transistor
0 V = logical 0
5 V = logical 1
p-type transistor
disconnects
5 V = logical 1 0 V = logical 0
transmits
n-type transistor
0 V = logical 0
5 V = logical 1
p-type transistor
transmits
0 V = logical 0 5 V = logical 1
disconnects
n-type transistor
0 V = logical 0
Output is 0 iff
there is a transmitting path from 0 to the output,
i.e., iff both n-type transistors transmit,
a = b = 1,
then NAND(a, b) = 0
Output is 1 iff
there is a transmitting path from 1 to the output,
i.e., iff one of the p-type transistors transmits,
a = 0 or b = 0,
then NAND(a, b) = 1
Questions:
1. How to model circuits
mathematically? nt ax
Sy
Intuitively:
A circuit is a directed graph with some
additional properties.
a= 1 0 0 0 0 0 0 0
g1 g2 g3
0 0 0
g4 g5 g6
0 0 0
g7 g8
1 0
Definition:
The function computed by circuit C is
fC := (y(y1), ..., y(ym))
Circuits System Architecture, Jan Reineke 27
Symbolic simulation
• Symbolic simulation does not simulate a circuit for fixed
Boolean inputs. Rather it simulates the circuit on
Boolean variables.
x1 x2 x3 x4 x5 x6 x7 x8
x2⊗ x3 x4 ∧ x5 x6 ∨ x7
of circuits?
y1 y2
Circuits 30
Cost of circuits
Definition (Cost):
The hardware cost C(C) of a circuit C is its
number of gates|I| = |V \ ({0, 1} ∪ (x1, ..., xn))|.
Remark:
• Circuits are defined based on a cell library BIB
à Cost depends on the choice of the library.
• If not stated otherwise, in the following we will use the
standard library STD:
STD := {NOT, AND, OR, EXOR, NAND, NOR}
Circuits 31
Speed of a circuit
Definition (Depth):
The depth(C) of a circuit C is the
maximal number of gates on a path from an
arbitrary input xi to an arbitrary output yj of C.
Remark:
• Depth is only a reasonable indicators of a circuit’s
speed if the switching speed of each gate in the library
is approximately the same.
x1 x2 x3 x4 x5 x6 x7 x8
Cost: 8
Depth: 3
y1 y2
In hierarchical circuits,
subcircuits are represented by symbols.
x1 EXOR
x2
EXOR
x3
x1
x2 EXOR
EXOR
x3
Circuits 35
Circuits vs Boolean functions
Theorem:
Let f Î Bn,m.
Then there is a circuit that computes f.
Reminder:
Lemma:
For every Boolean function f Î Bn,1 there
is a Boolean expression that describes f.
Circuits System Architecture, Jan Reineke 37
Circuits vs Boolean expressions
Lemma:
For every Boolean expression e Î BE(Xn)
there is a circuit C = (Xn, G, typ, IN, Ym),
such that y(e) = fC.
Proof:
By induction over the structure of the Boolean expression.
Theorem:
Let f Î Bn,m.
Then there is a circuit that computes f.
Proof:
Case 1: f Î Bn= Bn,1. $e Î BE(Xn), that computes f.
The theorem then directly follows from the previous lemma.
Case 2: f Î Bn,m, m ≥ 2.
Interpret f : Bn,m = Bn ® Bm as a sequence of functions (f1, ..., fm) with fi : Bn® B.
x1 x2 ... xn
... ...
C1 C2 .... Cm
f1 f2 ... fm
Wanted:
Circuit implementation for exor16.
Implementation of exor4:
x1 x2 x3 x4
Depth: 3
Cost: 3
Can we do better?
(((𝑥1 ⊗ 𝑥2) ⊗ 𝑥3) ⊗ 𝑥4) Idea: Make use of associativity:
𝑥1 ⊗ 𝑥2 ⊗ 𝑥3 ⊗ 𝑥4 = ((𝑥1 ⊗ 𝑥2) ⊗ (𝑥3 ⊗ 𝑥4))
Depth: 2
Cost: 3
Depth: 3
Cost: 7
Depth: 4
Cost: 15
Circuits
How do cost and depth depend on n for exorn? 46
Recursive construction of
generalized EXOR
Implementation of exor2n:
x1 … xn xn+1 … x2n
… … depth(exor2n) = depth(exorn)+1
Exorn Exorn depth(exor1) = 0
→ depth(exorn) = log2 n
C(exor2n) = 2·C(exorn)+1
C(exor1) = 0
→ C(exorn) = n-1
Circuits 47
Efficient implementation of
arbitrary associative operations
Lemma:
The function x1 ◦ x2 … ◦ xn can be implemented
using ◦ gates with 2 inputs in a circuit of
depth ⌈log2 n⌉.
Circuits 48
Two-level normal form of EXOR16
Question: How large is the smallest Boolean
polynomial of exor16?
Answer: 215 monomials with 16 literals each!
Proof sketch:
(Cost:) A function f Î Bn has at most 2n minterms.
Every minterm can be implemented using 2n-1 gates.
The disjunction of all minterms can be implemented using
at most 2n-1 gates.