-
Notifications
You must be signed in to change notification settings - Fork 1
/
Simple Combinational Circuit VHDL .txt
89 lines (83 loc) · 2.13 KB
/
Simple Combinational Circuit VHDL .txt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
## SIMPLE COMBINATIONAL CIRCUIT IMPLEMENTATION FOR BEGINEERS
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity masterswitch is
Port (Msw: in std_logic;
sw1: in std_logic;
sw2: in std_logic;
LED1: out std_logic;
LED2: out std_logic );
end masterswitch;
architecture Behavioral of masterswitch is
begin
LED1 <= Msw And sw1;
LED2 <= Msw And sw2;
end Behavioral;
Test Bench Code:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity tb_msw is
end tb_msw;
architecture Behavioral of tb_msw is
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT masterswitch
Port (Msw: in std_logic;
sw1: in std_logic;
sw2: in std_logic;
LED1: out std_logic;
LED2: out std_logic );
END COMPONENT;
--Inputs
signal Msw : std_logic := '0';
signal sw1 : std_logic := '0';
signal sw2 : std_logic := '0';
--Outputs
signal LED1 : std_logic;
signal LED2 : std_logic;
begin
-- Instantiate the Unit Under Test (UUT)
uut: masterswitch PORT MAP (
Msw => Msw,
sw1 => sw1,
sw2 => sw2,
LED1 => LED1,
LED2 => LED2
);
-- Stimulus process
stim_proc: process
begin
Msw<='0';sw1<='0';sw2<='0';
wait for 100ns;
Msw<='0';sw1<='0';sw2<='1';
wait for 100ns;
Msw<='0';sw1<='1';sw2<='0';
wait for 100ns;
Msw<='0';sw1<='1';sw2<='1';
wait for 100ns;
Msw<='1';sw1<='0';sw2<='0';
wait for 100ns;
Msw<='1';sw1<='0';sw2<='1';
wait for 100ns;
Msw<='1';sw1<='1';sw2<='0';
wait for 100ns;
Msw<='1';sw1<='1';sw2<='1';
wait for 100ns;
end process;
END;
Constraints:
For Inputs:
set_property PACKAGE_PIN V16 [get_ports {sw1}]
set_property IOSTANDARD LVCMOS33 [get_ports {sw1}]
set_property PACKAGE_PIN W16 [get_ports {sw2}]
set_property IOSTANDARD LVCMOS33 [get_ports {sw2}]
set_property PACKAGE_PIN W17 [get_ports {Msw}]
set_property IOSTANDARD LVCMOS33 [get_ports {Msw}]
For Outputs:
set_property PACKAGE_PIN U16 [get_ports {LED1}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED1}]
set_property PACKAGE_PIN E19 [get_ports {LED2}]
set_property IOSTANDARD LVCMOS33 [get_ports {LED2}]