And now let's go to the big brother of all of these all latches, the latches, which is the flip flop,
and let's see how we can behaviorally go that way.
This is the first actually synchronous design that we're going to do.
This is the most basic unit in synchronous design and we going to design it right now together.
So let us get started by creating a virtual file.
Copy pasting these and let's start with my.
Entity, I'm going to call it D.F. eight, so this the flip flop I'm going to create is eight bit length
so I can store in it eight bit data, not only just one bit.
So this is what we use in actual real circuit.
When you are designing, let's say, both systems, when we are designing Gramp's CPU's, we actually
we really consider using larger flipflops that can store larger data.
So let me create a port and let me create the inputs and outputs.
So what do we have?
We have D, we have Glocke and we have a Oreste for it.
These are my inputs, right, but they are not in the same length, so we cannot do that.
We will start with these and we are going to say input SDD logic.
Vector and the length here is from seven down to zero.
This is how we code eight bits, right?
That's great.
Next, I have a clock and I have reset.
Those are also inputs, but they are different types, so they are still logic.
Finally, I have my output, which is a Q and here I have out steady.
Logic.
And let me and this DFS eight.
OK, so far, so good, let's say architecture.
Behavioral.
Of DFS aid is.
We're going to say begin now, we are counting sequential circuits, so we need a process, so process,
what are we dependent on?
Well, we are dependent on clock and set.
OK, now this is Behaviorial, right, so it's not like we putting the circuits together to create at
the flip the flip flop, right.
So we can just do it behaviorally.
I'm going to say if Oreste equals one, then I want my cue to go zero.
Right.
Because I hit reset whatever data is stored, I want it to be zero.
So we could say KIU equals one, two, three, four, five, six, seven, eight.
But let's say I am using sixty four bits.
It really makes no sense to put all of these zeros like that.
There is another way to do that in video which is Q equals you open up parenthesis, you say others
meaning every other bit or every single bit.
Not every other bit is equal to zero.
So you just think it's pretty close to zero, you're close to the semicolon and you're good?
No.
Elsbeth.
And this is the new thing, remember that the flip flop works on the rising or falling edge, right?
So you get the clock.
If the clock is in the rising edge, you copy the input to the output cue and you store it right.
There is other times that for following it.
But now we are focusing on the rising.
So I'm going to say, if rising edge, this is a key word and we in to deal.
Which rising at 4:00.
OK, so if Locke has a rising edge, then please let the.
Please let you copy my.
Right, and that's and if.
And process.
And behavioral.
OK, let me recap.
This is sequential, so we use a process and clock whenever a clock and reset it changes, we can evaluate
whatever in here.
So.
I said, if Oreste is one, meaning, if I hit reset, please set my output all to zero and this is
the syntax to set all the bits to zero.
Else we are learning the new keyword, rising EJ.
And what weatherizing, which is it waits for a clock to have a rising edge in order to execute the
condition.
So when the clock comes and it's rising edge, we just got to cue and that's it.
So when let's say enfolding age or maybe clock is one, it doesn't really matter.
This won't be executed only on the horizon.
But now we can simulate this.
But first, let's save it.
And let's set it as a top level.
And, of course, that set of compile.
We got an error.
Let's see, what did we miss?
OK, we need a begin after process.
Software process always comes in software architecture.
We have a beginning up, a process.
We have another minute and we have another error.
OK, here is the error, we are having it saying that cannot determine the type here.
Why?
Because Q is not only one bit, it's seven bits.
Right.
So we forgot to specify that the output is also a bit.
Now, let me file again.
It's really nice to have this earth right now so that when you are trying to compile and you get errors,
you know how to face them.
Now, there is another error, we said, as to dialogic, but we did not say Vector C, so this will
create an issue.
So this issue can be solved by just doing that.
So now we have outis ideologic Lechter and here we go.
We are done.
Now let us go and simulate this one more time.
So BWF and let us add everything list at everything to me here, OK?
I want to save my file and I'm going to call it D.F..
Eight, the same as my interview name, and now how can we simulate a clock?
A lot can be simulated.
We could do this like one zero one zero like that, but that's not really practical in order to simulate
the clock hit on a clock, right click value and choose clock and choose discount value.
And we want to count.
Let's say every 20 milliseconds or 20 nanoseconds click, OK, and he will generate a clock.
OK, this is a little bit of a smaller clock.
Let us create something with the larger waveform.
So maybe we want to change every 15 nanoseconds.
OK, so this is my clock.
Now, the data here, I wanted to change.
So maybe from here to here we could have data like that.
So let us set this and this, change the radix and make it and sign this.
OK, so now let us put values, let's say, from here to here.
Right, click value, arbitrary value, let's say it is one hundred twenty three.
Let's say this area here is I don't know.
Fifty six, by the way, the shorter the short cut to change value is all out and be.
So let's say from here to here.
We have four.
From here to here.
We have.
41.
OK, and let's say that I want to reset here, so from here to here, I have a reset and now let us
start simulating.
But first, let us correct the simulation settings and let us delete this save and hit on simulation.
Now, let's see if what's happening is correct, remember?
Q Here is the output and is the impact.
Let's put them side by side.
No, whenever I have a clock rising.
So only this area, this is the rising edge.
This is the edge, it's rising.
It means that.
Q will copy rising.
Q is copying D and it's maintaining the value until.
Q is until the clock is rising again.
So all the here it's rising and the value is fifty six.
So we copied it.
Now the value is retained all the way here until here we have a rising value.
Right.
And at this moment of the rising value that is for sooky will be for.
And as you can see now, every rising edge we are copying D to Q Copied, copied, copied.
OK, and it's being retained all the way here.
Now here.
We are copying, right, because this is the rising edge, these 41, so we will see 41 at the Q But
as you can see, it's only for a very short amount of time.
Why?
Because as you can see here, we are activating the reset.
So when you activate a reset, your output should be zero immediately.
This is why we get a zero here.
Even though we are having the rising edge, it does not matter.
The reset overrides the rising edge and it always should skew to be zero.
Now, here again, we have a rising edge.
It's 41.
We can see 41 here again, rising at zero and we see zero so that if we probably will see change at
its output only at the rising edge and then the Q will copy whatever it has.
OK, and of course, the reset is going to override whatever data you have and it will always force
your output to be zero.
OK, and this is what the flip flop is.
And now we are done with the basic components of the deal and we can go and design our small project.