11/10/2023
RTL Design
Laser-Based Distance Measurer—Step 2C: Derive the Controller FSM
Controller Inputs: B, S Outputs: L, Dreg_clr, Dreg_ld, Dctr_clr, Dctr_ld
B S
B S
S0 S1 S2 S3 S4
L=0 Dctr_clr = 1 L=1 L=0 Dreg_ld = 1
Dreg_clr = 1 (clear count) (laser on) Dctr_ld = 1 Dctr_ld = 0
(laser off) (laser off) (load Dreg with Dctr/2)
(clear Dreg) (count up) (stop counting)
Some assignments to 0 still shown, due to their importance in
understanding desired controller behavior
Same FSM, using convention of
unassigned outputs implicitly assigned 0
RTL Design
HLSMs
s a
High-level state machine (HLSM) 8 8
extends FSM with:
Multi-bit input/output c Soda
dispenser
Local storage d
processor
Arithmetic operations
Conventions Inputs: c (bit), a (8 bits), s (8 bits)
Numbers: Outputs: d (bit) // '1' dispenses soda
Local storage: tot (8 bits)
Single-bit: '0' (single quotes)
Integer: 0 (no quotes) c
Multi-bit: “0000” (double quotes) Add
Init Wait
== for equal, := for assignment tot:=tot+a
Multi-bit outputs must be registered via d:='0' c’ * (tot<s)
local storage tot:=0 c’*(tot<s)’
// precedes a comment Disp
SodaDispenser d:='1'
1
11/10/2023
RTL Design
Example: Soda Dispenser from Earlier
s a
8 8
Quick overview example, more details of
each step to come
tot_ld ld
tot
tot_clr clr
Inputs: c (bit), a (8 bits), s (8 bits)
Outputs: d (bit) // '1' dispenses soda
8
Local storage: tot (8 bits)
c 8-bit
tot_lt_s 8-bit
Add adder
<
Init Wait
tot:=tot+a Datapath 8
d:='0' c’ * (tot<s)
tot:=0 c’*(tot<s)’ Step 2A
Disp s a
8 8
SodaDispenser d:='1'
c
Step 1 tot_ld
d
tot_clr
Controller Datapath
tot_lt_s
Step 2B
3
RTL Design
Example: Soda Dispenser
s a
8 8
Quick overview example, more details of
each step to come c
tot_ld
d
tot_clr
Inputs: c (bit), a (8 bits), s (8 bits)
Controller Datapath
Outputs: d (bit) // '1' dispenses soda tot_lt_s
Local storage: tot (8 bits)
Step 2B
c
Add
Init Wait
tot:=tot+a Inputs : c, tot_lt_s (bit)
Outputs : d, tot_ld , tot_clr (bit)
d:='0' c’ * (tot<s) tot_ld
c’*(tot<s)’ c
tot:=0 c
Disp Add tot_clr
d
Init Wait
tot_ld=1 tot_lt_s
SodaDispenser d:='1'
d=0 c' c tot_lt_s
tot_lt_s’
tot_clr=1
Step 1 Disp
Controller d=1
Step 2C
4
2
11/10/2023
RTL Design
Example: Soda Dispenser
Quick overview example, more details of
Inputs : c, tot_lt_s (bit)
each step to come Outputs : d, tot_ld , tot_clr (bit)
c tot_ld
c
Add tot_clr
d
Init Wait
tot_lt_s
tot_clr
tot_ld=1
tot_ld
tot_lt_s
s1 s0 c n1 n0 d d=0 c' c tot_lt_s
tot_lt_s’
0 0 0 0 0 1 0 0 1 tot_clr=1
0 0 0 1 0 1 0 0 1 Disp
Init
0 0 1 0 0 1 0 0 1 Controller d=1
0 0 1 1 0 1 0 0 1
0 1 0 0 1 1 0 0 0 Step 2C
0 1 0 1 0 1 0 0 0
Wait
0 1 1 0 1 0 0 0 0
0 1 1 1 1 0 0 0 0
1 0 0 0 0 1 0 1 0
Add
Use controller design process (Unit 2)
1 1 0 0 0 0 1 0 0
Disp
to complete the design