29/10/58 1 copyright 1997, kjh introduction to vhdl lecture 3 prof. k. j. hintz department of...
TRANSCRIPT
![Page 1: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/1.jpg)
04/21/23
1
Copyright ใ 1997, KJH
Introduction to VHDLLecture 3
Prof. K. J. Hintz
Department of Electrical
and
Computer Engineering
George Mason University
![Page 2: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/2.jpg)
04/21/23
2
Copyright ใ 1997, KJH
Sequential Statements
If Statements
Case Statements
Null Statements
Loop Statements
Assertion & Report Statements
![Page 3: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/3.jpg)
04/21/23
3
Copyright ใ 1997, KJH
If Statements
Value of a Boolean Expression Determines Which Statements Are Executed
if_statement <= [ [ if_label : ]]
if Boolean_expression then
sequential_statement
{ { elsif Boolean_expression then
sequential_statement }}
[ [ else
sequential_statement ]]
end if [ [ if_label ] ] ;
![Page 4: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/4.jpg)
04/21/23
4
Copyright ใ 1997, KJH
If Statement Example
entity NiCadCharger is
port ( Voltage, Current : in real ;
AC : in bit ;
Charged, Recharge : out bit );
end entity NiCadCharger ;
![Page 5: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/5.jpg)
04/21/23
5
Copyright ใ 1997, KJH
If Statement Example
architecture ChargerArch1 of NiCadCharger is
begin
Charger_A: process (Voltage, Current, AC ) is
begin
if Voltage >= 9.6 then
Charged <= ‘1’; Recharge <= ‘0’;
elseif (AC = ‘1’ and Current < 0.5 then
Charged <= ‘0’; Recharge <= ‘1’;
else Charged <= ‘0’; Recharge <= ‘0’;
end process Charger_A ;
end architecture ChargerArch1 ;
![Page 6: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/6.jpg)
04/21/23
6
Copyright ใ 1997, KJH
Case Statements
Particular Value of an Expression Determines Which Statements Are Executed
case_statement <= [ [ case_label : ]]
case expression is
( ( when choices =>
{ { sequential_statement } )} )
{ ... }{ ... }
end case [ [ case_label ]] ;
choices <= ( ( simple_expression | | discrete_range
| | element_simple_name | | others ))
{ |... }{ |... }
![Page 7: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/7.jpg)
04/21/23
7
Copyright ใ 1997, KJH
Choices in Case Statements
Locally Static, Determined During Analysis Phase Exactly One Choice for Each Possible Value of
Selector Expression More than one choice can be listed for each “when” Case Specification Alternatives
Enumerate specific value(s) Discrete Range Subtype
others Keyword Which Precedes the Alternative to Be Used If All
Other Case Alternatives Fail
![Page 8: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/8.jpg)
04/21/23
8
Copyright ใ 1997, KJH
Case Statement Example
entity Multiplexer is
port ( MuxSelect : in subtype MuxType is positive range 0 to 3;
In_0, In_1, In_2, In_3 : in bit ;
MuxOut : out bit );
end entity Multiplexer ;
![Page 9: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/9.jpg)
04/21/23
9
Copyright ใ 1997, KJH
Case Statement Example
4_to_1_MUX :
case MuxSelect is
when 0 =>
MuxOut <= In_0 ;
when 1 =>
MuxOut <= In_1 ;
when 2 =>
MuxOut <= In_2 ;
when 3 =>
MuxOut <= In_3 ;
end case 4_to_1_MUX ;
![Page 10: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/10.jpg)
04/21/23
10
Copyright ใ 1997, KJH
Null Statements
Need Method of Specifying When No Action Is to Be Performed, e.g., In Case Statement
null_statement <= [ [ null_label : ]] null ;
Use As “Stub” for Code to Be Written
FlirFocus: process ( range, aperture )
begin
null;
end process FlirFocus ;
![Page 11: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/11.jpg)
04/21/23
11
Copyright ใ 1997, KJH
Loop Statements
Used for Repeated Execution of Sequential Statements Alternatives
Infinite Single or multi-phase clock Whole system turned on
Exit on condition Inner & Outer Loops Next While For
![Page 12: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/12.jpg)
04/21/23
12
Copyright ใ 1997, KJH
Loop Statement Syntax
loop_statement <=
[ [ loop_label : ]] loop
{ { sequential_statement }}
end loop [ [ loop_label : ]] ;
![Page 13: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/13.jpg)
04/21/23
13
Copyright ใ 1997, KJH
Infinite Loop Example
entity 2_Phase_Clock is
port ( Clk : in bit ;
Phase_1, Phase_2 : out bit );
end entity 2_Phase_Clock ;
![Page 14: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/14.jpg)
04/21/23
14
Copyright ใ 1997, KJH
Infinite Loop Example
architecture 2PC of 2_Phase_Clock
begin
variable P1 : bit ;
loop
wait until Clk = ‘1’
if P1 = ‘0’ then
Phase_1 <= ‘0’; Phase_2 <= ‘1’; P1 := ‘1’;
else
Phase_1 <= ‘1’; Phase_2 <= ‘0’; P1 := ‘0’;
end if ;
end loop 2PC;
end architecture 2PC ;
![Page 15: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/15.jpg)
04/21/23
15
Copyright ใ 1997, KJH
Exit on Condition
variable String_Length : positive := 0 ;
constant String_Max : positive := 80 ;
StringFill: loop
wait until Char_In;
String_Length := String_Length + 1;
exit when String_Length = String_Max ;
end loop StringFill ;
![Page 16: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/16.jpg)
04/21/23
16
Copyright ใ 1997, KJH
Inner & Outer Loops
for Row_Index in 1 to Row_Max
Outer_Loop: loop
Inner_Loop: loop
exit Outer_Loop when Pixel_In = EOF ;
New_Image ( Row_index, Col_Index ) := Pixel_In ;
end loop Inner_Loop ;
end loop OuterLoop ;
![Page 17: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/17.jpg)
04/21/23
17
Copyright ใ 1997, KJH
Next Loops
The ‘next’ statement terminates execution of the current iteration and starts the subsequent iteration
If There Is a Loop Label the Statement Applies to That Loop
If There Is No Loop Label, the Statement Applies to the Inner-Most Enclosing Loop
![Page 18: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/18.jpg)
04/21/23
18
Copyright ใ 1997, KJH
In/Out Loops, Next Example
loop_1: loop
loop_2: loop
something;
next loop_1 when String_Length = 0 ;
more_something;
end loop loop_2;
end loop loop_1;
![Page 19: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/19.jpg)
04/21/23
19
Copyright ใ 1997, KJH
While
The Loop Only Executes, and Continues to Execute, If the Boolean Expression Evaluates to True, and Continues to Be Evaluated As True.
while
String_Length <= String_Max
String1: loop
String_Length := String_Length + 1 ;
end loop String1: ;
![Page 20: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/20.jpg)
04/21/23
20
Copyright ใ 1997, KJH
For Loops
The Loop Variable Is of Type Constant and Hence It Cannot Be Modified Within the Loop
The Loop Variable Is a Strictly Local Constant
for String_Index in 1 to String_Max
String_Reverse : loop
My_String( String_Index ) :=
Buffer (String_Max - String_Index + 1);
end loop String_Reverse ;
![Page 21: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/21.jpg)
04/21/23
21
Copyright ใ 1997, KJH
Assertion & Report Statements
Assertion Statements Check Expected Conditions at Their Location in the Program.
Assertion Statements Are Not “If” Statements Since They Test for the Correct, Expected Results Rather Than an Error.
If Other Than the Expected Condition, the Report and Severity Expressions Are Executed
assertion_statement <=
[ [ assertion_label : ] ] assert Boolean_expression
[ [ report expression ]] [[ severity expression ]] ;
![Page 22: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/22.jpg)
04/21/23
22
Copyright ใ 1997, KJH
Assertion Statements
Expression Must Evaluate to String Uses
Simulation notify user when statement is executed optionally print report expression optionally print severity e.g., (note, warning, error, failure) determine whether to continue
Synthesis: value in assertion statement is assumed and circuit optimized on that value
Verification: determine that the assertation statement is true for all possible values based on all possible routes to the statement
![Page 23: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/23.jpg)
04/21/23
23
Copyright ใ 1997, KJH
Report Statement
A Note Is Printed Whenever the Expression Occurs Report Always Produces a Message Useful for Tracing Values or Paths During Execution Expression Must Evaluate to String
[ [ report_label : ] ] report expression [[ severity expression ]] ;
![Page 24: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/24.jpg)
04/21/23
24
Copyright ใ 1997, KJH
HW 2-11
LIBRARY ieee;
USE ieee.std_logic_1164.all;
PACKAGE Clock_2_11_pkg IS
COMPONENT Clock_2_11
--GENERIC ( );
PORT ( ClockOut : out bit := '0');
END COMPONENT;
END Clock_2_11_pkg;
![Page 25: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/25.jpg)
04/21/23
25
Copyright ใ 1997, KJH
HW 2-11
ENTITY Clock_2_11 IS
--GENERIC ( );
PORT ( ClockOut : out bit := '0' );
END Clock_2_11;
![Page 26: 29/10/58 1 Copyright 1997, KJH Introduction to VHDL Lecture 3 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University](https://reader035.vdocument.in/reader035/viewer/2022081512/56649f075503460f94c1cbc9/html5/thumbnails/26.jpg)
04/21/23
26
Copyright ใ 1997, KJH
HW 2-11
ARCHITECTURE KJH_Clock OF Clock_2_11 IS
BEGIN
clock_gen: PROCESS
BEGIN
ClockOut <= '1'; WAIT FOR 10 ns;
Clockout <= '0'; WAIT FOR 10 ns;
END PROCESS clock_gen ;
END KJH_Clock;