Professional Documents
Culture Documents
B
ENTITY and2 IS
PORT ( a, b : IN BIT;
c : OUT BIT );
END and2
VHDL Format : Entity (2)
Ex 2. I0
Q
I1
I2
I3
A B
ENTITY mux4 IS
PORT ( i0, i1, i2, i3, a, b : IN std_logic; → PORT ( i0, i1, i2, i3 : IN std_logic;
q : OUT std_logic ); a, b : IN std_logic;
END mux4
Input-Output specification of circuit
Example: my_ckt
Inputs: A, B, C
Outputs: X, Y
A
VHDL description:
X
B my_ckt entity my_ckt is
Y port (
S A: in bit;
B: in bit;
S: in bit;
X: out bit;
Y: out bit);
end my_ckt ;
9
VHDL entity
11
User-defined datatype
12
VHDL as a language
strongly typed
• type check at compile time
• allows user defined types
• case insensitive
• two consecutive dashes (--) is used for comment
Level of Abstraction in VHDL
if Sel == 0
A Y <= A;
B Y else
Sel Y <= B;
The block diagram of mux
ENTITY mux is …
Example:
ARCHITECTURE dataflow OF mux IS
BEGIN
…
END dataflow;
Dataflow
-- y : target signal
-- <= : signal assignment operator
• six logical operators are
• AND OR NAND NOR XOR NOT
• relational operators
• =, /=, <, <=, >, >=
Dataflow
ENTITY mux_df IS
PORT (a, b, sel: in bit;
y: out bit);
END mux_df;
Entity mux2_df is
PORT ( data : in BIT_VECTOR(3 DOWNTO 0);
sel: in INTEGER RANGE 0 to 3;
f: out bit);
END mux2_df;
a0 s0
a1 s1
a2 s2
s3
decoder
s4
s5
s6
s7
Dataflow
library ieee;
use ieee.std_logic_1164.all;
entity dcd_3_8 is
port ( a: in std_logic_vector(2 downto 0);
s: out std_logic_vector(7 downto 0)
);
end dcd_3_8;
ENTITY mux_df2 IS
port ( a, b, sel : in bit;
y : out bit );
END mux_df2;
Example:
• Behavior for output X:
• When S = 0 A
X <= A X
• When S = 1 B my_ckt
X <= B Y
S
• Behavior for output Y:
• When X = 0 and S =0
Y <= ‘1’
• Else
Y <= ‘0’
27
VHDL Architecture
29