Previous

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.

  1. Set all the input switches High to select the NOP (no operation) command. Set the SW3 switches High to the On position.

  2. From the Design Manager, select Tools Hardware Debugger or click the Hardware Debugger icon.

    figures/tbhwd.gif

    The Communications dialog box appears.

  3. 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.


    NOTE

    If 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.


  4. Select File New Project.

  5. Select the input file name: CALC.BIT and click OK.

  6. 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.

  7. Select Cable Logic Level of Pins to check that the status of the Done pin is Low.

  8. Select Download Download Design or click the following toolbar button.

    figures/bdnld.gif

    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.

    figures/bdnldver.gif

    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.


    NOTE

    The 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.

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.

  1. 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.

  2. Look up the correct opcode for the operation you want to perform and set the three opcode switches to the correct value.

  3. 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.

  1. Verify that the initial contents of both ALU and stack are all zeros. The decimal display indicates 0, and the LED bar is off.

  2. Put a 1 on the DATA switches and load the switch value to the ALU register. The opcode for the load operation is 110.

  3. Add 13 to the ALU register. The opcode for the add operation is 000.

  4. 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.

  5. Perform an XOR operation between the switch value and the register. The opcode is 011. Set the four data switches to ones.

  6. 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.

  7. Clear the ALU register. The opcode is 101. The data is ignored.

  8. Try any other commands with which you want to experiment.

Next