Previous

Completing the Calc Design

To complete the tutorial design, you need to add a few design objects to the Calc schematic using ViewDraw.

If you must stop the tutorial at any time, save your work by selecting File Save and Check from the menu bar. The results of the Check portion appear at the bottom of the ViewDraw window. You can also check all the schematic sheets in the design by selecting Tools Check Project.

Design Description

You do not create the top-level schematic of the Calc tutorial design; it already exists. Each of the blocks in the schematic, such as CONTROL or ALU, links to a second-level module that describes its logic. Additionally, any second-level module can contain another block that references a third-level drawing, and so on. This organization is known as a hierarchical structure.

In this tutorial, you add three symbols to the ALU block schematic to complete it. First, you create the ANDBLK2 and ORBLK2 symbols and their underlying schematics and then add them to the schematic. Additionally, you add the FD4RE symbol from the Unified Libraries to the ALU block. After finishing the ALU block, you add the STARTUP block to the top-level Calc schematic to tie the device's global reset network to a device pin.

The Calc design is a four-bit processor with a stack. The processor performs functions between an internal register and either the top of the stack or data input from external switches. The register stores the results of the various operations and displays them in hexadecimal on a seven-segment display. The top value in the stack displays in binary on a bar LED. A count of the items in the stack displays as a “gauge” on another bar LED.

The design consists of the following functional blocks

Before proceeding, close (quit) the Calc schematic window. If a dialog box appears asking if you want to save any changes, choose NO.

Creating the ANDBLK2 Symbol

Opening a Symbol Window

  1. Choose File Open. Set the directory to Primary and the Type to Symbol.

  2. Type andblk2.1 in the Symbol box, then select OK. A symbol editor window appears.

Creating the Symbol Outline

  1. Double-click in the box to select the Properties. You can also single-click the right mouse button to get to this dialog box. Change the Width to 150 and Height to 120. Click OK. Press F4 to center the symbol sheet.

  2. Select Add Box from the pulldown menu.

  3. Position the cursor in the upper left corner of the symbol window, two dots below and two dots to the right of the corner, and press the left mouse button.

  4. While holding down the left mouse button, move the cursor diagonally to the opposite corner of the symbol window to the point two dots up and two dots to the left of the lower right hand corner. Release the mouse button.

Adding Pins to the ANDBLK2 Symbol

  1. Select Add Pin.

  2. Select the point on the edge of the newly-created box where you want to attach the pin. A single left mouse click connects this point to the edge of the work region.

    If you make a mistake before placing a pin, use Edit Undo to undo the last command. If you make a mistake after placing a pin, first undo the Add Pin feature by selecting the icon in the Object Toolbar that looks like the mouse cursor. Select the pin with a left mouse click and delete it by selecting Edit Delete. You can also click and drag to reposition it.

  3. To add a label and properties to this pin, right click on the pin and select Properties. See the “Adding Pin Label Information for A[3:0]” figure. Under the Name tab, type A[3:0] in the Label field. Select the Attributes tab. See the “Adding Pin Attribute Information for Q[3:0]” figure. Type PINTYPE in the Name field, IN in the Value field, change the Visibility to Invisible, and click on the Set button. Then click OK. Select NO when you are asked if it should expand the label.

    Figure 8.13 Adding Pin Label Information for A[3:0]

  4. Repeat this process for input pin B[3:0] using a different label.

  5. Repeat this on the right hand side for Q[3:0], but this time use OUT for the value for the pintype.

    Figure 8.14 Adding Pin Attribute Information for Q[3:0]

  6. To adjust the positioning of the pin names, select the label with the left mouse button. Make sure the pin itself has not been selected. Click and drag to the desired location. You can also right click on the label to bring up the Properties box. Under the Color, Etc. tab, you can modify the color, font, or origin of the text. You can use one of the Middle settings for the Origin to center the text to the middle of the pin so it looks like the next figure.

Figure 8.15 ANDBLK2 Symbol with Pins and Labels Added

Adding and Modifying Text

You can add comment text to a symbol to make it more easily identifiable on a schematic, or to annotate it without modifying its function. To add text to the symbol, perform the following steps.

  1. Select Add Text.

  2. Single click in the ViewDraw window to bring up the Text Properties window.

  3. Type ANDBLK2 in the Annotation Text field of the dialog box, then press return or select OK. Use the Size field to change the size of the text to 14.

  4. Click on the cursor icon, then use the left mouse button to select the text field. Click and drag the text to the top of the box. See the “Completed ANDBLK2 Symbol” figure.

To modify the text after it has been placed, select the cursor icon and double click on the text. This brings up the text properties box, where you can modify the size, color, font, and orientation of the text, as well as edit the text itself. You can use this method to modify any text on the symbol, such as pin names.


NOTE

You use labels and text for completely different purposes. Labels differentiate nets, buses, pins and components, passing these strings on into the Edif netlist and beyond. Text annotates symbols and schematics with information for documentation purposes. Text does not pass onto any netlists beyond the wire files.


Figure 8.16 Completed ANDBLK2 Symbol

Saving the ANDBLK2 Symbol

To save the ANDBLK2 symbol, perform the following steps.

  1. From the menu bar, select File Save.

  2. Check to see that the information displayed is the same as that in the “Output from Check” figure. If the output differs, correct the symbol to eliminate the differences and then save the symbol again.

    Figure 8.17 Output from Check

  3. Close the text window.

Creating the ORBLK2 Symbol

Create the symbol for ORBLK2, as shown in the “Completed ORBLK2 Symbol” figure. Because ORBLK2 is similar to ANDBLK2, use the ANDBLK2 symbol and modify the text.

  1. Move the cursor above the ANDBLK2 text. Double-click on the text.

  2. In the Text Properties dialog box, type ORBLK2 in the Annotation Text field, then select OK.

    Figure 8.18 Completed ORBLK2 Symbol

  3. If necessary, move and center the text, as described earlier.

  4. From the menu bar, select File Save Copy As.


    WARNING

    You must select the Save Copy As command instead of Save to prevent overwriting the original ANDBLK2 symbol file.


  5. Select Primary as the Directory and type ORBLK2 in the Symbol field.

  6. Select OK to execute the command. This saves the symbol as ORBLK2.

  7. Close the window containing the symbol.

  8. A dialog box appears prompting you to save the changes to ANDBLK2. Because you saved the symbol for ANDBLK2 prior to modifying it for the ORBLK2 symbol, you do not have to save changes to the ANDBLK2 symbol. Select “No.”

Creating Schematics for ANDBLK2 and ORBLK2

So far, you created symbols for ANDBLK2 and ORBLK2. The next step involves creating schematics for these blocks. You can then reference the schematics in a higher-level schematic by placing the symbols.

Opening a Schematic Window

  1. To open a schematic window, select File Open. A dialog box appears.

  2. Set the Directory to Primary and the Type to Schematic, then type andblk2.1 in the Schematic field, then select OK. A blank schematic sheet appears.

  3. Double-click on this sheet to bring up the Schematic Properties. Change the Width to 1100 and Height to 750. Click OK. Press F4 to center the schematic sheet.

Adding the First Component to a Schematic

  1. From the menu bar, select Add Component.


    NOTE

    Use the Unified Libraries for new designs. All design elements should come from the Xilinx Unified Library, LogiBLOX, or a user-created library; do not place any component from the Builtin, Xbuiltin, or Simprims libraries on your schematics. Also, the Add Component command does not place LogiBLOX components directly on the schematic. See the “Using LogiBLOX” section of this tutorial for more information.


  2. Select the XC4000E library under the Directory header. The components in this library appear in the left side of the Add Component window.

  3. Select AND2.1 with a left mouse button click. You can also type AND2 in the Symbol box. Then, click on the symbol that appears in the right hand side of the Add component window and move the cursor into the schematic window.

  4. Move the symbol outline to the location shown in the figure that follows and then click the left mouse button to place the object.

Figure 8.19 Placing a Component

Placing Additional Components

After placing the AND2, notice that the symbol for the AND2 still appears in the Add Component box. To place more components, simply repeat the click and move process to place more components of any type onto your schematic. When completed, use the Close button to close the Add Component box.

Copying a Component

You can also use the Copy command to add more components by copying a component that already appears on the schematic.

  1. Select the AND2 component.

  2. Select Edit Copy.

  3. Select Edit Paste.

  4. Place the cursor at the target location of the copied AND2 component and click the left mouse button.

  5. Repeat steps 3 and 4 (or use the Add Component command) until you have a total of four AND2s. Use the View pulldown to change the size and location of the working window. Note the function hot keys for these commands.

Moving a Component

If you make a mistake when placing a component, you can easily move the component.

  1. Select the component to move. Make sure that no other components are selected.

  2. Click and drag with the left mouse button to correctly place the component.

Press F4 to view the entire schematic. The schematic now looks like the next illustration.

Figure 8.20 Component Placements for ANDBLK2

Adding Buses to a Schematic

You can draw a set of signals as a bus rather than as several separate wires. You do not have to physically connect a bus to the nets that make up the bus. Several schematics in the Calc design have short bus segments that connect to nothing, so that a bus pin can represent the bus on the symbol. A bus must exist on the schematic if you use a bus pin is for a set of signals.

Add buses to the schematic as follows.

  1. Select Add Bus. Note the now-depressed Bus icon on the Object Toolbar. Pressing this button returns you to “Add Bus” mode.

  2. Draw a bus by clicking the left mouse button to specify the starting point, then dragging the mouse (while holding the left mouse button) to a new position. While holding the left mouse button, click the right mouse button to make a bend in the bus. Terminate the bus by releasing the left mouse button. Add the three buses shown in the “ANDBLK2 Schematic with Buses” figure. You can change the schematic view before adding the buses.

    If you make a mistake, click on the bus segments you want to delete so that they appear highlighted. Select Edit Delete to remove the bus segments.

  3. After adding the three buses, press the Escape key to exit the bus adding mode.

Figure 8.21 ANDBLK2 Schematic with Buses

Adding Nets to a Schematic

Add nets to attach the appropriate pins on the gates to the buses. You can enlarge the view of the schematic to make it easier to draw the nets.

  1. Select Add Net. Note the now-depressed Net icon on the Object Toolbar. Pressing this button returns you to “Add Net” mode.

  2. Move the cursor to the top input pin of the top AND2 gate, then click and drag the left mouse button.

  3. Move the cursor to the left to a position directly above top of the left-most bus, so that the wire forms a ninety degree angle with the bus. Release the left mouse button to terminate the net. See the next figure.

Figure 8.22 Connecting a Net

You need only this physical connection to logically connect a net to a bus. Bus rippers are not supported. However, the name of the net must have the same root name of the bus plus an index. For example, with a bus named A[3:0], you must label the net that is bit zero of bus A A0. You need no parentheses for the net name.

Completing the Net Connections

Add the remaining nets and labels to the schematic as shown in the following figure.

Figure 8.23 Completed ANDBLK2 Schematic

Adding Labels to Nets and Buses

To add a label to a bus or net, simply double-click on that net or bus. In the Net Properties box that pops up, add the name in the Label field. For buses, include the bounds using square brackets, as shown in the “Net Properties Dialog Box” figure.

You can also change the size of the text in this dialog box by changing the number in the Size field. All of the existing labels in this tutorial are 14 point. You can also change the default text size by choosing Project Settings and changing the Size under the Text tab. Click OK.

Figure 8.24 Net Properties Dialog Box

If you accidently select any elements besides the net or bus you want to label, press F2 and repeat the selection procedure.

To reposition a label, single-click on the label so that the net or bus is deselected. Click and drag the label to the final position.

Connectivity

You make the logical connection between the symbol and its underlying schematic simply by name. You find the name of each pin on the symbol in its corresponding schematic; no special connecting components are required. Naming the buses A[3:0], B[3:0] and Q[3:0] achieved the connectivity between the schematic and symbol. The Check program produces an error if a symbol pin is not represented on the underlying schematic.

Saving the Schematic

The schematic is now complete. Check and save the schematic by selecting File Save and Check. If no dialog box pops up, you see the following message at the bottom of the screen.

Check complete. 0 errors and 0 warnings in project ANDBLK2

If you do not see this message, check the errors in the dialog box and correct them before saving again.

Creating Schematic for ORBLK2

The ORBLK2 schematic is similar to the ANDBLK2 schematic. To create schematics for the ORBLK2 symbol, you can use the ANDBLK2 schematic and replace the four AND2 gates with four OR2 gates.

  1. Select the first AND2 gate with the left mouse button.

  2. While holding the Ctrl key, use the left mouse button to select the remaining three AND2 gates. This selects all four AND2 gates. See the figure that follows.

    Figure 8.25 Selecting Gates

  3. Choose Edit Replace to bring up the Find dialog box

  4. In the Object Type box, select Component. In the Expression box, <Selected Components> appears.

  5. In the Replace With box, type OR2. You can also use the lower Browse button to search through your libraries to find the desired replacement component. Choose OR2.1 from the XC4000E library.

  6. Click on the Replace button, then the Close button. You can see that the four selected AND2 gates changed to OR2 gates. See the next illustration.

    Figure 8.26 Completed ORBLK2 Schematic

  7. Select File Save Copy As. A dialog box appears.


    WARNING

    You must select the Save Copy As command instead of Save to prevent overwriting the original ANDBLK2 schematic file.


  8. Choose the Primary library and type ORBLK2.1 in the Schematic box and click OK.

  9. Close the only open window (the modified ANDBLK2 schematic) using the X button in the upper right corner of the window. A dialog box appears asking whether to save the changes to the schematic. Select No, because you saved the ANDBLK2 schematic earlier, but then modified it for use as the ORBLK2 schematic.

Editing the ALU Schematic

So far, you created symbols for ANDBLK2 and ORBLK2, and the underlying schematics for these symbols. Next, place the symbols in the ALU block schematic.

  1. Choose File Open.

  2. Select CALC.1 from the Primary library. Click OK. The Calc design appears. Use the View commands to resize the window, if necessary.

  3. Select the ALU symbol.

All additions you need to make reside in the ALU schematic; click the right mouse button and select Schematic. This pushes into the schematic below the ALU symbol.


NOTE

To navigate through the hierarchy, you can use a right mouse button click to select a lower level symbol or schematic if the component is selected, or another sheet of the same schematic if you selected no symbol. Buttons also exist for these commands on the View Toolbar.


Placing User-Created Components

You can now place the ANDBLK2 and ORBLK2 symbols on the schematic, as shown in the “Adding ANDBLK2 and ORBLK2 to ALU Schematic” figure. You can place the symbols using the same procedure you used to place the AND2 gate from the Xilinx libraries when you created the ANDBLK2 schematic.

  1. Use the View menu commands to zoom into the empty area near the center of the schematic, between the XORBLK2 and ADSU4 symbols.

  2. Choose Add Component. A dialog box appears.

  3. Select the ANDBLK2 schematic from the Primary library.


    NOTE

    Take all user-defined blocks that you add to your design from the Primary directory (or other user-created library directories), not the discrete path that describes the project directory. This ensures adding the proper aliases to the instantiated components and avoids problems further along in your flow.


  4. Drag a copy of this component from the Add Component window onto the schematic.

  5. You can reposition the symbol after placing it on the sheet. If you move the ANDBLK2 component after placing it correctly, notice that the two buses connected to the symbol move as well. This shows a successful connection.

    Figure 8.27 Adding ANDBLK2 and ORBLK2 to ALU Schematic

  6. Follow the same procedure to add the ORBLK2 symbol. Refer to the ALU schematic in the previous figure for proper placement. If you make a mistake when placing a component, use Edit Undo to step back.

Placing Library Components

Add the FD4RE and AND5B2 components to the ALU schematic. Both of these components reside in the Xilinx Unified Libraries. The FD4RE component consists of four flip-flops with clock enables. The AND5B2 component is a five-input AND gate with two inputs inverted (“bubbled,” hence the “B”).


NOTE

These components reside in all libraries, including those for the XC4000E and XC9500.


  1. Use the View commands to zoom into the open area in the lower right-hand corner.

  2. Select Add Component from the menu bar.

  3. Select the XC4000E library.

  4. Select the FD4RE component by using the scroll bar in the component window or by typing the name in the Symbol field.

  5. Move the component to lower right corner of the schematic, approximately to the location shown in the “Adding FD4RE and AND5B2 to ALU Schematic” figure.

  6. Click the left mouse button to place the component.

  7. Repeat steps 2-6 to place an AND5B2 component next to the FD4RE as shown in the figure that follows. When choosing the component from the library menu, select AND5B2.

Figure 8.28 Adding FD4RE and AND5B2 to ALU Schematic

Adding Nets, Buses, and Labels

This section includes information on adding nets, buses, and labels to the FD4CE and AND5B2 symbols, and on completing the addition of ANDBLK2 and ORBLK2 to the ALU schematic.

FD4CE and AND5B2

Complete the addition of the FD4RE and AND5B2 symbols by adding nets, buses, and labels as follows.

  1. Add the necessary nets and buses to complete connections for FD4RE and AND5B2 as you did for the previous schematic. The “Nets, Buses and Labels for FD4RE and AND5B2” figure displays the labeled nets and buses for FD4RE and AND5B2.

  2. To add net labels and attributes to nets, double-click on the net. Add net labels in the Name Label field and add any attributes under the Attributes tab. The nets appear as shown in this figure.

  3. Increase the size of the label text as described earlier, if necessary.

Figure 8.29 Nets, Buses and Labels for FD4RE and AND5B2

ANDBLK2 and ORBLK2

Next, complete the addition of ANDBLK2 and ORBLK2 to the ALU schematic.

  1. Add the necessary buses to complete connections for ANDBLK2 and ORBLK2. The “Nets, Buses and Labels for FD4RE and AND5B2” figure displays the labeled nets and buses for ANDBLK2 and ORBLK2.

  2. Use this figure as a reference to name the added buses. Label the output buses of the two components because the inputs to these components connect to pre-labeled buses.

Adding Labels to Components

Add labels to components. Error and warning messages often reference component labels, and labels also appear in simulation netlists. References to net names at lower levels of hierarchy use the following format.

...component_label\component_label\net_label

In the ALU schematic, labels already exist for the MUXBLK2, XORBLK2, and MUXBLK5 blocks.

To add a label to the ORBLK2 placement, follow these steps.

  1. Double-click on the ORBLK2 symbol.

  2. Under the Name tab, enter ORBLK2 in the Label field. Click OK.

    Figure 8.30 Adding Component Labels to ALU Schematic

  3. To move the label, select the label text only. Click and drag to the position shown in the “Completed ALU Schematic” figure.

  4. Label the ANDBLK2 symbol the same way using the label ANDBLK2, as shown in the “Completed ALU Schematic” figure.

  5. Give the FD4RE component the label ALUVAL.

The completed ALU schematic appears in the following figure.

Figure 8.31 Completed ALU Schematic

Saving the ALU Schematic

Check and save the schematic. If errors occur, resolve them and then check and save the schematic again.

Exploring Xilinx Library Elements

The Xilinx libraries contain three types of elements.

You place all three types of library elements on a schematic in exactly the same way.

Viewing a Xilinx Soft Macro Schematic

Soft macro schematics resemble the schematics you create for your own designs. In fact, you can load one of these schematics and use the File Save Copy As command to save it under another name. You can then edit this new schematic to customize it to your needs.

Open the schematic underneath the FD4RE symbol as follows.

  1. Select FD4RE with the left mouse button.

  2. With the right mouse button, select Schematic. As shown in the next illustration, FD4RE consists of four FDRE symbols.

Figure 8.32 FD4RE Schematic from XC4000E Library

Viewing a Xilinx RPM (XC4000E/EX, XC5200 Families Only)


NOTE

The following description of RPMs contains detailed information on the XC4000E architecture. Refer to The Programmable Logic Data Book for more information about the XC4000E CLB structure and fast carry logic.


If your design does not target the XC4000E family, read this section, but do not perform any of the commands. Continue the tutorial with the “Completing the Calc Design” section.

The ALU contains a component from the Xilinx library, ADSU4, a four-bit wide adder/subtracter. If your design targets the XC4000E library, this schematic implements as a Relationally Placed Macro (RPM). If your design does not target the XC4000E library, ADSU4 implements without this placement information.

RPM schematics resemble schematics you create for your own designs. In fact, you can load one of these schematics and use the File Save Copy As command to save it under another name. You can then edit this new schematic to customize it to your needs.

Elements placed in the ADSU4 RPM schematic include CY4 components and FMAPs. The CY4 symbol gives you the ability to specify fast carry logic functionality from the schematic. Fast carry logic, a hardware feature in XC4000E parts, allows very fast arithmetic-type functions.

The FMAPs map logic functions to function generators in Configurable Logic Blocks (CLBs), arranged in a rectangular grid in the die. Both CY4 symbols and FMAP symbols have RLOC attributes. RLOCs attach to the symbols that assign relative locations to the CLBs. You can use carry symbols as well as FMAPs and other mapping components in your own schematics. However, knowledge of them is not necessary to use RPMs. Do not create new macros containing carry logic and FMAPs unless you are an expert user. For a description of these components, see the Libraries Guide.

Push into the ADSU4 schematic as follows.

  1. Select ADSU4 with the left mouse button.

  2. With the right mouse button, select Schematic. The ADSU4 schematic appears.

  3. Use the View commands to zoom into the upper portion of the schematic as shown in the “Upper Portion of the ADSU4 RPM Schematic” figure.

  4. Select the FMAP component in the upper right corner.

    Figure 8.33 Upper Portion of the ADSU4 RPM Schematic

  5. Double-click on the FMAP symbol. A dialog box appears displaying the attributes on the symbol. Select the Attributes tab as shown in the “RLOC Attribute on FMAP Component” figure. The RLOC attribute is set to R0C0.G, indicating that this function maps to the G function generator of the upper-left corner (row zero, column zero) CLB in the RPM. RPM origins appear in the upper left-hand corner.

    Figure 8.34 RLOC Attribute on FMAP Component

  6. Close the dialog box to return to the adsu4 schematic window.

  7. Use the scroll bars on the sides of the window to pan around the schematic and look at the RLOCs. Note that logic maps to three CLBs, designated as R0C0, R1C0, and R2C0. Therefore, this RPM uses three CLBs arranged in a column. You can find information on the number of CLBs used and the shape of the logic block for each RPM in the Libraries Guide. Note that these locations are relative, not absolute. The macro is not defined as placed in the uppermost CLB in the left most column. Regardless of what the RPMs absolute location, the logic associated with the FMAP with the location R0C0 always appears at the top, R1C1 in the CLB directly below, and so on.

  8. Close the ADSU4 schematic and return to the ALU schematic.

Opening the Calc Schematic

Close all open schematic or symbol windows except for the top-level Calc schematic window. If you closed the Calc window, re-open it. The Calc schematic appears on the screen.

Using the XC4000E Oscillator

If your design does not target the XC4000E family, read this section, but do not perform any of the commands.

The XC4000E family devices contain an on-chip clock generator, which makes it unnecessary to use an external circuit for this purpose. The on-board clock circuitry, while not precise, suits designs that do not need a highly accurate clock, such as the Calc design. Refer to the following figure.

Figure 8.35 CLOCKGEN Schematic

The CLOCKGEN schematic contains an XC4000E library part, OSC4. This symbol represents the on-chip oscillator that generates nominal clock frequencies of 8 MHz, 500 KHz, 16 KHz, 490 Hz, and 15 Hz. The Calc design uses the 15-Hz output from this component when targeted for XC4000E family designs. The clock output from OSC4 buffers through a BUFG global clock buffer.

XC4000E family devices have eight on-chip clock buffers: one BUFGP (primary global buffer) and one BUFGS (secondary global buffer) in each corner of the device. Although you can use them for other purposes, BUFGPs work best when routing externally-generated clock signals. BUFGSs offer more flexibility; use them to route any large fan-out net, even one internally sourced. A BUFG symbol can represent either type of buffer, and allows the implementation software to choose which type of global buffer works best in each situation. BUFG also facilitates design retargeting to other Xilinx device families, because it can represent any type of global buffer in any family. The BUFG in the Calc design substitutes for a BUFGS during design implementation, because the clock generates internally by the on-chip oscillator. See the Libraries Guide and The Programmable Logic Data Book for more information about global clock buffers for Xilinx devices.

Next