Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 8211
Скачиваний: 6
680 A P P E N D I X A • Altera UP-1 User Guide
A P P E N D I X A • Altera UP-1 User Guide |
681 |
682 A P P E N D I X A • Altera UP-1 User Guide
A P P E N D I X A • Altera UP-1 User Guide |
683 |
684 A P P E N D I X A • Altera UP-1 User Guide
A P P E N D I X A • Altera UP-1 User Guide |
685 |
686 A P P E N D I X A • Altera UP-1 User Guide
A P P E N D I X A • Altera UP-1 User Guide |
687 |
688 A P P E N D I X A • Altera UP-1 User Guide
690A P P E N D I X B • VHDL Language Reference
1.3Entity and Architecture
All VHDL files require an entity declaration and an architecture body. The entity declaration indicates the input and output ports of the design. The architecture body details the internal relationship between inputs and outputs. The VHDL file name must be the same as the entity name.
Syntax:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY __entity_name IS
GENERIC(define parameters);
PORT(define inputs and outputs);
END __entity_name;
ARCHITECTURE a OF __entity_name IS
SIGNAL and COMPONENT declarations;
BEGIN statements;
END a;
EXAMPLES: ——Majority vote circuit (majority.vhd) LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY majority IS
PORT(
a, b, c: IN STD_LOGIC; y : OUT STD_LOGIC);
END majority;
ARCHITECTURE a OF majority IS
BEGIN
y <= (a and b) or (b and c) or (a and c); END a;
—— 2-line-to-4-line decoder with active-HIGH outputs (decoder.vhd) LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY decoder IS
PORT(
d : IN STD_LOGIC_VECTOR (1 downto 0); y : OUT STD_LOGIC_VECTOR (3 downto 0));
END decoder;
ARCHITECTURE a OF decoder IS
BEGIN
WITH d SELECT
y <= |
“0001” WHEN “00”, |
“0010” WHEN “01”, |
|
“0100” WHEN “10”, |
|
“1000” WHEN “11”, |
|
“0000” WHEN others; |
|
END a; |
|
692 A P P E N D I X B • VHDL Language Reference
integer value, up to the limits of the bit size of the particular computer system for which the VHDL compiler is designed. Some common types are:
Type |
Values |
How written |
BIT |
‘0’, ‘1’ |
Single quotes |
STD_LOGIC |
‘U’, ‘X’, ‘0’, ‘1’, ‘Z’, ‘W’, |
Single quotes |
(see Section 1.6.1) |
‘L’, ‘H’, ‘-‘ |
|
INTEGER |
Integer values |
No quotes |
BIT_VECTOR |
Multiple instances of ‘0’ and ‘1’ |
Double quotes (e.g., “00101”) |
STD_LOGIC_VECTOR |
Multiple instances of ‘U’, ‘X’, |
Double quotes (e.g., “11ZZ00”) |
‘0’, ‘1’, ‘Z’, ‘W’, ‘L’, ‘H’, ‘-‘ |
||
1.6.1STD_LOGIC
The STD_LOGIC (standard logic) type, also called IEEE Std.1164 Multi-Valued Logic, gives a broader range of output values than just ‘0’ and ‘1’. Any port, signal, or variable of type STD_LOGIC or STD_LOGIC_VECTOR can have any of the following values.
‘U’, —— Uninitialized
‘X’, —— Forcing |
Unknown |
‘0’, —— Forcing |
0 |
‘1’, —— Forcing |
1 |
‘Z’, —— High Impedance |
|
‘W’, —— Weak |
Unknown |
‘L’, —— Weak |
0 |
‘H’, —— Weak |
1 |
‘-’, —— Don’t care
“Forcing” levels are deemed to be the equivalent of a gate output. “Weak” levels are specified by a pull-up or pull-down resistor. The ‘Z’ state is used as the high-impedance state of a tristate buffer.
The majority of applications can be handled by ‘X’, ‘0’, ‘1’, and ‘Z’ values.
To use STD_LOGIC in a VHDL file, you must include the following reference to the VHDL library called ieee and the std_logic_1164 package before the entity declaration.
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
1.6.2Enumerated Type
An enumerated type is a user-defined type that lists all possible values for a port, signal, or variable. One use of an enumerated type is to list the states of a state machine.
EXAMPLE: |
TYPE STATE_TYPE IS (idle, start, pulse, read); |
|
SIGNAL state: STATE_TYPE; |
||
1.7 Libraries and Packages
A library is a collection of previously compiled VHDL constructs that can be used in a design entity. A package is an uncompiled collection of VHDL constructs that can be used in multiple design entities. Library names must be included at the beginning of a VHDL file, before the entity declaration, to use certain types or functions. The most obvious is the library ieee, which in the package std_logic_1164, defines the STD_LOGIC (standard logic)