Lecture 5 RTL Design
Lecture 5 RTL Design
Introduction outputs
inputs
bi bo
FSM
FSM
• Controllers Combinational
– Control input/output: single bit (or just a logic n1
few) representing event or state n0
s1 s0
– Finite-state machine describes
State register
behavior; implemented as state register clk
and combinational logic
• Datapath components
– Data input/output: Multiple bits Register Comparator
collectively representing single entity si
Register file
registers, adders, ALU, comparators, ALU
register files, etc.
bi bo
• This chapter: custom processors
e
1
10/31/2023
RTL Design
High-Level State Machines (HLSMs)
2
10/31/2023
RTL Design
HLSMs
s a
RTL Design
Ex: Cycles-High Counter
m m' m
? // Increment Preg
m S_Inc Preg := Preg + 1
(a) (b) (c)
a
6
3
10/31/2023
RTL Design
Example: Laser-Based Distance Measurer
T (in seconds)
laser
D
Object of
a
interest
sensor
2D = T sec * 3*108 m/sec
RTL Design
Example: Laser-Based Distance Measurer
T (in seconds)
B L
laser from button to laser
Laser-based
distance
sensor D 16 measurer S
to display from sensor
Inputs/outputs
B: bit input, from button, to begin measurement
L: bit output, activates laser
S: bit input, senses laser reflection
D: 16-bit output, to display computed distance
4
10/31/2023
RTL Design
Example: Laser-Based Distance Measurer
DistanceMeasurer B Laser-based L
Inputs : B (bit), S (bit) 16 distance measurer
Outputs : L (bit), D (16 bits) D S
Local storage: Dreg(16)
a
S0 ?
(first state usually
L := '0' // laser off initializes the system)
Dreg := 0 // distance is 0
RTL Design
Example: Laser-Based Distance Measurer
B Laser-based L
DistanceMeasurer
16 distance measurer
... B' // button not pressed D S
S0 S1 ?
B
L := '0' // button
Dreg := 0 pressed
10
5
10/31/2023
RTL Design
Example: Laser-Based Distance Measurer
B Laser-based L
16 distance measurer
DistanceMeasurer D S
... B'
S0 S1 S2 S3
B
L := '0' L := '1' L := '0'
Dreg := 0 // laser on // laser off
Q: What do next?
a
A: Start timer, wait to sense reflection
11
RTL Design
Example: Laser-Based Distance Measurer
S // reflection
S0 S1 S2 S3 ?
B
L := '0' Dctr := 0 L := '1' L := '0'
Dreg := 0 // reset cycle Dctr := Dctr + 1
count // count cycles
a
12
6
10/31/2023
RTL Design
Example: Laser-Based Distance Measurer
S0 S1 S2 S3 S4
B S
L := '0' Dctr := 0 L := '1' L := '0' Dreg := Dctr/2
Dreg := 0 Dctr := Dctr+1 // calculate D
13