4311 Lecture 17
4311 Lecture 17
Lecture #17
• Agenda
1. Counters
• Counters
- special name of any clocked sequential circuit whose state diagram is a circle
- there are many types of counters, each suited for particular applications
• Binary Counter
- state machine that produces a straight binary count
- the speed will be limited by the Setup/Hold and Combinational Delay of "F"
• Toggle Flop
- a D-Flip-Flop can produce a "Divide-by-2" effect by feeding back Qn to D
• Ripple Counter
- Cascaded Toggle Flops
can be used to form
rippled counter
• Shift Register
- a chain of D-Flip-Flops
that pass data to one
another
• Ring Counter
- feeding the output of a
shift register back to the
input creates a
"ring counter"
- also called a
"One Hot"
• Johnson Counter
- feeding the inverted
output of a shift register
back to the input creates
a "Johnson Counter"
• Counters in VHDL
- strong type casting in VHDL can make modeling counters difficult
(at first glance)
- the reason for this is that the STANDARD and STD_LOGIC Packages
do not define "+", "-", or inequality operators for BIT_VECTOR
or STD_LOGIC_VECTOR types
• Counters in VHDL
- there are a couple ways that we get around this
entity counter is
Port ( Clock : in STD_LOGIC;
Reset : in STD_LOGIC;
Direction : in STD_LOGIC;
Count_Out : out STD_LOGIC_VECTOR (3 downto 0));
end counter;
begin
process (Clock, Reset) begin
if (Reset = '0') then
count_temp <= "0000";
elsif (Clock='1' and Clock'event) then
if (Direction='0') then
count_temp <= count_temp + '1';
else
count_temp <= count_temp - '1';
end if;
end if;
end process;
Count_Out <= count_temp; -- assign to Port after the process
end counter_arch;
• Counters in VHDL
2) Use integers for the counter and then convert back to
STD_LOGIC_VECTOR
entity counter is
Port ( Clock : in STD_LOGIC;
Reset : in STD_LOGIC;
Direction : in STD_LOGIC;
Count_Out : out STD_LOGIC_VECTOR (3 downto 0));
end counter;
• Counters in VHDL
3) Use UNSIGNED data types #'s
- using integers allows a higher level of abstraction and more functionality can be included
architecture ….
begin
Q0 <= Q3;
Q1 <= Q0;
Q2 <= Q1;
Q3 <= Q2;
end architecture…
- notice that the signals DO NOT appear in the sensitivity list. If they did the process would
continually execute and not be synthesized as a flip-flop structure