-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_logic_tb.vhdl
42 lines (34 loc) · 1.08 KB
/
std_logic_tb.vhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- VHDL 2008 (informative) G.2 Using the STD_LOGIC_1164 package
-- http://electronics.stackexchange.com/questions/51848/when-to-use-std-logic-over-bit-in-vhdl/241653#241653
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all; -- unsigned
entity std_logic_tb is
end std_logic_tb;
architecture behav of std_logic_tb is
signal s0 : std_logic;
signal s1 : bit;
signal my_std_logic_vector : std_logic_vector (0 to 2);
begin
s0 <= '0';
s0 <= '1';
s1 <= '0';
-- Simulation error.
--s1 <= '1';
process
begin
wait for 1 ns;
assert s0 = 'X';
-- # std_logic_vector
-- TYPE std_logic_vector IS ARRAY ( NATURAL RANGE <>) OF std_logic;
-- Initialize.
my_std_logic_vector <= "01X";
wait for 1 ns;
assert my_std_logic_vector(0) = '0';
assert my_std_logic_vector(1) = '1';
assert my_std_logic_vector(2) = 'X';
-- To unsigned / signed.
assert unsigned(std_logic_vector'(B"011")) + 1 = 4;
wait;
end process;
end behav;