Lec 3 (VHDL For Combinational Circuits)
Lec 3 (VHDL For Combinational Circuits)
VHDL Combinational
circuits
Conditional assignment
With – select
When – else
Examples
Concurrent Statements (Conditional
3
assignment (when/else))
When/else
Relational operators
In VHDL, relational operators are used to compare two operands of the
same data type, and the received result is always of the Boolean type.
VHDL supports the following Relational Operators used in Boolean
condition:
• = Equal to
• /= Not Equal to
• < Less than
• > Greater than
Concurrent Statements (Conditional
4
assignment (With/select))
With/select
others
Program (Multiplexer 4 x 1 Using
5
When/else)
Program (Multiplexer 4 x 1 Using
6
With/Select)
Program (Demultiplexer 1 x 4
7
Using When/else)
Program (Demultiplexer 1 x 4
8
Using With/Select)
Program (Decoder with Enable 2 x 4 Using
9 When/else )
Program (Decoder with Enable 2 x 4 Using
10 With/Select )
11
EXAMPLE:
case opcode is
when "00" => perform_add;
when "01" => perform_subtract;
when others => signal_illegal_opcode;
end case;
Architecture
Flip flop
VHDL code for D latch
22
23 How to Ask about Edges in
VHDL
Clk
Rising (Positive) edge Falling (Negative) edge
D Q
• Positive reset
CLK
Rst = 1 Q=0 RST
• Negative reset D Q
Asynchronous reset
Synchronous
This means to execute Rst or E,
This means to execute Rst or the Clock must not exist first.
E, the Clock must exist first. The reset if happens so the
output =0, without checking the
clk
For example:
For example:
If rising-edge (clk) then
If Rst=‘1’ then Q =‘0’
Ask here on reset and Elsif rising-edge (clk) then
enable
Ask for enable
D flip-flop with synchronous
27 LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY D_ff IS
PORT ( D, Rst, Clk : IN STD_LOGIC ;
Q : OUT STD_LOGIC) ;
END D_ff ;
ENTITY D_ff IS
PORT ( D, RST, CLK : IN STD_LOGIC ;
Q : OUT STD_LOGIC) ;
END D_ff ;
ARCHITECTURE behavioral OF D_ff IS
BEGIN D Q
PROCESS (RST, CLK ) CLK
BEGIN
RST
IF RST= '1‘ THEN
Q <= '0' ;
ELSIF rising_edge(CLK) THEN
Q <= D ;
END IF ;
END PROCESS ;
END behavioral ;
29
Outline of course
Contents going to be covered during the course:
Introduction to embedded systems, FPGA, and HDL
VHDL basics
VHDL for Combinational circuits
VHDL for Sequential circuits
AVR family and architecture.
Learning embedded C of AVR microcontroller.
AVR I/O
AVR timer and counter.
AVR communication peripherals
30