Creating New Devices II | Including Files |
Let's move on to the AND gates. First thing's first: required attributes:
device quad_AND_gate is |
This will be a chip that has four dual-input AND gates for use. We are using this because these chips are really easy to obtain. Therefore we have a lot more pins to declare. We'll base it off of the following diagram:
As you can see, there are 14 pins to declare. Take a breath, and let's dive in.
device quad_AND_gate is |
This is obviously very verbose and undesirable. Therefore the following alternative should seem preferrable.
device quad_AND_gate is |
The notation "1:4" stands for "one up to four." The square brackets indicate to PHDL that the pin is to be a vector, allowing us to declare several pins in a simple expression as opposed to a long list of code.
Later, for example, if we wanted to access the third AND gate's second input pin, we would state "in2[3]."
Lastly, let's specify supplier and cost.
device quad_AND_gate is |
Now for something a little more interesting-- the 555 Timer. As usual, we need to declare the required attributes.
device 555_timer is |
Next we examine the pins:
Now let's declare the pins in the device declaration.
device 555_timer is |
Now let's add the supplier and cost information.
device 555_timer is |
Welcome to the last device we'll be declaring for this design: the 4-Bit Counter. This is the largest one of all the devices we've declared thus far, so buckle up!
device Counter is |
Next come the pins.
device Counter is |
And (finally!) we'll add the supplier and cost information.
device Counter is |
Congratulations! You've just finished declaring all of the devices you'll need to make the board!
Now, you definitely don't want to have to re-declare these devices if you were creating a similar board. Honestly, there is a decent amount of time that goes into these device declarations. In our next section "Including Files," we'll discuss how to re-use your own devices or use devices created by others.
Creating New Devices II | Including Files |