VHDL and HDL Designer Primer: Instructor: Jason D. Bakos
VHDL and HDL Designer Primer: Instructor: Jason D. Bakos
VHDL and HDL Designer Primer: Instructor: Jason D. Bakos
entity buffer is
port (
a:in std_logic_vector(3 downto 0);
y:out std_logic_vector(3 downto 0)
);
end;
– std_logic_vector
• Array of std_logic
• Represents a “bus” signal
– Hardware is concurrent
• Each line of code executes concurrently (no ordering)
A = B + C
print A (output is 10)
print B (output is 5)
B = C
print A (output is 10)
print B (output is 5)
• Example:
– A <= B OR C when D=‘1’ else C OR D;
– E <= A + B;
• Behavioral VHDL
– Defines how outputs are computed as function of inputs
– Use a “process”
• Looks like a programming language
• Internally has sequential semantics
• Sensitivity list
• Process block implements concurrent assignment
• May contain variables
• Constructs: if-then, for-loop, while-loop, inf-loop
• Difficult to synthesize
• Not synthesizable: timed waits, file I/O, some loop structures
• Example:
• Loops
loop
<statements>
end loop;
for i in 0 to 15 loop
<statements>
end loop;
while <condition>
<statements>
end loop;
• Views
– Block diagram
– State machine
– Truth table
– Flow chart
– VHDL view (combined or architecture-only)
– Symbol
library CPU_lib
component
ALU CPU control_unit
Library
ALU_Lib
Component
ALU
Src (hds) HDL Downstream Downstream
(graphical view) (generated) (compiled for sim) (compiled for synth)
Shared
Project ALU CPU
– Embedded blocks –
embedded into block
diagram
• Shown as yellow blocks
• Embeds behavior into structure
• Combinational logic
– Output = f (input)
• Sequential logic
– Output = f (input, input history)
– Involves use of memory elements
• Registers
– input set
– output set No locked
Standby
on
missile
– states (one is start state) detected
Fire=no
– transitions
Target
Fire = no
hit
miss
• FSMs are used for controllers
Locked
on
Launch
Fire= yes
-- Architecture Declarations
TYPE STATE_TYPE IS (
standby,
e5,
e10,
e25,
e30,
e15,
e20,
e35,
e50,
e40,
e55,
e45
);
----------------------------------------------------------------------------
clocked : PROCESS(
clk,
rst
)
----------------------------------------------------------------------------
BEGIN
IF (rst = '1') THEN
current_state <= standby;
-- Reset Values
ELSIF (clk'EVENT AND clk = '1') THEN
current_state <= next_state;
-- Default Assignment To Internals
END IF;
----------------------------------------------------------------------------
nextstate : PROCESS (
coin,
current_state
)
----------------------------------------------------------------------------
BEGIN
CASE current_state IS
WHEN standby =>
IF (coin = "01") THEN
next_state <= e5;
ELSIF (coin = "10") THEN
next_state <= e10;
ELSIF (coin = "11") THEN
next_state <= e25;
ELSE
next_state <= standby;
END IF;
WHEN e5 =>
IF (coin = "10") THEN
next_state <= e15;
ELSIF (coin = "11") THEN
next_state <= e30;
ELSIF (coin = "01") THEN
next_state <= e10;
ELSE
next_state <= e5;
END IF;
WHEN e10 =>
…
----------------------------------------------------------------------------
output : PROCESS (
current_state
)
----------------------------------------------------------------------------
BEGIN
-- Default Assignment
change <= "00";
release <= '0';
-- Default Assignment To Internals
-- Combined Actions
CASE current_state IS
WHEN standby =>
change <= "00" ;
release <= '0' ;
WHEN e5 =>
change <= "00" ;
release <= '0' ;
WHEN e10 =>
change <= "00" ;
release <= '0' ;
WHEN e25 =>
change <= "00" ;
release <= '0' ;
WHEN e30 =>
change <= "00" ;
release <= '0' ;
WHEN e15 =>
change <= "00" ;
release <= '0' ;
…
hstate1
• Reproducible
– Can use same testbench for multiple
implementations/generations of a component
– Can generate or utilize data file to share tests
between simulation and hardware testing