Getting Started with CPLDs – Part 4

cpldjIn this guide, we’re going to build up from the previous guide and add a button to our LED. Hopefully by now you’ve had a play with the Quartus II software and had a look through some of the logic elements in the library so I wont be explaining everything in minute detail. You should have a much better idea of what you’re doing now.

You’re going to need your CPLD board & programmer, a breadboard, LED, push button, 10K resistor, 220ohm resistor and some jumper wires.

button┬áHere is a quick schematic of the circuit we’re going to build. As you can see, I’ve chosen to use pins 1 & 2 on the CPLD. The 3.3v and ground are also connected to the CPLD. You’ll need to check the 220ohm resistor is the correct value for your particular setup, just like in Part 3. The 10K resistor connects between the 3.3v rail and the push button.┬áThe purpose of this 10K resistor is to hold Pin2 high when the button is not pressed. When the button is pressed, it connects Pin2 to ground and causes it to go low.

cpldbuttonshcemWhen you build the circuit and program your CPLD, the LED will light up as default but will turn off when the button is pressed. Let’s have a look at the schematic used in Quartus II. (Click to enlarge)

All we’ve done here is add an input pin and labelled it “Button” that then connects to an input buffer which in turn connects to an output buffer. Finally, the output connects to an output pin which I’ve named “LED”

Following the previous guides, build the circuit and program your CPLD chip. Once the chip is programmed, you should expect to see the results shown in the two photos below.

lit1

unlit1

 

 

 

 

 

Right, that works perfectly but it does seem odd that the LED goes off when the button is pressed. If only there were a way to reverse it so that the LED lights up when the button is pressed……. Enter the NOT gate.

If you take a quick look at this article, it will explain that a NOT gate basically works as an inverter so the output is the direct opposite of the input. Off is on and vise versa. Let’s add one to our CPLD schematic.

not1Delete the link between the input and output buffers and drop in a NOT gate. Link the NOT gate to both of the buffers and you should end up with something like this.

If you try to recompile your schematic now, you’ll receive an error. If you look at the newly added NOT gate, you’ll notice that it’s called “inst”. My input buffer is also called “inst” so the compiler spits out an error. Double click on the NOT gate and a dialogue box will appear with a text field to rename your NOT gate. I called mine “Not”. You can also rename any other components you wish. You should really start getting used to this as it will help later on when your projects start to grow.

notaddedYour schematic should now look like this.

Re-compile and upload to your board. If everything went as expected, your LED will now remain off until you press the button. See the photos below.

IMAG0232

IMAG0233

 

 

 

 

 

Now that we’ve got some of the basics out of the way, we can start getting our teeth into some more advanced topics than simply using buttons and LEDs.

Stay tuned for Part 5
Other articles in this series can be found here.

Email this to someoneShare on Google+Pin on PinterestTweet about this on TwitterShare on RedditShare on Facebook

2 thoughts on “Getting Started with CPLDs – Part 4

  1. great intro but please give links to each part from the previous part i no link to part 4 from part 3 etc

Leave a Reply to paul trezise Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">