際際滷

際際滷Share a Scribd company logo
仍舒仆仂于 ..
[v.kulanov@csn.khai.edu]
丐亳仗 亟舒仆仆 于 磶从亠
仂仗亳舒仆亳 舒仗仗舒舒
VHDL
束丐亠仆仂仍仂亞亳亳 仗仂亠从亳仂于舒仆亳
从仂仄仗ム亠仆 亳亠仄損
丼仂 舒从仂亠 束亳仗 亟舒仆仆損?
 丐亳仗 亟舒仆仆 (亳仗)  仄仆仂亢亠于仂 亰仆舒亠仆亳亶 亳
仂仗亠舒亳亶 仆舒 亳 亰仆舒亠仆亳 (IEEE Std 1320.2-1998).
丐亳仗 亟舒仆仆 舒舒从亠亳亰亠 仂亟仆仂于亠仄亠仆仆仂:
 仄仆仂亢亠于仂 亟仂仗亳仄 亰仆舒亠仆亳亶, 从仂仂亠
仄仂亞 仗亳仆亳仄舒 亟舒仆仆亠, 仗亳仆舒亟仍亠亢舒亳亠 从
仂仄 亳仗;
 仆舒弍仂 仂仗亠舒亳亶, 从仂仂亠 仄仂亢仆仂 仂亠于仍
仆舒亟 亟舒仆仆仄亳, 仗亳仆舒亟仍亠亢舒亳仄亳 从 仂仄 亳仗.
丐亳仗 亟舒仆仆 于 磶从亠 VHDL
亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆
+ =
+ =
丐亳仗 亟舒仆仆 于 磶从亠 VHDL
亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆
VARIABLE counter: INTEGER := 0;
VARIABLE step: INTEGER := 0;
VARIABLE offset: NATURAL := 0;
SIGNAL z_flag : BIT;
counter := counter + 1;
counter := counter + step;
counter := offset;
counter <= 5;
z_flag <= 1;
z_flag <= 0;
counter := step + offset;
丐亳仗 亟舒仆仆 于 磶从亠 VHDL
亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆
TYPE state1 IS (IDLE, ERROR, GO);
TYPE state2 IS (IDLE, ERROR, GO);
VARIABLE sys1_state, sys2_state: state1;
VARIABLE module_state: state2;
sys1_state := ERROR;
sys2_state := GO;
sys2_state := ERROR;
module_state := IDLE;
sys1_state := module_state;
丐亳仗 亟舒仆仆 于 磶从亠 VHDL
亠亟仂仗亠亟亠仍亠仆仆亠 亳仗 亟舒仆仆
 仗亠亟亠仍亠仆 于 舒仆亟舒舒 IEEE 1076
 亠 亠弍亠 仗仂亟从仍ム亠仆亳 仂仂仆仆亳 仗舒从亠仂于/弍亳弍仍亳仂亠从
 舒仂亟 于 仗舒从亠亠 STANDARD 亳 TEXTIO (弍亳弍仍亳仂亠从舒 STD),
从仂仂亶 仗仂亟从仍ム舒亠 仆亠磦仆仂
丐亳仗 亟舒仆仆 于于仂亟亳仄亠 仗仂仍亰仂于舒亠仍亠仄
 仗亠亟亠仍亠仆 于 仗仂仍亰仂于舒亠仍从亳 亳 亟亞亳 仂仂仆仆亳
仗舒从亠舒/弍亳弍仍亳仂亠从舒
 亳 亳仗仂仍亰仂于舒仆亳亳 仆亠仂弍仂亟亳仄仂 磦仆仂 从舒亰于舒
仗仂亟从仍ム舒亠仄亠 仗舒从亠/弍亳弍仍亳仂亠从亳
 弍磶舒亠仍仆仂 亟仂仍亢仆 弍 亳亰于亠仆 仆舒 舒仗亠 亟亠从仍舒舒亳亳
仂弍亠从仂于 磶从舒 (仗亠亠仄亠仆仆, 亳亞仆舒仍仂于, 从仂仆舒仆 亳 .亟.)
IEEE.numeric_std.vhd
IEEE.std_logic_1164.vhd
丐舒从仂仆仂仄亳亳仗仂于亟舒仆仆
丼亳仍亠仆仆亠 亳仗 亟舒仆仆
INTEGER
а亠仍仂亳仍亠仆仆亶 亳仗 亟舒仆仆
{-231+1, +231-1} (-2 147 483 647 亟仂 2 147 483 647)
REAL
亟亠亶于亳亠仍仆亶 亳仗 亟舒仆仆
{-238, +238}
CONSTANT PI : REAL := 3.14159;
CONSTANT HALF_PI : REAL := Pi/2.0;
CONSTANT N, N5 : INTEGER := 5;
VARIABLE count : INTEGER := 0;
VARIABLE flag : INTEGER := 1.5;
丼亳仍亠仆仆亠 亳仗 亟舒仆仆
 亳仄亠亳亠从亳亠 仂仗亠舒亳亳
束+損  仍仂亢亠仆亳亠 亳仍亳 仗仂于仂亠仆亳亠;
束-損  于亳舒仆亳亠 亳仍亳 亳仆于亠亳;
束*損 - 仄仆仂亢亠仆亳亠;
束/損 - 亟亠仍亠仆亳亠;
mod  亳仍仂 仗仂 仄仂亟仍 (5 mod 3 = 2);
rem  仂舒仂从 仂 亟亠仍亠仆亳;
abs  仄仂亟仍 (舒弍仂仍ム仆仂亠 亰仆舒亠仆亳亳 亳仍舒);
** - 于仂亰于亠亟亠仆亳亠 于 亠仗亠仆.
 仗亠舒亳亳 舒亳仄亠亳亠从仂亞仂 仂仆仂亠仆亳
=, /=, <, <=, >=, >, 从仂仂亠 亟舒ム 亠亰仍舒 亳仗舒 BOOLEAN
CONSTANT DATA_WIDTH: NATURAL := 8;
VARIABLE address_width: NATURAL := 2**DATA_WIDTH;
个亳亰亳亠从亳亠 亳仗 亟舒仆仆
TYPE TIME IS RANGE -2147483647 TO 2147483647
UNITS
fs; -- femtosecond
ps = 1000 fs; -- picosecond
ns = 1000 ps; -- nanosecond
us = 1000 ns; -- microsecond
ms = 1000 us; -- millisecond
sec = 1000 ms; -- second
min = 60 sec; -- minute
hr = 60 min; -- hour
END UNITS;
仗亠亟舒于仍磳 亠仍仄 亳仍仂仄, 亠亟亳仆亳舒 从仂仂仂亞仂 亳仄亠亠 于亠
亠亟亳仆亳 亳亰仄亠亠仆亳 仆亠从仂仂仂亶 亳亰亳亠从仂亶 于亠仍亳亳仆
仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆
仄仂亞 亰舒亟舒于舒 仗仂仍亰仂于舒亠仍礆亳
仗亠亟仂仗亠亟亠仍亠仆仆亶 亳仗 TIME
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
BIT
仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆
{' 1', ' 0 '}
 仂亞亳亠从亳亠 仂仗亠舒亳亳
not  亳仆于亠亳;
or  仂仗亠舒亳 ;
nor  仂仗亠舒亳 -;
and  仂仗亠舒亳 ;
nand  仂仗亠舒亳 -;
xor  仆亠舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆)
xnor  舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆)
仗亠舒亳亳 仂仗亠亟亠仍亠仆 仗仂 仗舒于亳仍舒仄 仗仂仍仂亢亳亠仍仆仂亶
仍仂亞亳从亳 (a AND b 亟舒亠 亰仆舒亠仆亳亠 '1', 仂仍从仂 亠仍亳 仂弍舒 仍亠仆舒
于舒亢亠仆亳 舒于仆 '1' 亳 .亟.)
TYPE bit IS ('0', '1');
SIGNAL x,y,z: BIT;
x <= '0';
y <= '1';
z <= x and y;
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
BOOLEAN
仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆
{TRUE, FALSE}
 仂亞亳亠从亳亠 仂仗亠舒亳亳
not  亳仆于亠亳;
or  仂仗亠舒亳 ;
nor  仂仗亠舒亳 -;
and  仂仗亠舒亳 ;
nand  仂仗亠舒亳 -;
xor  仆亠舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆)
xnor  舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆)
FALSE AND '1';
TYPE boolean IS (FALSE, TRUE);
SIGNAL x,y,z: BOOLEAN;
x <= FALSE;
y <= TRUE;
z <= x and y;
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
CHARACTER
仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆
仂弍亠亟亳仆磳 于亠 亳仄于仂仍, 仂仗亠亟亠仍亠仆仆亠 于 亳仗仂仍亰亠仄仂亶
仂仗亠舒亳仂仆仆仂亶 亳亠仄亠  弍从于, 亳, 仗亠亳舒仍仆亠
亳仄于仂仍 (VHDL`87 仂仍从仂 仗亠于亠 128 亳仄于仂仍仂于 ASCII)
 亠从亠 仗仂亞舒仄仄 亳仄于仂仍仆舒 从仂仆舒仆舒 亰舒仗亳于舒亠 从舒从
舒仆亟舒仆亶 亳仄于仂仍, 亰舒从仍ム亠仆仆亶 于 仂亟亳仆舒仆亠 从舒于从亳 ('a', '
' b', ';' 亳 .亟.)
 仂亟亟亠亢亳于舒ム 仂仗亠舒亳 从仂仆从舒亠仆舒亳亳 (&)
弌亳仄于仂仍 '0' 亳 '1' 亳仄亠ム 亟于仂亶仆仂亠 仆舒亰仆舒亠仆亳亠  亳 从舒从 亳仄于仂仍,
亳 从舒从 仍仂亞亳亠从仂亠 亰仆舒亠仆亳亠.  从舒亢亟仂仄 从仂仆从亠仆仂仄 仍舒亠 亳仗
仂仗亠亟亠仍磳 亳仂亟 亳亰 从仂仆亠从舒.
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
SEVERITY_LEVEL
亳仗仂仍亰亠 仂仍从仂 于 仂仗亠舒仂亠 ASSERT
仂仗亠亟亠仍磳 仂于仆亳 束从亳亳仆仂亳損 亳舒亳亶, 于仂亰仆亳从舒ム亳 于
仗仂亠亠 仄仂亟亠仍亳仂于舒仆亳 亳亠仄
TYPE SEVERITY_LEVEL IS (
NOTE, -- just report
WARNING, -- warning and continue simulation
ERROR, -- forces simulation to stop
FAILURE -- stop simulation
);
ASSERT i < 5 REPORT
"Unexpected value, i = " & INTEGER'IMAGE(i);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
FILE_OPEN_STATUS
仗亠亟亠仍磳 仆舒弍仂 于仂亰仄仂亢仆 亰仆舒亠仆亳亶 仗亳 舒弍仂亠  舒亶仍舒仄亳
TYPE FILE_OPEN_STATUS IS (
OPEN_OK, -- File open was successful.
STATUS_ERROR, -- File object was already open.
NAME_ERROR, -- External file not found or
-- inaccessible.
MODE_ERROR -- Could not open file with
-- requested access mode.
);
VARIABLE open_status : FILE_OPEN_STATUS;
...
IF open_status /= OPEN_OK THEN
...
END If;
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
FILE_OPEN_KIND
仗亠亟亠仍磳 仆舒弍仂 亟仂仗亳仄 亰仆舒亠仆亳亶 仄仆仂亢亠于舒 亠亢亳仄仂于
仂从亳 舒亶仍仂于
TYPE FILE_OPEN_KIND IS (
READ_MODE, -- Resulting access mode is read-only.
WRITE_MODE, -- Resulting access mode is write-only.
APPEND_MODE -- Resulting access mode is write-only;
-- information is appended to the end
-- of the existing file.
);
PROCEDURE file_open (
FILE f : file_type;
external_name : IN STRING;
open_kind : IN FILE_OPEN_KIND := READ_MODE
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
STD_ULOGIC, STD_LOGIC
弌舒仆亟舒仂仄 IEEE 1164 仂仗亠亟亠仍亠仆舒 亰舒仄亠仆舒 亳仗舒 BIT 仆舒 弍仂仍亠亠
束亞亳弍从亳亶損 亳仗 STD_LOGIC (于 仂仄 亳仍亠 仗仂亰于仂仍磳 仄亠仆亳
从仂仍亳亠于仂 仂亳弍仂从 仄仂亟亠仍亳仂于舒仆亳)
丐亳仗 STD_LOGIC 磦仍磳 舒亰亠亳仄仄 (resolved) 仗仂亟亳仗仂仄
亳仗舒 STD_ULOGIC
亠 磦仍ム 仗亠亟仂仗亠亟亠仍亠仆仆仄亳 亳仗舒仄亳 亟舒仆仆, 舒 亠弍ム
磦仆仂亞仂 仗仂亟从仍ム亠仆亳 于 仗仂亠从 仗舒从亠舒 std_logic_1164
STD_ULOGIC
Unresolved
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
亳弍仍亳仂亠从舒 舒从亠
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
仂仆亳 束仍舒弍損 (weak)
亳亞仆舒仍仂于 仂仂于亠于ム
亳仂仆亳从舒仄 仍仂亞亳亠从亳
仂于仆亠亶  仗仂于亠仆仆仄
仂仗仂亳于仍亠仆亳亠仄 仗仂
舒于仆亠仆亳  仂弍仆仄亳
仍仂亞亳亠从亳仄亳 仍亠仄亠仆舒仄亳
仍 亳仆亠亰舒 仍仂亞亳亠从亳 亠仄 亳仗仂仍亰ム 仂仍从仂 亠亠:
 '0'  仍仂亞亳亠从亳亶 "0"
 '1'  仍仂亞亳亠从舒 "1"
 'Z'  束亠亠損 仂仂礌亳亠
 ''  仆亠 仗仂亟从仍ム亠仆
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
Time step 0
TYPE STD_ULOGIC IS (
'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
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
Time step 0
1 U U U
TYPE STD_ULOGIC IS (
'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
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
Time step 1
0 1 U U
TYPE STD_ULOGIC IS (
'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
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
Time step 2
1 0 1 U
TYPE STD_ULOGIC IS (
'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
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
Time step 3
1 1 0 1
TYPE STD_ULOGIC IS (
'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
);
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 3
1 1 0 1
0 1
X
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 3
1 1 0 1
0 1
X
1
0
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 4
1 1 1 X
0 0
X
1
X
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 0
1 仂亟磪亳于舒ム亳亶 亠亰亳仂
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 0
0 U H U
1 仂亟磪亳于舒ム亳亶 亠亰亳仂
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 1
1 0 H 1
1 仂亟磪亳于舒ム亳亶 亠亰亳仂
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
TYPE STD_ULOGIC IS (
'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
);
Time step 2
0 1 0 1
1
Resolution(H, 0) = 0
仂亟磪亳于舒ム亳亶 亠亰亳仂
亠亠亳仍亳仄亠 亳仗 亟舒仆仆
STD_ULOGIC, STD_LOGIC
 仗亠舒亳亳 舒亳仄亠亳亠从仂亞仂 仂仆仂亠仆亳
=, /=, <, <=, >=, >, 从仂仂亠 亟舒ム 亠亰仍舒 亳仗舒 BOOLEAN
 仂亞亳亠从亳亠 仂仗亠舒亳亳
AND, OR, XOR, 
 仗亠舒亳 从仂仆从舒亠仆舒亳亳 (仂弍亠亟亳仆亠仆亳) - &
q <= in_x WHEN sel = '1' ELSE 'Z';
SIGNAL s1, s2 : STD_LOGIC;
VARIABLE v1, v2 : STD_LOGIC;
...
s1 <= '0'; v1 := '1'; s2 <= 'X';
WAIT FOR 10 ns;
s2 <= s1 AND v1; -- '0'
v2 := s1 OR v1; -- '1'
弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠
仗仂仍亰仂于舒亠仍亠仄
弌仗仂仂弍 亰舒亟舒仆亳 从舒仍仆
亳仗仂于 亟舒仆仆
亳舒仗舒亰仂仆仂仄
(亳仍亠仆仆亠 亳仗)
弌仗亳从仂仄 亰仆舒亠仆亳亶
(仗亠亠亳仍亳仄 亳仗)
TYPE name IS type_definition;
 弌亳仆舒从亳 于 仂弍亠仄 于亳亟亠:
亳仄 亳仗舒 亰舒亟舒仆亳亠 亳仗舒
弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠
仗仂仍亰仂于舒亠仍亠仄
 舒亟舒仆亳亠 亳仗舒 仗亳从仂仄 亰仆舒亠仆亳亶:
TYPE name IS (value1, value2, , value_n);
TYPE FSM_states IS (START, STOP, IDLE);
TYPE digits IS ('1', '2', '3', '4', '5');
TYPE LED_lights IS (RED, GREEN, BLUE);
 亳仄亠:
VARIABLE led1, led2 : LED_lights := RED;

led1 := BLUE;
led2 := YELLOW;
led2 := led1;
-- 仆亠亟仂仗亳仄仂亠 亰仆舒亠仆亳亠
-- led1 亳 led2 -> BLUE
弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠
仗仂仍亰仂于舒亠仍亠仄
 舒亟舒仆亳亠 亳仗舒 亟亳舒仗舒亰仂仆仂仄 亰仆舒亠仆亳亶:
TYPE name IS RANGE expression (TO|DOWNTO) expression;
TYPE unsigned_short IS RANGE 0 TO 255;
TYPE data IS RANGE -2**(n-1)+1 to 2**(n-1)-1;
TYPE levels IS RANGE -10.0 TO 10.0;
TYPE wrong_range IS RANGE 15 TO 10; -- DOWNTO

VARIABLE curr_level : levels := 0;
CONSTANT FIXED_DATA : data := 10.0;
VARIABLE: a, b, c : unsigned_short;
c := a + b; -- 0
a := 200; b := 100;
c := a + b;
 亳仄亠:
Value 300 for c is out of range 0 to 255.
仂亟亳仗
 弍亠从, 仂仆亠亠仆仆亠 从 仗仂亟亳仗, 仂舒仆ム 仂于仄亠亳仄仂 
亟舒仆仆仄亳 弍舒亰仂于仂亞仂 亳仗舒, 仆舒 仂仆仂于亠 从仂仂仂亞仂 弍仍 仂亰亟舒仆
仗仂亟亳仗
  仂弍亠仄 仍舒亠 仗仂亟亳仗 仂亞舒仆亳亳于舒亠 亟亳舒仗舒亰仂仆 亟仂仗亳仄
亰仆舒亠仆亳亶 弍舒亰仂于仂亞仂 亳仗舒
 仗亠亟亠仍亠仆 舒从仂亶 亢亠 仆舒弍仂 亟仂仗亳仄 仂仗亠舒亳亶, 从舒从 亳 亟仍
弍舒亰仂于仂亞仂 亳仗舒
 仍 仗仂亟亳仗舒 仄仂亞 弍 于于亠亟亠仆 亟仂仗仂仍仆亳亠仍仆亠,
于仂亶于亠仆仆亠 仂仍从仂 亠仄, 仆从亳亳 仗亠仂弍舒亰仂于舒仆亳
SUBTYPE name_of_subtype IS name_of_base_subtype RANGE
simple_expression (TO|DOWNTO) simple_exression;
仄 仗仂亟亳仗舒 仄 弍舒亰仂于仂亞仂 亳仗舒
亳舒仗舒亰仂仆 亰仆舒亠仆亳亶 仗仂亟亳仗舒
仂亟亳仗
SUBTYPE short IS INTEGER RANGE 0 TO 255;
SUBTYPE word IS STD_LOGIC_VECTOR(31 DOWNTO 0);
TYPE FSM_states IS (START, RUN, STOP, IDLE, ERROR);
SUBTYPE sys_status IS FSM_states RANGE START TO STOP;
SIGNAL reg_value: short := 128;
COSNTANT MASK: word := X"0000FFFF";
VARIABLE pipeline: sys_status;
VARIABLE worker: FSM_states;
...
pipeline := RUN;
-- 仂于仄亠亳仄仂 仄亠亢亟 弍舒亰仂于仄 亳仗仂仄 亳 仗仂亟亳仗仂仄 仂舒仆亠仆舒
worker := pipeline;
worker := IDLE;
-- 仂亳弍从舒 于 仗仂亠亠 于仗仂仍仆亠仆亳, .从. 亟亳舒仗舒亰仂仆 亰仆舒亠仆亳亶
pipeline := worker; -- 仗仂亟亳仗舒 仆亠 于从仍ム舒亠 亰仆舒亠仆亳亠 IDLE
-- 亰舒仗亠亠仆仂, .从. 亰仆舒亠仆亳亠 ERROR 仆亠 于仂亟亳 于
-- 亟亳舒仗舒亰仂仆 亰仆舒亠仆亳亶 仗仂亟亳仗舒 sys_status
pipeline := ERROR;
仂亟亳仗
-- 'HIGH  舒亳弍 从舒仍仆仂亞仂 亳仗舒, 从仂仂亶 仂仗亠亟亠仍磳
-- 仄舒从亳仄舒仍仆仂亠 亰仆舒亠仆亳亠 于 亳仗亠 (仄. 舒亳弍)
SUBTYPE natural IS INTEGER RANGE 0 TO INTEGER'HIGH;
SUBTYPE positive IS INTEGER RANGE 1 TO INTEGER'HIGH;
SUBTYPE delay_length IS TIME RANGE 0 FS TO TIME'HIGH
  磶从亠 VHDL 亳仄亠ム 仗亠亟仂仗亠亟亠仍亠仆仆亠 仗仂亟亳仗
 舒亰仂于亶 亳仗 亳 仂亞舒仆亳亠仆亳亠 亟亳舒仗舒亰仂仆舒 仄仂亞 弍
亰舒亟舒仆 仆亠仗仂亠亟于亠仆仆仂 仗亳 仂弍磦仍亠仆亳亳 仂弍亠从舒:
VARIABLE pipeline: FSM_states RANGE START TO STOP;
SIGNAL reg_value: INTEGER RANGE 0 TO 255;
--  仗仂亟亳仗仂于 仂亢亠 仄仂亞 弍 仗仂亟亳仗
VARIABLE symbol IS NATURAL RANGE 0 TO 255;
PORT(clk : IN STD_LOGIC;
cnt_out: OUT INTEGER RANGE 0 TO 9);
VHDL data types, user-defined types, subtypes

More Related Content

VHDL data types, user-defined types, subtypes

  • 1. 仍舒仆仂于 .. [v.kulanov@csn.khai.edu] 丐亳仗 亟舒仆仆 于 磶从亠 仂仗亳舒仆亳 舒仗仗舒舒 VHDL 束丐亠仆仂仍仂亞亳亳 仗仂亠从亳仂于舒仆亳 从仂仄仗ム亠仆 亳亠仄損
  • 2. 丼仂 舒从仂亠 束亳仗 亟舒仆仆損? 丐亳仗 亟舒仆仆 (亳仗) 仄仆仂亢亠于仂 亰仆舒亠仆亳亶 亳 仂仗亠舒亳亶 仆舒 亳 亰仆舒亠仆亳 (IEEE Std 1320.2-1998). 丐亳仗 亟舒仆仆 舒舒从亠亳亰亠 仂亟仆仂于亠仄亠仆仆仂: 仄仆仂亢亠于仂 亟仂仗亳仄 亰仆舒亠仆亳亶, 从仂仂亠 仄仂亞 仗亳仆亳仄舒 亟舒仆仆亠, 仗亳仆舒亟仍亠亢舒亳亠 从 仂仄 亳仗; 仆舒弍仂 仂仗亠舒亳亶, 从仂仂亠 仄仂亢仆仂 仂亠于仍 仆舒亟 亟舒仆仆仄亳, 仗亳仆舒亟仍亠亢舒亳仄亳 从 仂仄 亳仗.
  • 3. 丐亳仗 亟舒仆仆 于 磶从亠 VHDL 亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆 + = + =
  • 4. 丐亳仗 亟舒仆仆 于 磶从亠 VHDL 亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆 VARIABLE counter: INTEGER := 0; VARIABLE step: INTEGER := 0; VARIABLE offset: NATURAL := 0; SIGNAL z_flag : BIT; counter := counter + 1; counter := counter + step; counter := offset; counter <= 5; z_flag <= 1; z_flag <= 0; counter := step + offset;
  • 5. 丐亳仗 亟舒仆仆 于 磶从亠 VHDL 亊亰从 VHDL 仂仆仂于舒仆 仆舒 仂亞仂亶 亳仗亳亰舒亳亳 亟舒仆仆 TYPE state1 IS (IDLE, ERROR, GO); TYPE state2 IS (IDLE, ERROR, GO); VARIABLE sys1_state, sys2_state: state1; VARIABLE module_state: state2; sys1_state := ERROR; sys2_state := GO; sys2_state := ERROR; module_state := IDLE; sys1_state := module_state;
  • 6. 丐亳仗 亟舒仆仆 于 磶从亠 VHDL 亠亟仂仗亠亟亠仍亠仆仆亠 亳仗 亟舒仆仆 仗亠亟亠仍亠仆 于 舒仆亟舒舒 IEEE 1076 亠 亠弍亠 仗仂亟从仍ム亠仆亳 仂仂仆仆亳 仗舒从亠仂于/弍亳弍仍亳仂亠从 舒仂亟 于 仗舒从亠亠 STANDARD 亳 TEXTIO (弍亳弍仍亳仂亠从舒 STD), 从仂仂亶 仗仂亟从仍ム舒亠 仆亠磦仆仂 丐亳仗 亟舒仆仆 于于仂亟亳仄亠 仗仂仍亰仂于舒亠仍亠仄 仗亠亟亠仍亠仆 于 仗仂仍亰仂于舒亠仍从亳 亳 亟亞亳 仂仂仆仆亳 仗舒从亠舒/弍亳弍仍亳仂亠从舒 亳 亳仗仂仍亰仂于舒仆亳亳 仆亠仂弍仂亟亳仄仂 磦仆仂 从舒亰于舒 仗仂亟从仍ム舒亠仄亠 仗舒从亠/弍亳弍仍亳仂亠从亳 弍磶舒亠仍仆仂 亟仂仍亢仆 弍 亳亰于亠仆 仆舒 舒仗亠 亟亠从仍舒舒亳亳 仂弍亠从仂于 磶从舒 (仗亠亠仄亠仆仆, 亳亞仆舒仍仂于, 从仂仆舒仆 亳 .亟.)
  • 8. 丼亳仍亠仆仆亠 亳仗 亟舒仆仆 INTEGER а亠仍仂亳仍亠仆仆亶 亳仗 亟舒仆仆 {-231+1, +231-1} (-2 147 483 647 亟仂 2 147 483 647) REAL 亟亠亶于亳亠仍仆亶 亳仗 亟舒仆仆 {-238, +238} CONSTANT PI : REAL := 3.14159; CONSTANT HALF_PI : REAL := Pi/2.0; CONSTANT N, N5 : INTEGER := 5; VARIABLE count : INTEGER := 0; VARIABLE flag : INTEGER := 1.5;
  • 9. 丼亳仍亠仆仆亠 亳仗 亟舒仆仆 亳仄亠亳亠从亳亠 仂仗亠舒亳亳 束+損 仍仂亢亠仆亳亠 亳仍亳 仗仂于仂亠仆亳亠; 束-損 于亳舒仆亳亠 亳仍亳 亳仆于亠亳; 束*損 - 仄仆仂亢亠仆亳亠; 束/損 - 亟亠仍亠仆亳亠; mod 亳仍仂 仗仂 仄仂亟仍 (5 mod 3 = 2); rem 仂舒仂从 仂 亟亠仍亠仆亳; abs 仄仂亟仍 (舒弍仂仍ム仆仂亠 亰仆舒亠仆亳亳 亳仍舒); ** - 于仂亰于亠亟亠仆亳亠 于 亠仗亠仆. 仗亠舒亳亳 舒亳仄亠亳亠从仂亞仂 仂仆仂亠仆亳 =, /=, <, <=, >=, >, 从仂仂亠 亟舒ム 亠亰仍舒 亳仗舒 BOOLEAN CONSTANT DATA_WIDTH: NATURAL := 8; VARIABLE address_width: NATURAL := 2**DATA_WIDTH;
  • 10. 个亳亰亳亠从亳亠 亳仗 亟舒仆仆 TYPE TIME IS RANGE -2147483647 TO 2147483647 UNITS fs; -- femtosecond ps = 1000 fs; -- picosecond ns = 1000 ps; -- nanosecond us = 1000 ns; -- microsecond ms = 1000 us; -- millisecond sec = 1000 ms; -- second min = 60 sec; -- minute hr = 60 min; -- hour END UNITS; 仗亠亟舒于仍磳 亠仍仄 亳仍仂仄, 亠亟亳仆亳舒 从仂仂仂亞仂 亳仄亠亠 于亠 亠亟亳仆亳 亳亰仄亠亠仆亳 仆亠从仂仂仂亶 亳亰亳亠从仂亶 于亠仍亳亳仆 仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆 仄仂亞 亰舒亟舒于舒 仗仂仍亰仂于舒亠仍礆亳 仗亠亟仂仗亠亟亠仍亠仆仆亶 亳仗 TIME
  • 11. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 BIT 仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆 {' 1', ' 0 '} 仂亞亳亠从亳亠 仂仗亠舒亳亳 not 亳仆于亠亳; or 仂仗亠舒亳 ; nor 仂仗亠舒亳 -; and 仂仗亠舒亳 ; nand 仂仗亠舒亳 -; xor 仆亠舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆) xnor 舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆) 仗亠舒亳亳 仂仗亠亟亠仍亠仆 仗仂 仗舒于亳仍舒仄 仗仂仍仂亢亳亠仍仆仂亶 仍仂亞亳从亳 (a AND b 亟舒亠 亰仆舒亠仆亳亠 '1', 仂仍从仂 亠仍亳 仂弍舒 仍亠仆舒 于舒亢亠仆亳 舒于仆 '1' 亳 .亟.) TYPE bit IS ('0', '1'); SIGNAL x,y,z: BIT; x <= '0'; y <= '1'; z <= x and y;
  • 12. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 BOOLEAN 仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆 {TRUE, FALSE} 仂亞亳亠从亳亠 仂仗亠舒亳亳 not 亳仆于亠亳; or 仂仗亠舒亳 ; nor 仂仗亠舒亳 -; and 仂仗亠舒亳 ; nand 仂仗亠舒亳 -; xor 仆亠舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆) xnor 舒于仆仂亰仆舒仆仂; (VHDL`87 仆亠 仂仗亠亟亠仍亠仆) FALSE AND '1'; TYPE boolean IS (FALSE, TRUE); SIGNAL x,y,z: BOOLEAN; x <= FALSE; y <= TRUE; z <= x and y;
  • 13. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 CHARACTER 仗亠亠亳仍亳仄亶 亳仗 亟舒仆仆 仂弍亠亟亳仆磳 于亠 亳仄于仂仍, 仂仗亠亟亠仍亠仆仆亠 于 亳仗仂仍亰亠仄仂亶 仂仗亠舒亳仂仆仆仂亶 亳亠仄亠 弍从于, 亳, 仗亠亳舒仍仆亠 亳仄于仂仍 (VHDL`87 仂仍从仂 仗亠于亠 128 亳仄于仂仍仂于 ASCII) 亠从亠 仗仂亞舒仄仄 亳仄于仂仍仆舒 从仂仆舒仆舒 亰舒仗亳于舒亠 从舒从 舒仆亟舒仆亶 亳仄于仂仍, 亰舒从仍ム亠仆仆亶 于 仂亟亳仆舒仆亠 从舒于从亳 ('a', ' ' b', ';' 亳 .亟.) 仂亟亟亠亢亳于舒ム 仂仗亠舒亳 从仂仆从舒亠仆舒亳亳 (&) 弌亳仄于仂仍 '0' 亳 '1' 亳仄亠ム 亟于仂亶仆仂亠 仆舒亰仆舒亠仆亳亠 亳 从舒从 亳仄于仂仍, 亳 从舒从 仍仂亞亳亠从仂亠 亰仆舒亠仆亳亠. 从舒亢亟仂仄 从仂仆从亠仆仂仄 仍舒亠 亳仗 仂仗亠亟亠仍磳 亳仂亟 亳亰 从仂仆亠从舒.
  • 14. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 SEVERITY_LEVEL 亳仗仂仍亰亠 仂仍从仂 于 仂仗亠舒仂亠 ASSERT 仂仗亠亟亠仍磳 仂于仆亳 束从亳亳仆仂亳損 亳舒亳亶, 于仂亰仆亳从舒ム亳 于 仗仂亠亠 仄仂亟亠仍亳仂于舒仆亳 亳亠仄 TYPE SEVERITY_LEVEL IS ( NOTE, -- just report WARNING, -- warning and continue simulation ERROR, -- forces simulation to stop FAILURE -- stop simulation ); ASSERT i < 5 REPORT "Unexpected value, i = " & INTEGER'IMAGE(i);
  • 15. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 FILE_OPEN_STATUS 仗亠亟亠仍磳 仆舒弍仂 于仂亰仄仂亢仆 亰仆舒亠仆亳亶 仗亳 舒弍仂亠 舒亶仍舒仄亳 TYPE FILE_OPEN_STATUS IS ( OPEN_OK, -- File open was successful. STATUS_ERROR, -- File object was already open. NAME_ERROR, -- External file not found or -- inaccessible. MODE_ERROR -- Could not open file with -- requested access mode. ); VARIABLE open_status : FILE_OPEN_STATUS; ... IF open_status /= OPEN_OK THEN ... END If;
  • 16. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 FILE_OPEN_KIND 仗亠亟亠仍磳 仆舒弍仂 亟仂仗亳仄 亰仆舒亠仆亳亶 仄仆仂亢亠于舒 亠亢亳仄仂于 仂从亳 舒亶仍仂于 TYPE FILE_OPEN_KIND IS ( READ_MODE, -- Resulting access mode is read-only. WRITE_MODE, -- Resulting access mode is write-only. APPEND_MODE -- Resulting access mode is write-only; -- information is appended to the end -- of the existing file. ); PROCEDURE file_open ( FILE f : file_type; external_name : IN STRING; open_kind : IN FILE_OPEN_KIND := READ_MODE );
  • 17. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 STD_ULOGIC, STD_LOGIC 弌舒仆亟舒仂仄 IEEE 1164 仂仗亠亟亠仍亠仆舒 亰舒仄亠仆舒 亳仗舒 BIT 仆舒 弍仂仍亠亠 束亞亳弍从亳亶損 亳仗 STD_LOGIC (于 仂仄 亳仍亠 仗仂亰于仂仍磳 仄亠仆亳 从仂仍亳亠于仂 仂亳弍仂从 仄仂亟亠仍亳仂于舒仆亳) 丐亳仗 STD_LOGIC 磦仍磳 舒亰亠亳仄仄 (resolved) 仗仂亟亳仗仂仄 亳仗舒 STD_ULOGIC 亠 磦仍ム 仗亠亟仂仗亠亟亠仍亠仆仆仄亳 亳仗舒仄亳 亟舒仆仆, 舒 亠弍ム 磦仆仂亞仂 仗仂亟从仍ム亠仆亳 于 仗仂亠从 仗舒从亠舒 std_logic_1164 STD_ULOGIC Unresolved LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; 亳弍仍亳仂亠从舒 舒从亠
  • 18. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); 仂仆亳 束仍舒弍損 (weak) 亳亞仆舒仍仂于 仂仂于亠于ム 亳仂仆亳从舒仄 仍仂亞亳亠从亳 仂于仆亠亶 仗仂于亠仆仆仄 仂仗仂亳于仍亠仆亳亠仄 仗仂 舒于仆亠仆亳 仂弍仆仄亳 仍仂亞亳亠从亳仄亳 仍亠仄亠仆舒仄亳 仍 亳仆亠亰舒 仍仂亞亳亠从亳 亠仄 亳仗仂仍亰ム 仂仍从仂 亠亠: '0' 仍仂亞亳亠从亳亶 "0" '1' 仍仂亞亳亠从舒 "1" 'Z' 束亠亠損 仂仂礌亳亠 '' 仆亠 仗仂亟从仍ム亠仆
  • 19. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 Time step 0 TYPE STD_ULOGIC IS ( '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 );
  • 20. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 Time step 0 1 U U U TYPE STD_ULOGIC IS ( '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 );
  • 21. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 Time step 1 0 1 U U TYPE STD_ULOGIC IS ( '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 );
  • 22. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 Time step 2 1 0 1 U TYPE STD_ULOGIC IS ( '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 );
  • 23. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 Time step 3 1 1 0 1 TYPE STD_ULOGIC IS ( '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 );
  • 24. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 3 1 1 0 1 0 1 X
  • 25. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 3 1 1 0 1 0 1 X 1 0
  • 26. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 4 1 1 1 X 0 0 X 1 X
  • 27. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 0 1 仂亟磪亳于舒ム亳亶 亠亰亳仂
  • 28. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 0 0 U H U 1 仂亟磪亳于舒ム亳亶 亠亰亳仂
  • 29. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 1 1 0 H 1 1 仂亟磪亳于舒ム亳亶 亠亰亳仂
  • 30. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 TYPE STD_ULOGIC IS ( '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 ); Time step 2 0 1 0 1 1 Resolution(H, 0) = 0 仂亟磪亳于舒ム亳亶 亠亰亳仂
  • 31. 亠亠亳仍亳仄亠 亳仗 亟舒仆仆 STD_ULOGIC, STD_LOGIC 仗亠舒亳亳 舒亳仄亠亳亠从仂亞仂 仂仆仂亠仆亳 =, /=, <, <=, >=, >, 从仂仂亠 亟舒ム 亠亰仍舒 亳仗舒 BOOLEAN 仂亞亳亠从亳亠 仂仗亠舒亳亳 AND, OR, XOR, 仗亠舒亳 从仂仆从舒亠仆舒亳亳 (仂弍亠亟亳仆亠仆亳) - & q <= in_x WHEN sel = '1' ELSE 'Z'; SIGNAL s1, s2 : STD_LOGIC; VARIABLE v1, v2 : STD_LOGIC; ... s1 <= '0'; v1 := '1'; s2 <= 'X'; WAIT FOR 10 ns; s2 <= s1 AND v1; -- '0' v2 := s1 OR v1; -- '1'
  • 32. 弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠 仗仂仍亰仂于舒亠仍亠仄 弌仗仂仂弍 亰舒亟舒仆亳 从舒仍仆 亳仗仂于 亟舒仆仆 亳舒仗舒亰仂仆仂仄 (亳仍亠仆仆亠 亳仗) 弌仗亳从仂仄 亰仆舒亠仆亳亶 (仗亠亠亳仍亳仄 亳仗) TYPE name IS type_definition; 弌亳仆舒从亳 于 仂弍亠仄 于亳亟亠: 亳仄 亳仗舒 亰舒亟舒仆亳亠 亳仗舒
  • 33. 弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠 仗仂仍亰仂于舒亠仍亠仄 舒亟舒仆亳亠 亳仗舒 仗亳从仂仄 亰仆舒亠仆亳亶: TYPE name IS (value1, value2, , value_n); TYPE FSM_states IS (START, STOP, IDLE); TYPE digits IS ('1', '2', '3', '4', '5'); TYPE LED_lights IS (RED, GREEN, BLUE); 亳仄亠: VARIABLE led1, led2 : LED_lights := RED; led1 := BLUE; led2 := YELLOW; led2 := led1; -- 仆亠亟仂仗亳仄仂亠 亰仆舒亠仆亳亠 -- led1 亳 led2 -> BLUE
  • 34. 弌从舒仍仆亠 亳仗 亟舒仆仆, 于于仂亟亳仄亠 仗仂仍亰仂于舒亠仍亠仄 舒亟舒仆亳亠 亳仗舒 亟亳舒仗舒亰仂仆仂仄 亰仆舒亠仆亳亶: TYPE name IS RANGE expression (TO|DOWNTO) expression; TYPE unsigned_short IS RANGE 0 TO 255; TYPE data IS RANGE -2**(n-1)+1 to 2**(n-1)-1; TYPE levels IS RANGE -10.0 TO 10.0; TYPE wrong_range IS RANGE 15 TO 10; -- DOWNTO VARIABLE curr_level : levels := 0; CONSTANT FIXED_DATA : data := 10.0; VARIABLE: a, b, c : unsigned_short; c := a + b; -- 0 a := 200; b := 100; c := a + b; 亳仄亠: Value 300 for c is out of range 0 to 255.
  • 35. 仂亟亳仗 弍亠从, 仂仆亠亠仆仆亠 从 仗仂亟亳仗, 仂舒仆ム 仂于仄亠亳仄仂 亟舒仆仆仄亳 弍舒亰仂于仂亞仂 亳仗舒, 仆舒 仂仆仂于亠 从仂仂仂亞仂 弍仍 仂亰亟舒仆 仗仂亟亳仗 仂弍亠仄 仍舒亠 仗仂亟亳仗 仂亞舒仆亳亳于舒亠 亟亳舒仗舒亰仂仆 亟仂仗亳仄 亰仆舒亠仆亳亶 弍舒亰仂于仂亞仂 亳仗舒 仗亠亟亠仍亠仆 舒从仂亶 亢亠 仆舒弍仂 亟仂仗亳仄 仂仗亠舒亳亶, 从舒从 亳 亟仍 弍舒亰仂于仂亞仂 亳仗舒 仍 仗仂亟亳仗舒 仄仂亞 弍 于于亠亟亠仆 亟仂仗仂仍仆亳亠仍仆亠, 于仂亶于亠仆仆亠 仂仍从仂 亠仄, 仆从亳亳 仗亠仂弍舒亰仂于舒仆亳 SUBTYPE name_of_subtype IS name_of_base_subtype RANGE simple_expression (TO|DOWNTO) simple_exression; 仄 仗仂亟亳仗舒 仄 弍舒亰仂于仂亞仂 亳仗舒 亳舒仗舒亰仂仆 亰仆舒亠仆亳亶 仗仂亟亳仗舒
  • 36. 仂亟亳仗 SUBTYPE short IS INTEGER RANGE 0 TO 255; SUBTYPE word IS STD_LOGIC_VECTOR(31 DOWNTO 0); TYPE FSM_states IS (START, RUN, STOP, IDLE, ERROR); SUBTYPE sys_status IS FSM_states RANGE START TO STOP; SIGNAL reg_value: short := 128; COSNTANT MASK: word := X"0000FFFF"; VARIABLE pipeline: sys_status; VARIABLE worker: FSM_states; ... pipeline := RUN; -- 仂于仄亠亳仄仂 仄亠亢亟 弍舒亰仂于仄 亳仗仂仄 亳 仗仂亟亳仗仂仄 仂舒仆亠仆舒 worker := pipeline; worker := IDLE; -- 仂亳弍从舒 于 仗仂亠亠 于仗仂仍仆亠仆亳, .从. 亟亳舒仗舒亰仂仆 亰仆舒亠仆亳亶 pipeline := worker; -- 仗仂亟亳仗舒 仆亠 于从仍ム舒亠 亰仆舒亠仆亳亠 IDLE -- 亰舒仗亠亠仆仂, .从. 亰仆舒亠仆亳亠 ERROR 仆亠 于仂亟亳 于 -- 亟亳舒仗舒亰仂仆 亰仆舒亠仆亳亶 仗仂亟亳仗舒 sys_status pipeline := ERROR;
  • 37. 仂亟亳仗 -- 'HIGH 舒亳弍 从舒仍仆仂亞仂 亳仗舒, 从仂仂亶 仂仗亠亟亠仍磳 -- 仄舒从亳仄舒仍仆仂亠 亰仆舒亠仆亳亠 于 亳仗亠 (仄. 舒亳弍) SUBTYPE natural IS INTEGER RANGE 0 TO INTEGER'HIGH; SUBTYPE positive IS INTEGER RANGE 1 TO INTEGER'HIGH; SUBTYPE delay_length IS TIME RANGE 0 FS TO TIME'HIGH 磶从亠 VHDL 亳仄亠ム 仗亠亟仂仗亠亟亠仍亠仆仆亠 仗仂亟亳仗 舒亰仂于亶 亳仗 亳 仂亞舒仆亳亠仆亳亠 亟亳舒仗舒亰仂仆舒 仄仂亞 弍 亰舒亟舒仆 仆亠仗仂亠亟于亠仆仆仂 仗亳 仂弍磦仍亠仆亳亳 仂弍亠从舒: VARIABLE pipeline: FSM_states RANGE START TO STOP; SIGNAL reg_value: INTEGER RANGE 0 TO 255; -- 仗仂亟亳仗仂于 仂亢亠 仄仂亞 弍 仗仂亟亳仗 VARIABLE symbol IS NATURAL RANGE 0 TO 255; PORT(clk : IN STD_LOGIC; cnt_out: OUT INTEGER RANGE 0 TO 9);