In this lab, we are going to talk more about sequential logic, we will start by builidng edge-triggered D Flip-Flop, and understand the befients from it, then we will talk about clocks, how to generate clocks and the purpose of having a clock in our system.
The problem with our prevous D-Latch is that it will pass that data if the enable line is true
, so the flaw in this design is that we don't have a certain moment for capturing the data, which will lead to lot of problems later.
Imagine if you want to create a counter that counts from 0 to 15, you will need 4 D-Latches to save the previous data, a 4-Bits adder to add 1
to the previous value, then you will connect the output of the adder to the latch to update it.
The problem here is that if we enabled the latch we will never guess what will be stored in it, as it will update then the adder will add one then it will add agine (beacuse the enable still 1
), and so on.
The solution for the above problem is that we can create a latch that only updates its value on certain edge (not level), so it will update only if the signal goes from low
to high
(rising edge), or from high
to low
(falling edge).
This device can be created easily using two latches:
D Flip-Flop
Notice that even if C
is 1
and D
is 1
, the output is 0
, because our flip-flop will only updates its value on the rising edge.
D Flip-Flop Digram
You could design a 4-bit counter using 4 D Flip-Flops and 4 Full-Adders, the concept here is that you will need to add 1
to the ouptut of the flip-flops then store the output of the full-adders to the flip-flops
Counter using D Flip-Flops
Note: You can use register and 4-bit full-adder in Logisim.
When we say clock in digital design, we don't mean a real time clock, we mean the basic clock, which is something that gives a meaning to time!
As you know an AND
gate won't know anything about seconds or minutes, so we have the basic clock, which will generate a wave in a certain amount of time, we usual measure the amount of time using frequancy (how many waves in one second).
So a 1 Hz clock will generate a complate wave each second, we will use a sequare wave with 50% duty.
Sequare Wave Clocks
In the lab, we will have a clock generator, which you can adjust the speed of it as you wish, and you also have pulse inputs, which generate a plus when you push it down.
To generate a clock, we will use 555 timer chip, first, we will understand how this timer works, then we will talk about how to use it!
555 Timer
At the begining our capacitor will behave as short circuit, so trigger and threshold will have 0 volt, so the output of the threshold comparator will be 0, and the output of the tigger comparator will be 1, thus the output will be 1.
After some time, the capacitor will charge to 1.66 volt, which will result make the trigger comparator output 0, then it will charge to 3.33 volt, which will make the threshold comparator output 1, this will make our output goes high 1, and the discharge transistor will open.
After some time of opeining the discharge transistor, the voltage will drop below 3.33 volt, which will make threshold comparator output 0, then it will drop below 1.66 volt, which will make the trigger output 1, which will set our latch output to 1.
Then the cicule will repeat.
So as you might notice, to adjust the speed of charging and discharging we will need to adjust and and , if the resistors or capacitor are bigger, it will take more time to charge.
According to the datasheet to calculate the time for each wave we will use the following equation:
And to calculate the frequacny it will be
Note: There are some more pins in the chip, some of them you will not use (e.g. reset), and some have recommended capcitors and resistors (e.g 0.01μF capacitor on pin 5), which will make your output much cleaner.
Return to task 2 in the prvious lab to build two D-Latches, then connect them both to create a D Flip-Flop.
The 74/74 Chip is a Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs
, which mean we will have two flip-flops in this chip.
Use this chip to create to test the D Flip-Flop in it, then create a T Flip-Flop using it!
Digital Design
Digital
IUG
Computer Engineering