HDL – Full Adder Schematic

This is a continuation of my FPGA series.  I’m going to show how to create a one-bit full adder circuit using a schematic diagram in Xilinx HDL language.  Then I’m going to send the compiled code to the Mimas V2 Spartan-6 board and test it.  This project is for the entry-level FPGA programmer.  If you just purchased the Mimas V2 board and you’re unsure how to get started, this short tutorial should help with some of the entry-level basics.

To start this project, you’ll need to download and install the Xilinx Design Suite by clicking here.  Follow the instructions, you’ll need to register and answer some questions and install the software.  Go to “All Programs -> Xilinx Design Tools -> ISE Design Suite 14.7 -> ISE Design Tools -> 64-Bit Project Navigator”, then click on the “New Project” button.  If you’ve already installed the tools and wish to start a new project, you’ll need to go to the File menu and close the project before starting a new project.

When the new project dialog starts, select “Schematic” as your top level project (I keep my FPGA projects in a directory on my D: drive):

Then give your project a name and click on the next button.  Then click next again.

You’ll need to create a schematic. Right click on the FPGA board designation node and select New Source:

Click on “Schematic” and Next, Next.

Now you can draw a schematic.  First you’ll need to find logic gates that you want to use.  If you click on the “Symbols” tab (bottom tab of the palette window):

You can find logic gates like and2 which is the 2-input AND gate.  Draw a full adder circuit.  The basic logic for a full adder is like this:

You can plot the XOR2, OR2 and AND2 gates first, then use the wire tool to connect outputs to inputs.  Next you’ll need to add connectors to the A, B, Cin, S and Cout points.  Your final circuit should look something like this:

I added three VCC connections to the enable pins of the LED displays since I won’t be using them. I also had to invert the outputs because the LEDs on the Mimas board are active low.  You can use an XNOR gate instead of an XOR and inverter and you can use a NOR gate instead of the OR and inverter.  I added inverters after I generated the code, sent it to the board and discovered that the LEDs lit opposite of what I expected.

The connectors (A, B, CARRY_IN, SUM, CARRY_OUT, EN1, EN2 and EN3 in the diagram above) can be added from the palette to indicate inputs and outputs.  You’ll need to give them a useful name so you can designate a physical pin to connect them to.  Double-click on the connector object and you’ll see this screen:

Now click on the name under the “Nets” branch and then change the “Name” to the value that you want.  You can also change the connector to be an input or output.

To define the connectors to a physical pin, you’ll need to add a ucf file to your project.  Right-click on the FPGA node again (under the Design tab) and add a New Source.  This time select an Implementation Constraints File:

Then add the following definitions to connect the circuit to your FPGA board:

NET "SUM" LOC = P15;
NET "CARRY_OUT" LOC = P16;

NET "A" PULLUP;
NET "B" PULLUP;
NET "CARRY_IN" PULLUP;
NET "EN1" PULLUP;
NET "EN2" PULLUP;
NET "EN3" PULLUP;

NET "A" LOC = F17;
NET "B" LOC = F18;
NET "CARRY_IN" LOC = E16;

NET "EN1" LOC = B3;
NET "EN2" LOC = A2;
NET "EN3" LOC = B2;

You can lookup the physical connection names for the MIMAS V2 board from this website: Mimas V2 Spartan 6 FPGA Development Board With DDR SDRAM.

Next, you’ll need to select your FPGA board node and then in the processes section, you can right-click on “Generate Programming File” and select “Process Properties”.  Make sure the “Create Binary file” check box is checked.  Then right-click “Generate Programming File” again and select “Rerun All”.  That will compile and generate all the files you’ll need for your board.

Now you can startup your Configuration tool.  This can be downloaded from here (Click on Downloads and download the Configuration Tool for Windows).

You’ll need to select the COM port that corresponds to the USB port that you are using for your board.  To find that, you can open the Windows “Device Manager” and look it up.  You’ll need to plug in your Mimas board for this to show up.  You’ll see an entry in the “Ports (COM & LPT)” section:

You can see the “Numato Lab Mimas…” line and it is using COM3.  So select the COM port that your computer is setup for in the Configuration Tool.

Next, click on the “Open File” button and navigate to your project folder and click on the “.bin” file.

Then Click the “Program” button and wait for the “Done” status.

Now you can use the dip switches to turn on/off the A, B and Carry in signals:

This is a view with A, B and Carry In set to a “1”.  The LEDs represent D1=Sum and D2=Carry.  As you can see, they are both lit.

Leave a Reply