1 vhdl comment ------------------------------------------------------------
2 vhdl comment -- Combinational Logic Design
3 vhdl comment -- (ESD book figure 2.4)
4 vhdl comment -- by Weijun Zhang, 04/2001
6 vhdl comment -- A simple example of VHDL Structure Modeling
7 vhdl comment -- we might define two components in two separate files,
8 vhdl comment -- in main file, we use port map statement to instantiate
9 vhdl comment -- the mapping relationship between each components
10 vhdl comment -- and the entire circuit.
11 vhdl comment ------------------------------------------------------------
13 vhdl code library ieee; -- component #1
14 vhdl code use ieee.std_logic_1164.all;
16 vhdl code entity OR_GATE is
17 vhdl code port( X: in std_logic;
18 vhdl code Y: in std_logic;
19 vhdl code F2: out std_logic
21 vhdl code end OR_GATE;
23 vhdl code architecture behv of OR_GATE is
25 vhdl code process(X,Y)
27 vhdl code F2 <= X or Y; -- behavior des.
28 vhdl code end process;
31 vhdl comment -------------------------------------------------------------
33 vhdl code library ieee; -- component #2
34 vhdl code use ieee.std_logic_1164.all;
36 vhdl code entity AND_GATE is
37 vhdl code port( A: in std_logic;
38 vhdl code B: in std_logic;
39 vhdl code F1: out std_logic
41 vhdl code end AND_GATE;
43 vhdl code architecture behv of AND_GATE is
45 vhdl code process(A,B)
47 vhdl code F1 <= A and B; -- behavior des.
48 vhdl code end process;
51 vhdl comment --------------------------------------------------------------
53 vhdl code library ieee; -- top level circuit
54 vhdl code use ieee.std_logic_1164.all;
55 vhdl code use work.all;
57 vhdl code entity comb_ckt is
58 vhdl code port( input1: in std_logic;
59 vhdl code input2: in std_logic;
60 vhdl code input3: in std_logic;
61 vhdl code output: out std_logic
63 vhdl code end comb_ckt;
65 vhdl code architecture struct of comb_ckt is
67 vhdl code component AND_GATE is -- as entity of AND_GATE
68 vhdl code port( A: in std_logic;
69 vhdl code B: in std_logic;
70 vhdl code F1: out std_logic
72 vhdl code end component;
74 vhdl code component OR_GATE is -- as entity of OR_GATE
75 vhdl code port( X: in std_logic;
76 vhdl code Y: in std_logic;
77 vhdl code F2: out std_logic
79 vhdl code end component;
81 vhdl code signal wire: std_logic; -- signal just like wire
85 vhdl comment -- use sign "=>" to clarify the pin mapping
87 vhdl code Gate1: AND_GATE port map (A=>input1, B=>input2, F1=>wire);
88 vhdl code Gate2: OR_GATE port map (X=>wire, Y=>input3, F2=>output);
92 vhdl comment ----------------------------------------------------------------