Creating Nets | Instancing the Diode |
Now we move onto device instances. These take place after the 'begin' keyword in a design declaration.
design LED_Dice is |
The basic syntax is the word 'inst' followed by the name of the instance followed by the keyword 'of,' the name of the device being instanced, and the keyword 'is.' Then you are free to add attribute delcarations or modifications and pin connections after the keyword 'is.' The device instance is terminated with the keyword 'end' (optionally followed by the keyword 'inst' and optionally followed by the name of the instance) and lastly a semicolon.
The basic structure of the push button switch device instance looks like this:
inst mySW of PBSwitch is |
This would not compile unfortunately, since PBSwitch has pins that haven't been wired up. Recall that the device declaration for PBSwitch looked like this:
device PBSwitch is |
There are four pins that need to be hooked up-- namely "off_a," "off_b," "on_a," and "on_b." However, when the switch is in the off position, nothing should happen, meaning that those respective pins shouldn't be hooked up to anything.
Let's look at the significant nets hooked up to the switch.
As we can see, the switch's "on" pins are connected to the "+5V" and "SD_junct" nets. The new device instance would therefore look like the following:
inst mySW of PBSwitch is |
Great! We're done, right?
Sorry, but the compiler will still throw an error with this code. There are two pins that haven't been hooked up yet! "But," you protest, "the 'off' pins don't need to be hooked up to anything!" You're right, but PHDL tries very hard to make sure you don't make any passive mistakes. In other words, you can't just leave pins open-- you must declare them as such. This is done using the keyword 'open' as shown below:
inst mySW of PBSwitch is |
There we go! Now we've create a Push Button Switch and hooked it up to the board! Congratulations; you are that much closer to completing your board! Let's go ahead and instance another device.
Creating Nets | Instancing the Diode |