Downloading and Verifying the Bitstream
After the cable is connected to your computer, you can download the bitstream. If you are using an XChecker cable, you can also verify the design.
- Set all the input switches High to select the NOP (no operation) command. Set the SW3 switches High to the On position.
- From the Design Manager, select Tools
Hardware Debugger or click the Hardware Debugger icon.

The Communications dialog box appears.
- Click a cable type in the Cable Type field. Select the correct port from the Port drop-down list box and the appropriate baud rate from the Baud Rate drop-down list box.
After you have used a certain kind of cable and set the correct port, the information is saved in a file called design_name.xck in your design directory, so you do not have to specify it each time.
NOTEIf you invoked the Hardware Debugger from within the Design Manager after selecting the desired implementation revision in the project view, the configuration file is already loaded in the Hardware Debugger. If you did not select an implementation revision, complete steps 4 and 5, following, to load a bitstream file.
|
- Select File
New
Project.
- Select the input file name: CALC.BIT and click OK.
- If you are using the serial download cable to program an XC4000 family part, press the PROG button on the demonstration board. This step is not necessary if you are using the XChecker cable or the parallel cable.
- Select Cable
Logic Level of Pins to check that the status of the Done pin is Low.
- Select Download
Download Design or click the following toolbar button.

If you are using an XChecker cable, select Download
Download and Verify or click the following toolbar button if you want to verify the design. You must also connect the RT and RD pins for readback to be available.

If the FPGA is successfully programmed, the following message appears.
Device is Configured.
If the DONE signal does not go High, check the connections between the cable and the demonstration board, power the board off and on, and try downloading again. Also, ensure that the bitstream is targeted for an XC4003E device.
If the Hardware Debugger informs you in a message that the current design does not include the READBACK block connected, check your schematic to ensure that the READBACK symbol is connected as shown in the Readback Symbol Connections figure.
NOTEThe serial download cable has limited functionality when used with XC4000 family parts and may report that DONE went High even if you do not press the PROG button as in step 6. If this occurs, the part is not re-programmed. Download the bitstream again, this time pressing the PROG button prior to configuration. Cycling the power off and on before starting the download has the same effect.
| If you chose the Download and Verify command, the software initiates a design verification after downloading. The output of the design verification is displayed in a message box.
Testing the Design
After programming your device with the logic functions of your design, you can test your design by checking the states of the device.
The FPGA demonstration board has a row of eight rocker switches (SW3) that provide input to the design.
In the Calc design, the SW7 schematic assigns pin names to flip-flop inputs. Each pin corresponds to an input switch of the demonstration board. The Schematic Labels vs. Demo Board Switches table lists the schematic labels of SW7 and the demo board switches to which the labels correspond. The interpretation of the pattern you use to set the switches depends on the pin assignment you used in the schematic. The different patterns generate different operation codes. The Operation Codes (Opcodes) table shows the operation codes assigned by the SW7 schematic to the bank of input switches of your demonstration board.
Table 9_5 Schematic Labels vs. Demo Board Switches
Calc Design Signal
| Demo Board Switch
|
SW0_P
| SWx-8
|
SW1_P
| SWx-7
|
SW2_P
| SWx-6
|
SW3_P
| SWx-5
|
SW4_P
| SWx-4
|
SW5_P
| SWx-3
|
SW6_P
| SWx-2
|
EXC_P
| SWx-1
|
Table 9_6 Operation Codes (Opcodes)
| Demo Board Switches
|
|
| 2
| 3
| 4
| 5
| 6
| 7
| 8
|
|
Operations
| 3-Digit Opcodes
| Data
| Operations Between Switches and Register
|
ADD
| 0
| 0
| 0
| DATA
| ADD between switches and register
|
AND
| 0
| 0
| 1
| DATA
| AND between switches and register
|
OR
| 0
| 1
| 0
| DATA
| OR between switches and register
|
XOR
| 0
| 1
| 1
| DATA
| XOR between switches and register
|
SUB
| 1
| 0
| 0
| DATA
| SUB switch value from register
|
CLEAR
| 1
| 0
| 1
| X
| X
| X
| X
| CLEAR register
|
LOAD
| 1
| 1
| 0
| DATA
| LOAD register
|
| Demo Board Switches
|
|
| 2
| 3
| 4
| 5
| 6
| 7
| 8
|
|
Operations
| 6-Digit Opcodes
| Don't Care
| Operations Between Stack and Register
|
ADD
| 1
| 1
| 1
| 0
| 0
| 0
| X
| ADD between stack and register
|
AND
| 1
| 1
| 1
| 0
| 0
| 1
| X
| AND between stack and register
|
OR
| 1
| 1
| 1
| 0
| 1
| 0
| X
| OR between stack and register
|
XOR
| 1
| 1
| 1
| 0
| 1
| 1
| X
| XOR between stack and register
|
SUB
| 1
| 1
| 1
| 1
| 0
| 0
| X
| SUB stack value from register
|
PUSH
| 1
| 1
| 1
| 1
| 0
| 1
| X
| PUSH register value to stack
|
POP
| 1
| 1
| 1
| 1
| 1
| 0
| X
| POP stack value to register
|
NOP
| 1
| 1
| 1
| 1
| 1
| 1
| X
| NOP
|
Each time you set the switches for a logical operation, you generate a value, which is stored in your flip-flops. When you toggle the Execute switch (switch 1), the value is displayed on the 7-segment display.
The Calc design is essentially a 4-bit processor with a stack. There are three types of inputs that you must supply using the input switches on your board: an Opcode, Data, and an Execute command.
Use the demonstration board input switches to enter the opcodes and the data.
- The leftmost switch, labeled 1, is the Execute (EXEC) command, which is activated by toggling the switch off and on.
- The next three switches (labeled 2, 3, and 4) select the opcode. Opcode encoding is shown in the Operation Codes (Opcodes) table.
- Use the rightmost four switches (labeled 5, 6, 7, and 8) to input data.
When the extended instruction set is selected with opcode 111, these switches provide additional bits of opcode.
Understanding Opcodes
Your Calc design includes a user-defined module, SW7, which consists of input pads, output pads, and flip-flops. The input pads are assigned pin locations. These pins are associated with the programming switches on your board. The flip-flops store the values displayed by the switches. The output pads display the values on your 7-segment display.
Operating the Board 7-Segment Display
To perform an operation, follow these guidelines.
- Use the rightmost nibble, (switches 5 to 8) to set the data.
You can represent values ranging from 0 to (24-1). On is a one; Off is a zero.
- Look up the correct opcode for the operation you want to perform and set the three opcode switches to the correct value.
- Toggle the leftmost Execute (EXEC) switch on.
If the switch is already on, switch it off, wait a moment, and then return it to the On position.
The contents of the ALU register are displayed in hexadecimal on the 7-segment display. The top value in the stack is displayed in binary on the bank of LEDs along with a gauge that indicates how many values are on the stack.
Opcode Examples
The following examples show you how to set the switches using operation codes to enter and process data arithmetically. For example, after loading data, you can complete the following operations: addition, subtraction, and boolean operations.
- Verify that the initial contents of both ALU and stack are all zeros. The decimal display indicates 0, and the LED bar is off.
- Put a 1 on the DATA switches and load the switch value to the ALU register. The opcode for the load operation is 110.
- Set the seven rightmost switches to 110-0001.
- Toggle the leftmost switch (switch 1) off and on to execute the command.
The decimal display shows the contents of the ALU register, which is now 1. The stack is still empty.
- Add 13 to the ALU register. The opcode for the add operation is 000.
- Set the seven rightmost switches to 000-1101.
- Toggle the leftmost switch (switch 1) off and on to execute the command.
The 7-segment display shows the contents of the ALU register, which is now E. The stack is still empty.
- Push the register value onto the stack. The opcode is 111, which is the extended opcode. The data must be set to 101x, where the x is a don't-care.
- Set the seven rightmost switches to 111-1011.
- Toggle the leftmost switch off and on to execute the command.
The decimal display still shows E. The stack value is also E, so the LED bar shows 1110 in the right hand side nibble. The left hand side nibble shows 1000, indicating that one value is stored on the stack.
- Perform an XOR operation between the switch value and the register. The opcode is 011. Set the four data switches to ones.
- Set the seven rightmost switches to 011-1111.
- Toggle the leftmost switch off and on to execute the command.
The decimal display changes to 1. The stack value on the LED display is still E (hex), or 1110 (binary).
- Pop the value from the stack. The opcode is 111, which is the extended opcode. The data must be set to 110x, where the x is a don't-care.
- Set the seven rightmost switches to 111-1101.
- Toggle the leftmost switch off and on to execute the command.
The decimal display changes to E. The stack value returns to 0, and the stack gauge indicates an empty stack.
- Clear the ALU register. The opcode is 101. The data is ignored.
- Set the seven rightmost switches to 101-1101.
- Toggle the leftmost switch off and on to execute the command.
The decimal display changes to 0. The stack value remains at 0, and the stack gauge indicates an empty stack.
- Try any other commands with which you want to experiment.
