Embedded Systems Design: A Unified Hardware/Software Introduction
Embedded Systems Design: A Unified Hardware/Software Introduction
Outline
Introduction Combinational logic Sequential logic Custom single-purpose processor design RT-level custom single-purpose processor design
Introduction
Processor
Digital circuit that performs a computation tasks Controller and datapath CCD General-purpose: variety of computation tasks Single-purpose: one particular lens computation task Custom single-purpose: non-standard task
Digital camera chip
A2D
CCD preprocessor
Pixel coprocessor
D2A
JPEG codec
Microcontroller
Multiplier/Accum
DMA controller
Display ctrl
Memory controller
UART
LCD ctrl
IC package
IC
source
nMOS
pMOS
F = (xy)'
F = (x+y)'
y
Basic gates
Inverter, NAND, NOR
x 0 1
F 0 1
x y F
F=x Driver
F=xy AND
x 0 0 1 1
y 0 1 0 1
F 0 0 0 1
x y
F=x+y OR
x 0 0 1 1
y 0 1 0 1
F 0 1 1 1
x y F
F=xy XOR
x 0 0 1 1
y 0 1 0 1
F 0 1 1 0
x 0 1
F 1 0
x y F
F = x Inverter
F = (x y) NAND
x 0 0 1 1
y 0 1 0 1
F 1 1 1 0
x y
F = (x+y) NOR
x 0 0 1 1
y 0 1 0 1
F 1 0 0 0
x y F
F=x y XNOR
x 0 0 1 1
y 0 1 0 1
F 1 0 0 1
C) Output equations
y = a'bc + ab'c' + ab'c + abc' + abc z = a'b'c + a'bc' + ab'c + abc' + abc
E) Logic Gates a b c
Combinational components
I(m-1) I1 I0 n S0 n-bit, m x 1 Multiplexor S(log m) n I(log n -1) I0 log n x n Decoder O(n-1) O1 O0 A n n-bit Adder n carry sum less equal greater B n A n B n A n B
n-bit Comparator
O = A op B op determined by S.
With enable input e With carry-in input Ci all Os are 0 if e=0 sum = A + B + Ci
Sequential components
I n load clear n-bit Register n Q Q= 0 if clear=1, I if load=1 and clock=1, Q(previous) otherwise. Q = lsb - Content shifted - I stored in msb shift I n-bit Shift register n-bit Counter n Q Q= 0 if clear=1, Q(prev)+1 if count=1 and clock=1.
I1 0 0 0 1 1 1 1 0
x 0 0 0 1
0
a=1 1 a=0 x=0
3
a=1 2 x=0 a=0
a=1
I1 Q1Q0 00 a 0
1
01
11
10
0
0
0
1
1
0
1
1
I0 Q1Q0 00
a
01 1 0
11 1 0
10 0 1 I0 = Q0a + Q0a
I1
0 1
x Q1Q0 00 a 0 1 0 0
I0 01 0 0 11 1 1 10 0 0 x = Q1Q0 Q1 Q0
11
functiona l units
13
Branch statement
if (c1) c1 stmts else if c2 c2 stmts else other stmts next statement
C: c1 c1 stmts !c1*c2 c2 stmts !c1*!c2 others
C:
loop-bodystatements
J: next statement
next statement
14
1: 1 2: !(!go_i)
go_i
x_i GCD
y_i
2-J: 3:
!go_i
d_o
x = x_i
4:
0: int x, y; 1: while (1) { 2: while (!go_i); 3: x = x_i; 4: y = y_i; 5: while (x != y) { 6: if (x < y) 7: y = y - x; else 8: x = x - y; } 9: d_o = x; (b) desired functionality }
5:
8: x = x - y
15
Datapath
x_ld
4: y = y_i !(x!=y) x!=y 6: x<y y = y -x 6-J: !(x<y) != 5: x!=y x_neq_y x_lt_y y_ld
0: x
0: y
5:
< 6: x<y
subtractor 8: x-y
subtractor 7: y-x
8: x = x - y
9: d d_o
d_ld
16
1:
1 2: !go_i 2-J: 3: x = x_i !(!go_i)
Controller
0000 0001 1: 1 2: !go_i 0010 2-J: 0011 x_sel = 0 3: x_ld = 1 y_sel = 0 4: y_ld = 1 5: 6:
!1 !(!go_i)
4:
Datapath
!x_neq_y x_sel n-bit 2x1 n-bit 2x1
5:
0110
y_sel x_ld 0: x 0: y
8: x = x - y
y_ld
< 6: x<y
subtractor 8: x-y
subtractor 7: y-x
5-J:
9:
1-J:
9: d d_o
d_ld
1100 1-J:
17
Controller
0000 0001 1: 1 2: !go_i 0010 2-J: 0011 x_sel = 0 3: x_ld = 1 y_sel = 0 4: y_ld = 1 5: 6:
!1 x_i !(!go_i) x_sel y_sel x_ld y_ld 0: x 0: y n-bit 2x1 n-bit 2x1 y_i
(b) Datapath
< 6: x<y
subtractor 8: x-y
subtractor 7: y-x
9: d d_o
1001 6-J:
1010 5-J: 1011 9: d_ld = 1
1100 1-J:
18
* * * * * 0 1 * * * * * * * * * * *
19
state register
functional units
20
Sende r
Bridge A single-purpose processor that converts two 4-bit inputs, arriving one at a time over data_in along with a rdy_in pulse, into one 8-bit output on data_out along with a rdy_out pulse.
rdy_out
Rece iver
data_out(8)
Example
Bus bridge that converts 4-bit bus to 8-bit bus Start with FSMD Known as register-transfer (RT) level Exercise: complete the design
Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis
rdy_in=1 RecFirst4End
rdy_in=0 WaitSecond4
rdy_in=1 RecSecond4End
FSMD
Send8End rdy_out=0
Inputs rdy_in: bit; data_in: bit[4]; Outputs rdy_out: bit; data_out:bit[8] Variables data_lo, data_hi: bit[4];
21
(a) Controller
rdy_in=0 WaitFirst4 rdy_in=0 WaitSecond4 rdy_in=1 RecFirst4Start data_lo_ld=1 rdy_in=0 rdy_in=1 RecSecond4Start data_hi_ld=1 rdy_in=1 RecFirst4End
rdy_in=1 RecSecond4End
Send8End rdy_out=0
rdy_out
data_in(4)
data_out_ld data_hi_ld to all registers data_hi data_out data_lo data_lo_ld
data_out
(b) Datapath
22
23
24
replace the subtraction operation(s) with modulo operation in order to speed up program
GCD(42, 8) - 9 iterations to complete the loop x and y values evaluated as follows : (42, 8), (43, 8), (26,8), (18,8), (10, 8), (2,8), (2,6), (2,4), (2,2). Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis
25
separate states
states which require complex operations (a*b*c*d) can be broken into smaller states to reduce hardware size
scheduling
26
3: 4: 5:
3:
5:
merge state 3 and state 4 assignment operations are independent of one another
merge state 5 and state 6 transitions from state 6 can be done in state 5 eliminate state 5J and 6J transitions from each state can be done from state 7 and state 8, respectively eliminate state 1-J transition from state 1-J can be done directly from state 9
x<y 7: y = y -x
x>y 8: x = x - y
9:
d_o = x
7:
9: 1-J:
27
Multi-functional units
ALUs support a variety of operations, it can be shared among operations occurring in different states
28
State minimization
task of merging equivalent states into a single state
state equivalent if for all possible input combinations the two states generate the same outputs and transitions to the next same state
29
Summary
Custom single-purpose processors
Straightforward design techniques Can be built to execute algorithms Typically start with FSMD CAD tools can be of great assistance
30