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;
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
);
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.
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);