Slide 07
Slide 07
Sequential Logic
● Output depends not only on current input values but also on
previous input values.
● Are building blocks of;
● Counters
● Shift registers
● Memories
● Flip flops are basic sequential logic devices.
● Sequential logic can be Synchronous or are asynchronous
inputs outputs
Combinational
Circuit
Memory
Sequential Logic
● Synchronous Sequential Logic
● Change in output due to current input values and current
system state (history) to next state only takes place when a
clock pulse is applied.
● Asynchronous
● Change in output due to current input values and current
system state (history) to next state is triggered by completion
of previous stage without reference to clock pulse.
VHDL Sequential Statement
● Statements that are executed one after the other like in software
languages.
ENTITY dff IS
PORT (
d, clk, rst: IN STD_LOGIC;
q: OUT STD_LOGIC);
END dff;
ARCHITECTURE behavior OF dff IS
BEGIN
PROCESS (clk, rst)
BEGIN
IF (rst='1') THEN
q <= '0';
ELSIF (clk'EVENT AND clk='1') THEN
q <= d;
END IF;
END PROCESS;
END behavior;
Signals and Variables
SIGNALS VARIABLES
Declared in declarative of Entity, Package Declared only in a piece of sequential
or architecture logic e.g. PROCESS
SIGNAL mySig:dataType := intialValue VARABLE: varName:= initialValue;
Can be local or global Can only be local to the declarative
process
Cannot be passed of the process
directly: assign to a signal first.
Uses <= as an assignment operator Uses = as an assignment operator
● Syntax :
● Example:
FOR j IN 0 TO 3 LOOP
qt(j+1) <= qt(j);
END LOOP;
-- OR --
FOR k IN 3 DOWNTO 0 LOOP
qt(k+1) <= qt(k);
END LOOP
WHILE....LOOP Statement
● Use when number of repetition depends on certain condition
● Syntax:
● Example:
j = 0;
WHILE j <= 3 LOOP
qt(j+1) <= qt(j);
j = j + 1;
END LOOP;
CASE Statement
● Use for selecting assignment based on value of identifier
● Syntax:
CASE identifier IS
WHEN value => assignments; [assignments;]
WHEN value => assignments; [assignments;]
...
END CASE;
Example:
CASE control IS
WHEN "00" => x<=a; y<=b;
WHEN "01" => x<=b; y<=c;
WHEN OTHERS => x<="0000"; y<="ZZZZ";
END CASE;
Flip-Flop Modeling
D Flip-Flop
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
ENTITY D_FF IS
PORT(d, clk: IN std_logic;
q: OUT std_logic);
END D_FF;
JKFF1: PROCESS(T0)
BEGIN
IF(T0'EVENT and T0 = '1') THEN
IF(J1 = '0' AND K1 = '0') THEN
T1 <= T1; -- NO CHANGE
ELSIF(J1 = '0' AND K1 = '1') THEN
T1 <= '0'; -- RESET
ELSIF(J1 = '1' AND K1 = '0') THEN
T1 <= '1'; -- SET
ELSIF(J1 = '1' AND K1 = '1') THEN
T1 <= NOT(T1); -- TOGGLE
END IF;
END IF;
END PROCESS JKFF1;
Q1 <= T1;
END Counter;
Flip-Flop Applications
Counter revisited
● The previous counter example is not practical way of implementation
● We can generate circuit from its behavior without knowing what are
Counter_Output = 0
DO
IF Clock = rising_edge THEN
Increment Counter_Output by 1
LOOP forever
Type Conversion
Example:
We can write VHDL description of our asynchronous
counter as follows:
Type Conversion
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity sync_counter is
port(clk : in std_logic;
output : out std_logic_vector(3 downto 0));
end sync_counter;