Professional Documents
Culture Documents
V H D L: Ery High Speed Integrated Circuits Ardware Escription Anguage
V H D L: Ery High Speed Integrated Circuits Ardware Escription Anguage
13-04-21 1
Subjects
Goal
Assessments
Non -appearance
Subjects
Plan
Questions.
13-04-21 2
Goal
The students are able to describe
hardware with VHDL and to
implement it on a testboard , on their
own
13-04-21 3
Practical
Following the praktikum is mandatory.
When you are not able to come please
contact the teacher.
If you miss more than two practical lessons :
no credits.
13-04-21 4
Assessment
Theoritical/ practical examination
13-04-21 5
Responsibilities
The student is responsible for the
hard and software, which must be
used by the next group.
Defects must be reported immediately
13-04-21 6
Subjects.
History VHDL
VHDL Data Types
VHDL Operators
VHDL Based Synthesis of Digital Hardware
Synthesis Models of Gate Networks
Seven-segment LED Decoder
Multiplexer
Tri-State Output
Flip-flops and Registers
Inferred Latches
Counter
State Machine
ALU
Multiply and Divide
Memory
Hierarchy
13-04-21 7
Subjects week 1
History
Data types
VHDL operators
Synthesis
Gate Networks
Exercise 1 ‘Adder’
Introduction Quartus
13-04-21 8
1981 initiation United States Department of Defence
1983-85 baseline language Intermetrics,IBM,IT
1986 rights to IEEE
1987 first publication of IEEE Standard
1994 Revised standard
VHDL(1076-1993)
About each 3 years a new version
2006 new version (more analogue description
possible)
The VHDL standard IEEE 1076-2008[2] was
published in January 2009.
History
13-04-21 9
Alternatives to VHDL
Verilog: biggest next to VHDL
http://my.ece.msstate.edu/faculty/reese/EE4743/lectures
/verilog_intro_2002/verilog_intro_2002.pdf
Alternatives
13-04-21 10
Variables and Signal types
VHDL
Data types
13-04-21 11
STD_LOGIC (U, X,0,1,Z,W,L,H,-)
'U': uninitialized. This signal hasn't been set yet.
'X': unknown. Impossible to determine this
value/result.
'0': logic 0
'1': logic 1
'Z': High Impedance
'W': Weak signal, can't tell if it should be 0 or 1.
'L': Weak signal that should probably go to 0
'H': Weak signal that should probably go to 1
'-': Don't care.
VHDL
Data types
13-04-21 12
STD_LOGIC_VECTOR
VHDL
Operators
13-04-21 14
ENTITY nand IS
PORT (A,B : IN STD_LOGIC;
Out: OUT STD_LOGIC);
END nand;
13-04-21 16
Exercise 2
Design a SR-FLIP FLOP in VHDL
13-04-21 17
Introduction Quartus
13-04-21 18
“Danjel” board
13-04-21 19
“Danjel” board
13-04-21 20
Subjects week 2
Levels of design
Behavioral
Structural
Register Level
Timing (chapter4)
Seven segment decoder(chapter 5)
13-04-21 21
Behavioral level
ARCHITECTURE behavior OF ilatch IS
BEGIN
PROCESS (A, B)
BEGIN
IF A = '0' THEN
Output1 <= '0';
Output2 <= '0';
ELSE
IF B = '1' THEN
Output1 <= '1';
Output2 <= '1';
ELSE
Output1 <= '0'; END
IF;
END IF;
END PROCESS;
END behavior;
13-04-21 22
Structural level
13-04-21 25
Explicite processes ,
The Sensitivity list
compute_xor: process (b,c)
begin
a<=b xor c;
end process;
compute_xor: process (c)
begin
a<=b xor c;
13-04-21
end process;http://esd.cs.ucr.edu/labs/tutorial/ 26
implicite processes
In inplicit processes you do not see the
word “process”. Each assignment is a
process on itself
begin
a<=b xor c;
d<=b and c;
end archx;
13-04-21 http://esd.cs.ucr.edu/labs/tutorial/ 27
7 segments
decoder
13-04-21 28
Architecture with case statement
ARCHITECTURE behaviour OF sevensegm
PROCESS(msd)
BEGIN
CASE msd IS
WHEN “0000” =>
msd_7seg <= “1111110”;
13-04-21
etc 29
Assignment 1,2
Write a structural architecture of the next schematics;
13-04-21 30
Assignment 3
architecture structural_2 of multiplexer_4_to_1_st is
component NOT1 port( in1 : in std_logic; out1 : out
std_logic); end component;
13-04-21 33
Subjects week 3
Multiplex and demultiplex(Chapter 6)
Tri state (Chapter 7)
Flip-flops and registers(Chapter 8)
13-04-21 34
Mux_out <=A WHEN Mux_Control =‘0’
ELSE Mux_out <=B;
Multiplexer
when else
13-04-21 35
Process(A,B,Mux_control)
begin
if Mux_control =‘0’ then Mux_out <=A
Multiplexer
if else Mux_out <= B; end if;
end process;
13-04-21 36
Process(A,B,Mux_control)
Begin
case Mux_control is
when ‘0’ =>
mux_out <= A;
when ‘1’=>
mux_out <= B;
when others =>
Multiplexer mux_out <= A;
case end case;
end process;
13-04-21 end 37
ENTITY tristate IS
PORT(A,Control : IN STD_LOGIC;
Tri_out :INOUT STD_LOGIC);
END tristate;
Tri-State
13-04-21 38
ARCHITECTURE behaviour OF tristate IS
BEGIN
Tri_out <= A WHEN Control =‘0’ ELSE ‘Z’;
END behaviour;
13-04-21 40
D-Flip flop
13-04-21 41
Gated D-Flip flop
PROCESS (Reset,Clock)
BEGIN
IF reset = '1' THEN
Q4 <= '0';
ELSIF (clock'EVENT AND clock='1') THEN
IF Enable = '1'
THEN Q4 <= D;
END IF;
END IF;
END PROCESS;
13-04-21 42
Gated D-ff register
PROCESS (Reset,Clock)
BEGIN
IF reset = '1' THEN
Q4 <= '00000000';
ELSIF (clock'EVENT AND clock='1') THEN
IF Enable = '1'
THEN Q4 <= D;
END IF;
END IF;
END PROCESS;
13-04-21 45
Subjects week 4
Inferred latches(Chapter 9)
Counters (Chapter 10)
Simulating with Quartus simulator
FPGA MAX II technology
LUT
I/O
13-04-21 46
Accidental Synthesis of inferred
latch
ARCHITECTURE behavior OF ilatch IS
BEGIN
PROCESS (A, B)
BEGIN
IF A = '0' THEN
Output1 <= '0';
Output2 <= '0';
ELSE
IF B = '1' THEN
Output1 <= '1';
Output2 <= '1';
ELSE
Output1 <= '0'; --latch inferred
since no
-- value is assigned to output 2 in the else clause
END IF;
END IF;
13-04-21
END PROCESS; 47
END behavior;
Counters
USE IEEE.STD_LOGIC_ARITH.all;
USE IEEE.STD_LOGIC_UNSIGNED.all;
13-04-21 48 48
Counters
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Counter2_VHDL is
port( Clock_enable_B: in std_logic;
Clock: in std_logic;
Reset: in std_logic;
Output: out std_logic_vector(0 to 3));
end Counter2_VHDL;
13-04-21 49 49
Counters architecture Behavioral of Counter2_VHDL is
signal temp: std_logic_vector(0 to 3);
begin
process(Clock,Reset)
begin
if Reset='1‘
then temp <= "0000";
elsif(Clock'event and Clock='1')
then if Clock_enable_B='0'
then if temp="1111"
then temp<="0000";
else temp <= temp + 1;
end if;
end if;
end if;
end process;
13-04-21 Output <= temp; 50
end Behavioral; 50
Simulating with Quarter simulator (1) 4 to 1
13-04-21 51
51
Simulating with Quarter simulator
(up/down counter)
13-04-21 52
52
FPGA MAX II technology (1)
13-04-21 53
53
FPGA MAX II technology (2)
13-04-21 54
54
Look Up Table (LUT)
13-04-21 56
56
13-04-21 57
57
I/O FEATURES
IOEs support many features, including:
■ LVTTL and LVCMOS I/O standards
■ 3.3-V, 32-bit, 66-MHz PCI compliance
■ Weak pull-up resistors during power-up and in system
programming
■ Slew-rate control
■ Tri-state buffers with individual output enable control
■ Programmable pull-up resistors in user mode
■ Unique output enable per pin
■ Open-drain outputs
■ Schmitt trigger inputs
■ Programmable Drive Strength
13-04-21 58
58
I/O FEATURES
13-04-21 59
59
Subjects week 5
Statemachines(Chapter 11)
ALU (Chapter 12)
Multiply (Chapter 13)
Memory (Chapter 14)
13-04-21 60
State Machines
13-04-21 61
State Machines (flow)
library IEEE;
use IEEE.STD_LOGIC_1164.all;
ENTITY st_mach IS
PORT( clk, reset : IN STD_LOGIC;
Input1, Input2 : IN STD_LOGIC;
Output1 : OUT STD_LOGIC);
END st_mach;
ARCHITECTURE A OF st_mach IS
-- Enumerated Data Type for State
TYPE STATE_TYPE IS (state_A, state_B, state_C);
SIGNAL state: STATE_TYPE;
BEGIN
PROCESS (reset, clk)
BEGIN
IF reset = '1' THEN
state <= state_A;
ELSIF clk'EVENT AND clk = '1' THEN
CASE state IS
13-04-21 62
State Machines
ELSIF clk'EVENT AND clk = '1' THEN
CASE state IS
WHEN state_A =>
IF Input1 = '0' THEN
state <= state_B;
ELSE
state <= state_C;
END IF;
WHEN state_B =>
state <= state_C;
WHEN state_C =>
IF Input2 = '1' THEN
state <= state_A;
END IF;
WHEN OTHERS =>
state <= state_A;
END CASE;
END IF;
13-04-21 63
END PROCESS;
State Machines (output decoder)
PROCESS (state)
BEGIN
CASE state IS
WHEN A =>
output1 <= ‘0';
WHEN B =>
output1 <= '1';
WHEN C =>
output1 <= ‘0';
END CASE;
13-04-21 64
VHDL Synthesis Model of an ALU ALU
13-04-21
65
12. VHDL Synthesis Model of an ALU
library and entity
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
USE IEEE.STD_LOGIC_ARITH.all;
USE IEEE.STD_LOGIC_UNSIGNED.all;
ENTITY ALU IS
PORT(
Op_code : in std_logic_vector(2 DOWNTO 0);
A_input, B_input: in std_logic_vector(7 DOWNTO 0);
ALU_output : out std_logic_vector(7 DOWNTO 0));
END ALU;
13-04-21 66
VHDL Synthesis Model of an ALU A
architecture ARCHITECTURE behavior OF ALU IS
-- declare signal(s) internal to module here
SIGNAL temp_output: std_logic_vector(7 DOWNTO 0);
BEGIN
PROCESS (Op_code, A_input, B_input)
BEGIN
-- Select Arithmetic/Logical Operation
CASE Op_Code (2 DOWNTO 1) IS
WHEN "00" =>
temp_output <= A_input + B_input;
WHEN "01" =>
temp_output <= A_input - B_input;
WHEN "10" =>
temp_output <= A_input AND B_input;
WHEN "11" =>
temp_output <= A_input OR B_input;
WHEN OTHERS =>
temp_output <= "00000000";
END CASE;
-- Select Shift Operation
IF Op_Code(0) = '1' THEN
-- Shift bits left with zero fill using concatination operator
-- can also use VHDL 1076-1993 shift operator such as SLL
Alu_output <= temp_output(6 DOWNTO 0) & '0';
ELSE
Alu_output <= temp_output;
END IF;
13-04-21 END PROCESS; 67
END behavior;
VHDL Synthesis Model of multiply and
Divide hardware
-Efficient design requires vendor
13-04-21 70
VHDL Synthesis LIBRARY IEEE; models for memory example
2 USE IEEE.STD LOGIC 1164.ALL;
ENTITY memory IS
PORT( read data : OUT STD_LOGIC_VECTOR( 7 DOWNTO 0 );
read address : IN STD_LOGIC_VECTOR( 2 DOWNTO 0 );
write-data : IN STD_LOGIC_VECTOR( 7 DOWNTO 0 );
write address : IN STD_LOGIC_VECTOR( 2 DOWNTO 0 );
Memwrite : IN ST_ LOGIC;
Clock : IN STD_LOGIC );
END memory;
ARCHITECTURE behavior OF memory IS
define new data type for memory array
TYPE memory_type IS ARRAY ( 0 TO 7 ) OF STD_LOGIC_VECTOR (7 DOWNTO 0 );
SIGNAL memory : memory type;
BEGIN
--Read Memory and convert array index to an integer with CONV INTEGER
read-data <= memoir (CONV_INTEGER )read-address (2 downto 0 ) );
PROCESS - - Write Memory?
BEGIN
WAIT UNTIL clock 'EVENT AND clock = '1';
IF ( memorize = '1' ) THEN
--- convert array index to an integer with CONV INTEGER
memory ( CONV_INTEGER) write-address( 2 DOWNTO 0 ) ) ) <= write-data;
END IF;
13-04-21 END PROCESS; 71
71
END behavior;
Subjects week 6
Hierarchy (Chapter 15)
Explanation final assignments
13-04-21 72
15 Hierarchy in VHDL Synthesis models
13-04-21 73 73
15 Final assignment Moving average filter
13-04-21
Draw a blockschemtic. 74 74
15 Final assignment Serial send (9600 baud)
13-04-21 75 75
Source : pic16f690 datasheet microchip
17 Conclusion
•Just an introduction of VHDL
basics
•Many templates and examples
IEEE
•Many online examples
13-04-21 76 76