Describe
the use of feedback to make a D-type flop-flip divide by two.
Convert
a four-bit binary number into decimal or HEX notation.
Design
4-bit up or down counters based on rising edge triggered D-type
flip-flops.
Design
4-bit modulo-N counters and draw timing diagrams.
Describe
the use off a BCD or HEX decoder with a seven segment display.
Counters
Latches
can act as a memory for binary numbers that have been put into them.Eight flip-flops can act as a memory for an eight-bit word, or a
single byte.In computers,
which work with bytes, each eight-bit number stands for something, be it a
letter, a number, or a character, determined by the ASCII code, universal
for all computers.
Counters
are special memories that store a word that represents the number of pulses that
have passed into the circuit.The D-type flip-flop is the simplest counter for 1 bit.
The
timing diagram shows the behaviour of the circuit:
Question
1.
What do you notice about the output compared to the input? ANSWER
This
circuit can count two bits:
When
the reset is made high, the outputs Q go to give a two bit word BA 00.The circuit then changes state on the falling edge of the clock pulse,
according to the following table:
Pulse
B
A
0
0
0
1
0
1
2
1
0
3
1
1
4
0
0
The
word BA tells us the number of pulses that have arrived.B is the most significant bit
worth 21 (= 2), while A is the least
significant bit worth 20 (= 1).So BA = 11represents 2 x
1 + 1 x
1 = 3. The timing diagram is like this:
As
well as acting as a single bit counter, the circuit above, which is a D-type
flip-flop with feedback, acts as a divide
by two circuit.If we look at
the timing diagram, we can see that the number of output pulses is half the
number of clock pulses.
Computers
work on binary numbers, which mean
numbers to the base 2.We normally count in tens, because we have ten digits on our front and
hind paws.This is base
10 or decimal.We can count in any base we like.In the UK the currency was run on a duodecimal system,
counting in base twelve. 1 shilling = 12 old pence; 1 pound = 20 shillings.
When
we express anumber, we start off
with the most significant bit at the
left hand side, and the least significant
at the right.Consider the number
245:
Hundreds
Tens
Units
Powers
of Ten
102
101
100
Number
2
4
5
2
x
100
4
x 10
5
x
1
So 245 is the sum of
200 + 40 + 5
We do a similar thing in binary.The least significant bit is 20 (= 1), followed by
21 (= 2), followed by 22 (= 4), etc.We will look at a four bit number:
Computer
memories are designed to act rather like a set of pigeonholes, or lockers, in
which data is posted.Each location
has a unique address, which is given a number in base 16 (= 24),
called a hexadecimal or HEX code.
The
first 9 hexadecimal numbers are like the first 9 decimal numbers.The character 10 represents decimal 16.So there have to be alternative characters for decimal 10, 11, 12, 13,
14, and 15.These are A, B, C, D,
E, and F respectively.The table
shows decimal numbers 0 to 16 with their four bit binary and hexadecimal codes:
Decimal
Four-bit
binary
Hexa-decimal
0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
7
8
1000
8
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
16
0000
10
The binary code for
decimal 16 or hexadecimal 10 is 10000, which is a five bit number.
Address codes of four figures give 164 (= 65536) combinations.In real computers the addresses can be 16digit codes or even 32 digit,
which give many more combinations.
We
can cascade the flip-flops so that we can have as many bits as we want.
The next diagram shows a four bit counter:
This
circuit is rising edge triggered, and each flip-flop has its Q-bar output fed
back to the data input. The timing diagram shows the idea:
Notice
that the unit counter goes through a change every two clock pulses, and the
two’s counter every four pulses. The four’s would be every eight
pulses, and the eight’s every sixteen pulses. If
we look at the output of the counter, we would see it increase by 1 every two
clock pulses. This is an up-counter.
Question 6
What is the maximum decimal number that this counter can count to? ANSWER
To
make a down-counter, we connect the Q-bar output to the CK input of the
next flip-flop, while the Q output is connected to the data input.
The
4-bit counters we have seen above count from 0 to 15 (decimal) before resetting
to zero.We say that it is a modulo 16 counter.The modulo
refers to the number of states that a counter goes through until it resets
to zero.
A counter with n flip-flops will go through 2n
states before it resets to zero.
If
we want to reset to zero before that 2nth
state is reached, we need to add an AND gate to the circuit and feed the output
of the AND gate to the reset line.The
diagram shows the four bit counter with the AND gate feeding the reset line:
The
counter counts up to binary 1010 (decimal 10).Since Q1 and Q3 are 1, the output of the AND gate
is 1 and that makes the reset line 1, knocking the counter back to zero.This circuit is called a binary
coded decimal (BCD) counter.We
could chose any of the lines. The AND gate between Q2 and Q3 would
give us a modulo 12 counter.