Documente Academic
Documente Profesional
Documente Cultură
COMBINATIONAL DESIGN
TOPICS
Dataflow Style Behavioral Style
Lookup tables
OPERATORS
VHDL operators listed from higher to lower
precedence
Miscellaneous ** abs not
Multiplying * / mod rem
Sign + -
Adding + - &
Shift sll srl sla sra rol ror
Relational = /= < <= > >=
Logical and or nand nor xor xnor
LOGICAL OPERATORS
A B not A A and B A nand B A or B A nor B A xor B A xnor B
0 0 1 0 1 0 1 0 1
0 1 1 0 1 1 0 1 0
1 0 0 0 1 1 0 1 0
1 1 0 1 0 1 0 0 1
entity mux4to1 is
Port ( I : in STD_LOGIC_VECTOR
(3 downto 0);
S : in STD_LOGIC_VECTOR
(1 downto 0);
nE : in STD_LOGIC;
Y : out STD_LOGIC);
end mux4to1;
EXAMPLE: 4-TO-1 MULTIPLEXER
Concurrent signal assignment using Boolean
expression:
I3 I2 I1 I0 A1 A0
X X X 1 0 0
X X 1 0 0 1
X 1 0 0 1 0
1 0 0 0 1 1
EXAMPLE: PRIORITY ENCODER
entity PEncoder is
Port ( I : in STD_LOGIC_VECTOR (3 downto 0);
A : out STD_LOGIC_VECTOR (1 downto 0));
end PEncoder;
decoder3to8
A(3)
G1 D(8)
nG2A
nG2B
SEATWORK 3-1
2. Given the entity diagram, create a dataflow
VHDL description of a 8-input priority encoder.
Use conditional signal assignment with don’t care
conditions and std_match function. (Note: Follow
the truth table of the 74LS148 for the behavior of
the system).
PEncoder
nI(8) nGS
nE A(3)
nEO
LOOKUP TABLE
A simple way to describe a combinational system
For single output systems, use a constant vector
If statement
Loop statement
Variables
COMPARISON: HALF ADDER
Dataflow Behavioral
[ process_label: ]
process [(sensitivity_list)] is
{ process_declarative_item }
begin
{ sequential_statement }
end process [ process_label ];
PROCESS STATEMENT
Can be used to define combinational and
sequential systems
No signals can be declared in a process.
wait If
assertion loop
report next
return
CASE STATEMENT
It is appropriate to use this statement when the
selection can be based on the value of a single
expression
Equivalent to a concurrent selected signal
assignment statement
Syntax:
case expression is
when choices => sequence_of_statements
{ when choices => sequence_of_statements }
end case [ case_level ];
EXAMPLE: XOR_CASE
entity XOR_case is
Port ( A, B : in STD_LOGIC;
C : out STD_LOGIC);
end XOR_case;
architecture Behavioral of XOR_case is
begin
process(A, B)
begin
case std_logic_vector'(A,B) is
when "01" | "10" => C <= '1';
when others => C <= '0';
end case;
end process;
end Behavioral;
EXAMPLE: DECODE
architecture Behavioral of decode is
begin
casey: process(g_bar, a, b)
begin
y0 <= '1'; y1 <= '1'; y2 <= '1'; y3 <= '1';
case std_logic_vector'(g_bar, a, b) is
g_bar y0 when "000" => y0 <= '0';
a y1 when "001" => y1 <= '0';
b y2 when "010" => y2 <= '0';
decode when "011" => y3 <= '0';
y3
(Behavioral) when others =>null;
end case;
end process;
end Behavioral;
SIMULATION OUTPUT (W/ INITIALIZATION)
SIMULATION OUTPUT
(W/O INITIALIZATION)
SEATWORK 3-3
Problem statement Truth table
if condition then
sequence_of_statements
{elsif condition then
sequence_of_statements
end if [if_label];
EXAMPLE: XOR_IF
entity XOR_if is
Port ( A, B : in STD_LOGIC;
C : out STD_LOGIC);
end XOR_if;
architecture Behavioral of XOR_if is
begin
process(A, B)
begin
if A /= B then -- C <= ‘0’;
C <= '1';
else -- if A /= B then
C <= '0'; -- C <= ‘1’;
end if;
end process;
end Behavioral;
EXAMPLE: DECODE
architecture Behavioral2 of decode is
begin
iffy: process(g_bar, a, b)
begin
y0 <= '1'; y1 <= '1'; y2 <= '1'; y3 <= '1';
if (g_bar = '0') then
if ((a = '0') and (b = '0')) then y0 <= '0';
g_bar y0 end if;
if ((a = '0') and (b = '1')) then y1 <= '0';
a y1
end if;
b y2
decode if ((a = '1') and (b = '0')) then y2 <= '0';
y3 end if;
(Behavioral)
if ((a = '1') and (b = '1')) then y3 <= '0';
end if;
end if;
end process;
end Behavioral2;
EXAMPLE: MAG_COMP
architecture Behavioral of mag_comp is
begin
pgtq: process(p, q)
begin
if p > q then p_gt_q <= '1';
else p_gt_q <= '0';
end if;
p p_gt_q end process pgtq;
q p_eq_q peqq: process(p, q)
mag_comp p_lt_q begin
(Behavioral) if p = q then p_eq_q <= '1';
else p_eq_q <= '0';
end if;
end process peqq;
pltq: process(p, q)
begin
if p < q then p_lt_q <= '1';
else p_lt_q <= '0';
end if;
end process pltq;
end Behavioral;
CASE STATEMENT VS IF STATEMENT
CASE statement IF statement