Creating New Devices II Including Files

Creating New Devices III


AND Gates

Let's move on to the AND gates. First thing's first: required attributes:

device quad_AND_gate is
   attr refPrefix = "U";
   attr pkg_type = "DIL_14";
end device quad_AND_gate;

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
   attr refPrefix = "U";
   attr pkg_type = "DIL_14";
   pin inA1 = {1};
   pin inA2 = {2};
   pin outA = {3};
   pin inB1 = {4};
   pin inB2 = {5};
   pin outB = {6};
   pin inC1 = {9};
   pin inC2 = {10};
   pin outC = {8};
   pin inD1 = {12};
   pin inD2 = {13};
   pin outD = {11};
   pin vcc = {14};
   pin gnd = {7};
end device quad_AND_gate;

This is obviously very verbose and undesirable. Therefore the following alternative should seem preferrable.

device quad_AND_gate is
   attr refPrefix = "U";
   attr pkg_type = "DIL_14";
   pin[1:4] in1 = {1,4,9,12};
   pin[1:4] in2 = {2,5,10,13};
   pin[1:4] out = {3,6,8,11};
   pin vcc = {14};
   pin gnd = {7};
end device quad_AND_gate;

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
   attr refPrefix = "U";
   attr pkg_type = "DIL_14";
   attr supplier = "Tayda Electronics";
   attr cost = "0.25";
   pin[1:4] in1 = {1,4,9,12};
   pin[1:4] in2 = {2,5,10,13};
   pin[1:4] out = {3,6,8,11};
   pin vcc = {14};
   pin gnd = {7};
end device quad_AND_gate;


555 Timer

Now for something a little more interesting-- the 555 Timer. As usual, we need to declare the required attributes.

device 555_timer is
   attr refPrefix = "U";
   attr pkg_type = "NE555";
end device 555_timer;

Next we examine the pins:

Now let's declare the pins in the device declaration.

device 555_timer is
   attr refPrefix = "U";
   attr pkg_type = "NE555";
   pin gnd = {1};
   pin trigger = {2};
   pin out = {3};
   pin reset = {4};
   pin vcc = {8};
   pin discharge = {7};
   pin threshold = {6};
   pin control = {5};
end device 555_timer;

Now let's add the supplier and cost information.

device 555_timer is
   attr refPrefix = "U";
   attr pkg_type = "NE555";
   attr supplier = "National Semiconductor";
   attr cost = "0.36";
   pin gnd = {1};
   pin trigger = {2};
   pin out = {3};
   pin reset = {4};
   pin vcc = {8};
   pin discharge = {7};
   pin threshold = {6};
   pin control = {5};
end device 555_timer;


4-Bit Counter

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
   attr refPrefix = "U";
   attr pkg_type = "14-TSSOP";
end device Counter;

Next come the pins.

device Counter is
   attr refPrefix = "U";
   attr pkg_type = "16-TSSOP";
   pin B = {1};
   pin Qb = {2};
   pin Qa = {3};
   pin Down = {4};
   pin Up = {5};
   pin Qc = {6};
   pin Qd = {7};
   pin gnd = {8};
   pin D = {9};
   pin C = {10};
   pin _Load = {11};
   pin _Co = {12};
   pin _Bo = {13};
   pin clr = {14};
   pin A = {15};
   pin vcc = {16};
end device Counter;

And (finally!) we'll add the supplier and cost information.

device Counter is
   attr refPrefix = "U";
   attr pkg_type = "16-TSSOP";
   attr supplier = "Jameco Electronics";
   attr cost = "3.49";
   pin B = {1};
   pin Qb = {2};
   pin Qa = {3};
   pin Down = {4};
   pin Up = {5};
   pin Qc = {6};
   pin Qd = {7};
   pin gnd = {8};
   pin D = {9};
   pin C = {10};
   pin _Load = {11};
   pin _Co = {12};
   pin _Bo = {13};
   pin clr = {14};
   pin A = {15};
   pin vcc = {16};
end device Counter;


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