Previous

Design Entry

In this hierarchical design, you will create various types of macros, including schematic-based macros, HDL-based macros, state machine macros, and LogiBLOX macros. You will learn the process for creating each of these types of macros, and then you will connect them all together to create the completed Watch design. This tutorial gives you experience with creating and using each type of design macro so that you can apply this knowledge to your own design.

Starting the Schematic Editor

There are two different ways to open the Schematic Capture tool.

The Schematic Editor opens with the Watch schematic sheet loaded. The Watch schematic is incomplete at this point. Throughout the tutorial, you create the components to complete the design. The unfinished design is shown in the figure below.

Figure 4.4 Incomplete Watch Schematic

If you need to stop the tutorial at any time, save your work by selecting File Save from the pulldown menus.

Executing Commands

There are three ways to execute commands within the Foundation tools: pulldown menus, hotkeys, and toolbar buttons. In most cases, this tutorial instructs you to use the pulldown menus.

Hotkeys

You can use the keyboard to execute various commands. These “hotkeys” are listed next to the commands within the pulldown menus. Some of the hotkeys are the function keys, some are single letters, and some require the Ctrl or Alt keys. You cannot customize them.

Toolbar Buttons

There are also toolbars that are located beneath the pulldown menus and to the left of the main Schematic Editor window. Hold your mouse over the buttons to see their function.

Figure 4.5 Schematic Editor

Manipulating the Screen

Under the Display pulldown menu is a series of commands that modify the viewing area of the Schematic Editor window. Zoom in the schematic to comfortably view it.

Creating a Schematic-Based Macro

A schematic-based macro consists of a symbol and an underlying schematic. You can create either the underlying schematic or the symbol first, and the tools can automatically generate the corresponding symbol or schematic file, respectively. In the following steps, you create a schematic-based macro by first creating the symbol using the Symbol Wizard. A template schematic file is then created by the tools, and you complete the schematic with the appropriate logic. The created macro is then automatically added to the project's library.

The macro you will create is called CNT60. CNT60 is a binary counter with two 4-bit outputs, which represent the Ones and Tens values of the stopwatch. The counter counts from 0 to 59, decimal.

  1. Select Hierarchy New Symbol Wizard. The Design Wizard opens.

    The Design Wizard guides you through the process of creating a macro symbol. It also creates a “skeleton” file based on the pins you define and the type of macro (schematic, ABEL, VHDL, or state machine). The State Editor and the HDL Editor (described later in this tutorial) also use the Design Wizard.

  2. Click Next.

  3. In the Symbol Name field, type CNT60. In the Contents section, select Schematic. This tells the tool that the underlying file for the symbol is a schematic.

    Figure 4.6 Symbol Wizard - Contents Page

  4. Click Next.

  5. Click New to create a new pin. In the Name field, type CE. Check that the direction of the pin is set to Input.

  6. Repeat Step 5 for input pins CLK and CLR.


  7. Repeat Step 5 for output bus pins LSBSEC[3:0] and MSBSEC[3:0]. To create a bus pin, type the name of the bus in the Name field (that is, LSBSEC), and then use the up/down arrows in the Bus field to set the bounds of the bus (that is, 3:0). Check that the Direction of the pin is set to Output.

    Figure 4.7 Symbol Wizard - Ports Page

  8. Click Next.


    NOTE

    In the Comments section, you can type text that appears on the symbol when it is placed. You can also define a longer comment that only appears in the SC Symbols window when you place components.


  9. Click Next and then click Finish.

    The symbol is created and placed in the project library and can be accessed from the SC Symbols toolbox. The Symbol Wizard automatically creates and opens a schematic sheet with I/O terminals corresponding to the defined symbol pins.


    NOTE

    If the schematic is not automatically created, the most likely cause is that Empty was selected in step 4. Repeat steps 1-9, and click Yes or OK when prompted to overwrite the existing symbol.


Creating the CNT60 Schematic

You have now created the symbol for CNT60 with the help of the Symbol Wizard. The next step is to create the underlying corresponding schematic for this macro. You can then reference this macro symbol by placing it on a schematic sheet.

Opening the Schematic

  1. If the CNT60 schematic is not open, select File Open. The Open Sheet dialog box opens. Click Browse, select cnt60.sch from the files list, then click OK.

  2. Zoom in or out until all of the Hierarchy Connectors are clearly visible. The hierarchy connectors represent connections between this schematic sheet and the pins of the corresponding symbol.

Figure 4.8 CNT60 Schematic Hierarchy Connectors

Connectivity - Hierarchy Connectors

Hierarchy Connectors logically connect the CNT60 symbol and its underlying schematic. The name of each pin on the symbol must have a corresponding connector in the underlying schematic.

The Symbol Wizard automatically places hierarchy connectors on the schematic. If you need to add hierarchy connectors manually, you can use the Hierarchy Connector icon in the vertical toolbar.

figures/hier_connect_icon.gif

When you save a macro, the Schematic Editor checks the hierarchy connectors against the corresponding symbol. If there is a discrepancy, you can let the software update the symbol automatically, or you can modify the symbol manually. Hierarchy connectors should only be used to connect signals between levels of hierarchy. Never use hierarchy connectors on top-level schematic sheets.

Project Libraries

When you create a new project in Foundation, three libraries are automatically added to the project: the appropriate device family library based on the target family you have chosen (for example, xc4000e), the project library (with the same name as the project), and the SIMPRIMS library (for simulation). All libraries which are part of the project are listed in the Files tab of the Project Manager. You can double click on any of these libraries to see the contents of the library.

Figure 4.9 Project Libraries

The device family library (XC4000E for this project) contains all of the Xilinx Unified Library components for the given family. A complete description of all of these components can be found in the DynaText Xilinx Libraries Guide.

The project library (WTUT_SC for this project) is a writable library containing user-created macros. Any macro you create in this project is automatically placed in this library.

Additionally, you can copy macros from other libraries into this project library and vice versa using the Schematic Symbols Library Manager which you can open with the Tools Utilities menu in the Project Manager.

To facilitate simulation with the Foundation Logic Simulator, the SIMPRIMS is added to the project. This library contains the simulation models for the Xilinx devices.

You can add more libraries to the project by choosing File Project Libraries from the Project Manager. After you add a library to the project, you can use any component from that library in the current project.

Adding Components to CNT60

Components from all of the libraries (except SIMPRIMS) for the given project are available from the SC Symbols toolbox to place on the schematic. The available components listed in this toolbox are arranged alphabetically within each library.

  1. From the menu bar, select Mode Symbols or click the Symbols Toolbox button in the vertical toolbar on the left side of the Schematic Editor.

    figures/sc_symbol_icon.gif

    This opens the SC Symbols window and displays the libraries and their corresponding components.

    Figure 4.10 SC Symbols Toolbox

  2. The first component you will place is an AND2, a 2-input AND gate. You can select this component by either scrolling down the list and selecting it or by typing AND2 in the bottom of the SC Symbols Window. Then move the mouse back into the schematic window.

    In the SC Symbols window, when the AND2 component is selected, a description of the component appears in the bottom of the window.

  3. Move the symbol outline to the location shown in the following figure and click the left mouse button to place the object.

Figure 4.11 Completed CNT60 Schematic


NOTE

The preceding schematic illustrates the completed CNT schematic. Use this figure as a reference for drawing nets and buses in the following subsections.


Correcting Mistakes

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

  1. Press the Esc key on the keyboard to exit the Symbols Mode.

  2. Select the component you want to move or delete. Make sure that no other components are selected (clicking on a blank area of the schematic deselects everything).

  3. Click and drag to correctly place the component, or press the Del key on the keyboard or the Cut icon in the toolbar to delete the component.

Placing the Remaining Components

Follow the steps listed previously in the “Adding Components to CNT60” section to place the CD4CE, OR2, CB4RE, INV, and AND4 components on the schematic sheet as shown in the “Completed CNT60 Schematic” figure. For a detailed description of the functionality of each of these components, refer to the Xilinx Libraries Guide.

Moving Hierarchy Terminals

To make the schematic easier to draw and clearer to read, move some of the hierarchy connectors which were automatically created by the Symbol Wizard. Follow these steps to relocate the hierarchy connectors as shown in the “Completed CNT60 Schematic” figure.

  1. With the mouse cursor in point/select mode, select the CLR hierarchy connector, and drag it to the lower left area of the schematic sheet. If the mouse cursor is not in point/select mode, Press the Esc key on the keyboard to get into this mode.

  2. To move the bus hierarchy terminal MSBSEC[3:0], select and drag an area surrounding the entire bus hierarchy terminal and label it, so that both the bus and the label are highlighted in red. With the bus and label highlighted, click on the terminal again, and drag the entire unit down to the lower right area of the schematic sheet. Release the mouse to place the terminal, and then click anywhere else on the schematic sheet to deselect the bus and label.

Drawing Nets

You use the Draw Wires icon in the vertical toolbar to draw wires (also called nets) between the various components on the schematic. Use Nets to physically connect single bits together.

Signals can also logically be connected by naming multiple segments identically. In this case, the nets do not need to be physically connected on the schematic to make the logical connection. In the CNT60 schematic, you will draw nets to connect the components together. Do not yet worry about drawing the nets for the LSBSEC and MSBSEC buses. These nets will be drawn in the next section.

Follow these steps to draw a net between the AND2 and the CB4RE components on the CNT60 schematic.

  1. Click the Draw Wires icon in the vertical toolbar.

    figures/draw_wire_icon.gif

  2. Click the source symbol pin (output pin of the AND2), then click on the destination pin (CE pin on the CB4RE). The net will automatically be drawn between the two pins.


    NOTE

    You can specify the shape of the net by moving the mouse in the direction you want to draw the net and then single-clicking to create a 90-degree bend in the wire.


Draw the nets to connect the remaining components as shown in the “Completed CNT60 Schematic” figure. To draw a net between an already existing net and a pin, click once on the component pin and once on the existing net. A junction point will be drawn on the existing net.

You should now have all the nets drawn except those connected to the LSBSEC and MSBSEC buses. You will draw these in the next section.

Adding Buses

Sometimes it is convenient to draw a set of signals as a bus rather than as several separate wires. You have the option to group signals in the form of a bus and “tap” this bus off to use each signal individually. In this CNT60 schematic, you will create two buses, each comprised of the 4 output bits of each counter. These buses will be named LSBSEC[3:0] and MSBSEC[3:0], and they will also be connected to hierarchy connectors to connect them to the CNT60 symbol.

Add buses to the schematic as follows.

  1. Select Mode Draw Buses or click the Draw Buses button in the vertical toolbar to get into the Draw Buses mode.

    figures/draw_bus_icon.gif

  2. The CNT60 schematic has some bus “stubs” connected to Hierarchy Connectors which represent the symbol pins on the CNT60 macro symbol as defined with the Symbol Wizard.

    Click the end of the LSBSEC[3:0] stub, then move the mouse to a new position. Click to make a corner in the bus.

  3. Terminate the bus by either double clicking with the left mouse button, or single-clicking with the right mouse button. This opens the Add Bus Terminal/Label dialog box where you can define the bus name, width, and the type of terminal you want to use.

  4. In the Add Bus Terminal/Label dialog box, change the Terminal Marker type to None by choosing this selection from the pulldown menu. This sets the type of terminal for the point where you are terminating the bus. Do not change any of the other settings. Click Bus End (the bus name and width were defined with the Symbol Wizard, so it is unnecessary to redo this here).

    Figure 4.12 Creating Bus Ends

  5. Repeat Steps 2 through 4 for the MSBSEC[3:0] bus.

  6. If you make a mistake, press the Esc key on the keyboard to exit the Draw Buses mode. Then click the bus you want to delete so that it is highlighted. Press Del to remove the bus.

  7. After adding the two buses, press Esc or right-click to exit the Draw Buses mode.

Adding Bus Taps

Next, you add nets to attach the appropriate pins from the CB4RE and CD4CE counters to the buses. Use Bus Taps to tap off a single bit of a bus and connect it to another component. The Schematic Capture tool can automatically name the bus taps incrementally as they are drawn.

You have the option to enlarge the view of the schematic to make it easier to draw the nets.

  1. Select Mode Draw Bus Taps or click the Draw Bus Taps button in the vertical toolbar. The cursor changes, indicating that you are now in Draw Bus Taps mode.

    figures/bus_tap_icon.gif

  2. Click the LSBSEC[3:0] bus label.

    The status bar at the bottom of the window displays the message Expand Bus Tap: LSBSEC3. This tells you that the next bus tap drawn will be labeled LSBSEC3.


    NOTE

    The default is to start at 3 and decrement as bus taps are drawn. You can use the up and down arrow keys to change which bus bit will be tapped first.


  3. Click the Q3 output pin of the CD4CE component to draw the bus tap. The net is automatically drawn and labeled. The status bar now reads Expand Bus Tap: LSBSEC2.

  4. Click next on each of the other output pins of the CD4CE component. The bus taps will be drawn and labeled incrementally.


    NOTE

    If the bits are not automatically being labeled incrementally, check that you clicked the bus name (label) before clicking the counter output pins.



    NOTE

    If the nets appear disconnected, try selecting Display Redraw to refresh the screen.


    If there is an error with the labeling of the bus taps, double click the bus tap net to edit the label.

  5. Repeat Steps 1 through 4 for the MSBSEC[3:0] bus.

  6. Press Esc twice or right-click to exit the Draw Bus Taps mode.

  7. Complete the schematic by drawing the nets to connect the MSBSEC bus taps to the INV and AND4 components. If necessary, refer to the “Drawing Nets” section for guidance.

  8. Compare your CNT60 schematic again with the “Completed CNT60 Schematic” figure to ensure that all connections are properly made.

Saving the Schematic

The CNT60 schematic is now complete.

Save the schematic by selecting File Save or clicking the Save icon in the horizontal toolbar.

figures/save.gif

All errors, warnings, and informational messages are displayed in the Message Window in the Project Manager. If any errors are issued, resolve them and save the schematic again.

Placing the CNT60 Macro

So far, you have created the CNT60 macro. The next step is to place this macro on the top-level Watch schematic sheet, where it may then be connected to other components in the design.

  1. Open the Watch schematic sheet. If the Watch schematic is already open, you will see a tab at the bottom of the Schematic Capture tool where you can select that sheet.

  2. If the Watch schematic is not open, select File Open, select the Watch sheet, and click OK.

  3. Open the SC Symbols Toolbox to display a list of all the available design components. As mentioned before, you can select the Symbols Toolbox icon to open the SC Symbols Toolbox.

    figures/sc_symbol_icon.gif

  4. Near the top of the SC Symbols Toolbox, there is a header with the name of the project representing the current project library. Beneath this, find the newly created CNT60 macro in this list. Select this component.

  5. Place the CNT60 macro as shown below.

    Figure 4.13 Placing the CNT60 Macro

  6. Press Esc to exit the Symbols mode. The cursor now returns to the standard “point and select” mode.

    Notice that the SC Symbols window remains open. With this window open, you can quickly place additional symbols without having to click on the Symbols Toolbox icon again. If you want to close the SC Symbols window, click the `-' button in the upper left corner of the window.

  7. Do not yet worry about connecting nets to the pins of the CNT60 symbol. You will do this later in the tutorial after you add the other components to the Watch schematic.

Creating a LogiBLOX Module

LogiBLOX is a graphical interactive design tool that you use to create high-level modules such as counters, shift registers, RAM, and multiplexers. You can customize and pre-optimize the modules to take advantage of the inherent architectural features of the Xilinx FPGA architectures, such as Fast Carry Logic for arithmetic functions and on-chip RAM for dual-port and synchronous RAM.

In this design, you create a LogiBLOX module called Tenths. Tenths is a 10-bit one-hot encoded counter. It counts the tenths digit of the stopwatch's time value. To better see the digit when it is downloaded on the FPGA Demonstration Board, the encoding is set to one-hot. The series of LED lights displays the Tenths digit, where one light is on for each count of the tenths digit.

You use the LogiBLOX Module Selector GUI to select the type of module you want to create, as well as the specific features of the module. You may invoke this GUI from either the Project Manager, the Schematic Editor, or the HDL Editor. The operation of the tool is the same regardless of where you invoke it.

  1. From within the Schematic Editor, select Options LogiBLOX.

  2. Fill in the Logiblox Module Selector with the following settings:

  3. “Check” or “uncheck” the appropriate boxes on the module diagram so that only the following pins are used.

    Q_OUT, Clock Enable, Async Control, Terminal Count

    Figure 4.14 LogiBLOX Module Selector

  4. Click OK. The module is created and automatically added to the project library. Additionally, it will be automatically attached to the cursor to immediately place on the schematic.



    NOTE

    If you do not want to place the symbol at this time, you can press the Esc key on the keyboard to get out of the Place Symbol mode. You can then select it at any time from the SC Symbols Toolbox to place on the schematic.


  5. Place the newly created Tenths component on the Watch schematic sheet, as shown below. You will connect this symbol to the rest of the schematic later in the tutorial. The symbol is labeled “L1” on the schematic sheet.

    Figure 4.15 Placing the Logiblox TENTHS component

  6. Save the schematic by selecting File Save. Close the Schematic Editor.

Creating a State Machine Module

With the Foundation State Editor, you graphically create finite state machines. You draw states, inputs/outputs, and state transition conditions on the diagram using a simple windows GUI. Transition conditions and state actions are typed into the diagram in appropriate VHDL, Verilog, or ABEL syntax. The State Editor then synthesizes the diagram into either VHDL, Verilog or ABEL code. The resulting HDL file is finally synthesized to create a netlist and/or macro for you to place on a schematic sheet.

For this tutorial, a partially complete state machine diagram is provided. In the next section, you complete the diagram and synthesize the module into a macro to place on the Watch schematic. Both a VHDL and an ABEL version of the State Machine diagram have been provided for you.

If you have a Foundation Express package, you can use either the VHDL or ABEL version. If you have a Foundation Standard or a Foundation Base package, then you must use the ABEL version of the diagram.

Opening the State Editor

To invoke the State Editor, click the State Editor button in the Flow tab of the Project Manager.

figures/fsm_flow.gif

A dialog box prompts you to select a document. Click Existing Document, click OK, and then select STMACH_V.ASF (VHDL) or STMACH_A.ASF (ABEL) to open the partially completed stopwatch state machine.

The unfinished State Machine diagram is shown below.

Figure 4.16 Incomplete State Machine Diagram

In the State Machine diagrams, the transition conditions and the state actions are written in proper HDL syntax, either VHDL or ABEL.

In the following section, you add the remaining states, transitions, actions, and also a reset condition to complete the state machine.

Adding New States

Complete the state machine by adding a new state called CLEAR.

  1. Click the State icon in the vertical toolbar.

    figures/add_state_icon.gif

    The state bubble is now attached to the cursor.

  2. Place the new state on the left-hand side of the diagram as shown below. Click the mouse to place the state bubble.

  3. The state is given a default name, in this case S1. Double click the S1 in the state bubble, and change the name of the state by typing CLEAR. The name of the state is for your use only; it does not affect the synthesis, and so you can name it whatever you want.

    Figure 4.17 Adding the CLEAR State

You can change the shape of the state bubble by clicking the bubble and dragging in the direction to “stretch” the bubble.

Adding a Transition

A transition defines the movement between states of the state machine. Transitions are represented by arrows in the State Editor. You will be adding a transition from the CLEAR state to the ZERO state in the following steps. Because this transition is unconditional, there is no Transition Condition associated with it.

  1. Click the Transition icon in the vertical toolbar.

    figures/transition_icon.gif

  2. Click first on the CLEAR state, then on the ZERO state to draw the transition arrow. The arrow's shape can be manipulated by clicking it and then dragging the mouse.

    Figure 4.18 Adding State Transition

Adding a State Action

A State Action dictates how the outputs should behave in a given state. There are three types of state actions: Entry Action, State Action, and Exit Action. These determine if the outputs should act upon entry to, existence in, or exit from a given state, respectively.

You will add two state actions to the CLEAR state, one to drive the CLKOUT output to 0, and one to drive the RST output to 1.

  1. Click the State Action icon in the vertical toolbar.

    figures/state_action_icon.gif

  2. Move the mouse over the diagram so that the small round ball at the end of the pointer is over the CLEAR state. After you are in this position, click the mouse to place the State Action box.

  3. When a cursor appears, type the following state action:

  4. Click in an empty space in the diagram to exit out of state action entry mode. The State Action should now appear in a black box next to the CLEAR state.

    You have the option to click and drag the State Action to move it.

    Figure 4.19 Adding State Actions

Adding a State Machine Reset Condition

Using the State Machine Reset, you specify a reset condition for the State Machine. The state machine initializes to this specified state and enters the specified state whenever the reset condition is met. In this design, you add a Reset condition which sends the state machine to the CLEAR state whenever the RESET signal is asserted.

  1. Click the Reset icon in the vertical toolbar.

    figures/reset_icon.gif

  2. Place the Reset triangle onto the diagram near the CLEAR state, as shown in the diagram below.

  3. The cursor is automatically attached to the transition arrow for this Reset. Move the cursor to the CLEAR state, and click the state bubble.

    Figure 4.20 Adding Reset

Adding a Transition Condition

Add the Transition Condition to the Reset. Transition Conditions are applied to all transitions, not only Reset transitions, in the same way. Transition Conditions are attached to the transition arrows, and describe the required condition for the movement between states.

Add a transition condition which tells the state machine to reset to the CLEAR state whenever the signal RESET is high.

  1. Click the Condition icon in the vertical toolbar.

    figures/condition_icon.gif

  2. Click the transition arrow which was drawn between the Reset triangle and the CLEAR state.

  3. When the cursor appears, type in the following condition:

  4. Click in an empty space in the diagram to exit the Draw Condition mode. The condition should now appear underlined and in purple text.

    Figure 4.21 Adding Reset Transition Condition

  5. Save your changes by selecting File Save.

Creating the State Machine Macro

You will now synthesize the state machine and a macro will be created that you can place on the Watch schematic. The macro symbol will automatically be added to the project library. The synthesis process encompasses the creation of the HDL code from the state machine diagram and the synthesis of the HDL code by either the Foundation Express (VHDL) or XABEL (ABEL) compiler. Additionally, you have the option to use the State Editor to create a symbol for the state machine which you can place on the schematic.

  1. Select Project Create Macro. This synthesizes the design as well as creates the macro symbol and adds the symbol to the SC Symbols toolbox.

  2. To view the HDL code which the State Editor produced, select Tools HDL Editor.

  3. Close the State Editor by clicking the X in the upper right corner of the window.

Placing the STMACH symbol

You can now place the STMACH state machine macro on the Watch schematic. If it is not already opened, open the Schematic Editor. Open the SC Symbols Toolbox to view the list of available library components. You should now be able to locate the STMACH_A or STMACH_V macro in this list. (If the SC Symbols Toolbox was already open, and you do not see the STMACH macro, select File Update Libraries.) Select the appropriate symbol, and add it to the Watch schematic as shown below. Do not worry about drawing the wires to connect this symbol. You will connect the entire schematic later in the tutorial.

Figure 4.22 Placing the State Machine Macro

Save the schematic.

Creating an HDL-Based Module

With Foundation you can create modules from HDL code. The HDL code is synthesized by either the Express compiler (for VHDL or Verilog), or the XABEL compiler (for ABEL), and a symbol is generated which you can place on the schematic.


NOTE

If you use Verilog or VHDL to create an HDL macro, then you must have Base Express or Foundation Express and a valid license.


You will create an HDL module from scratch. This macro serves to convert the two 4-bit outputs of the CNT60 module into 7-segment LED display format.

Using the HDL Design Wizard and HDL Editor

The HDL Wizard is very similar to the Symbol Wizard that you used to create the CNT60 macro earlier.You enter the name and ports of the component and the HDL Wizard creates a “skeleton” HDL file which you can complete with the remainder of your code.

  1. From the Flow tab in the Project Manager, click the HDL Editor button.

    figures/hde_flow.gif

  2. A dialog box opens, asking if you want to create an empty HDL file, select an existing HDL file, or use the HDL Wizard to create a new file. Click the radio button next to Use HDL Design Wizard and click OK.

  3. Follow the instructions from the Wizard. When you are prompted for a preferred HDL language, choose one.


    NOTE

    You must have a Base Express or Foundation Express package in order to use VHDL or Verilog.


  4. When you are prompted for a file name, type HEX2LED and click Next.

  5. The HEX2LED component will have a 4-bit input port named HEX, and a 7-bit output port named LED. To enter these ports, click the New button in the Ports dialog box. Select Input as the direction and type HEX in the Name field. Then, click the arrow next to the Bus field to select 3:0, which is the width of the bus. In the Name field, you should now see HEX[3:0], and a corresponding pin should appear on the symbol diagram on the left.

    Figure 4.23 HDL Wizard

  6. Repeat the previous step for the LED[6:0] output bus. Be sure to set the direction to Output.

    If you use ABEL, set the outputs to combinatorial instead of the default (registered). To set the outputs, make sure the LED[6:0] pin is highlighted and click the Advanced ... button. In the Advanced Port Settings dialog box, click the radio button next to Combinatorial.

  7. Click Finish to complete the Wizard session. A “skeleton” HDL file now appears in the HDL Editor.

    Figure 4.24 Skeleton HDL File

In the HDL Editor, the ports are already declared in the HDL file, and some of the basic file structure is already in place. Keywords are printed in red, comments in green, and values are gray. This color-coding enhances readability and recognition of typographical errors.

Using the Language Assistant

Use the templates from the Language Assistant for commonly used HDL constructs, as well as synthesis templates for commonly used logic components such as counters, D flip-flops, multiplexers, and global buffers. You can add your own templates to the Language Assistant for components or constructs you use often.

  1. To invoke the Language Assistant, select Tools Language Assistant from the HDL Editor pulldown menu.

  2. The Language Assistant is divided into three sections: Language Templates, Synthesis Templates and User Templates. To expand the view of any of these sections, click the `+' next to the topic. Click any of the listed templates to view the template in the right hand pane.

  3. Use the template called HEX2LED Converter located under the Synthesis Templates heading. Locate this template, preview it in the right hand pane by clicking the template. This template provides source code to convert a 4-bit value to 7-segment LED display format.

    Figure 4.25 HDL Language Assistant

  4. Before adding this template to your HDL file, be sure that the cursor in the HDL Editor is positioned below the line with the comments “<<enter your statements here>>” for VHDL. For Verilog, enter code after the “// Add your code here” line. For ABEL, add the template below the line “<<add your equations here>>”. When you use the template, the code is placed wherever the cursor is currently positioned in the HDL Editor.

  5. To add the HEX2LED Converter template code, click the Use button in the Language Assistant while the HEX2LED Converter template is selected. The code is automatically placed in the HDL file.

  6. Close the Language Assistant by clicking the X in the upper right corner of the window.

  7. (Verilog only) After the “//add your declarations here” statement and before the HEX2LED converter that you just added, add the following line of code to the HDL file to allow an assignment.

    reg LED;

  8. You now have complete and functional HDL code and can check the syntax using Synthesis Check Syntax.

  9. After you successfully complete the syntax check, save the file by selecting File Save from the HDL Editor.

Synthesizing the HDL Code and Creating a Macro

Synthesize the code and create a macro symbol which may be placed on the schematic.

  1. From within the HDL Editor, select Project Create Macro.

    The code is synthesized, and a symbol is created and placed in the project library.

  2. Close the HDL Editor by clicking the X in the upper right corner of the window.

Adding the HEX2LED Component to the Schematic

You are now ready to place the HEX2LED macro on the Watch schematic. Open the Schematic Editor if it is not already open. Open the SC Symbols Toolbox (refer to the “Adding Components to CNT60” section) to view the list of available library components. You should now be able to locate the HEX2LED macro in this list. Select it, and add it to the Watch schematic as shown below.

This component will be placed on the Watch schematic sheet in two separate instances. To duplicate the component in the schematic, click the left mouse button while the pointer is on the placed symbol, and then click again to place the duplicate symbol.


NOTE

The Symbols Toolbox icon must still be depressed on the vertical toolbar to enable this feature to automatically duplicate a symbol.


Again, do not worry about drawing the wires and buses to connect this macro. You will connect the entire schematic later in the tutorial.

Figure 4.26 Placing the HEX2LED Component

Specifying Device Inputs/Outputs

When specifying device I/O on a schematic sheet, use components from the Xilinx Unified Library to represent the input/output pads and buffers in the device. The XC4000E library, which is attached to this Foundation project, contains primitive components for these, such as IPAD, OPAD, IBUF, OBUF, and IOPAD. You can place I/O components on any level of hierarchy in a Foundation schematic. However, it is recommended that the pad and the buffer (that is, IPAD/IBUF) reside on the same level of hierarchy. In other words, do not split up the pad and the buffer between levels of hierarchy.

Hierarchy Push/Pop

Descend into a lower-level of hierarchy to view the underlying file. You will be pushing down into the OUTS1 macro, which is a schematic-based user-created macro.

  1. To push down into OUTS1, click the Hierarchy Push/Pop button. The mouse cursor changes to the letter “H”. Double click the OUTS1 symbol.

    figures/hier_push_icon.gif

    In the OUTS1 schematic, you see a series of output buffers (OBUF) and output pads (OPAD). These represent output pins on the XC4000E device. Each of these pads has a LOC=P__ attribute attached to them. This attribute assigns each of the pins to a particular pin on the target device. You will add more pins with LOC attributes in the next section.

    Figure 4.27 OUTS1 Schematic Macro

    The OUTS2 and OUTS3 macros are similar to OUTS1, except that the pins have been locked to different device I/O. All of these pin assignments are based on the 4003EPC84 device/package which is on the Xilinx demonstration board. The pins are connected to the LED indicator lights on the demo board.

  2. “Pop” back out of the OUTS1 component. You can do this in one of two ways. Either click the Hierarchy Push/Pop icon, then double click in an empty space in the OUTS1 schematic, or click the Watch tab at the bottom of the Schematic Capture tool to return to the top-level Watch schematic sheet.

Adding Input Pins

Add two more input pins to the Watch schematic, called RESET and STRTSTOP.

  1. Add an IPAD and an IBUF for each of these two new input pins, shown in the diagram below. To add these components, click the SC Symbols icon in the vertical toolbar to open the SC Symbols Toolbox. Browse to locate the IPAD and IBUF components in the XC4000E library. Drop these on the schematic as shown below.

  2. Draw a net between each IPAD/IBUF pair. If necessary, refer to the section on drawing nets (see the “Drawing Nets” section) for instruction.

    Figure 4.28 Placing RESET and STRTSTOP I/O Components

Labeling Nets

It is important to label nets and buses for several reasons. It aids in debugging and simulation, as you will more easily trace nets back to your original design. Any nets which remain unnamed in the design will be given machine-generated names which will mean nothing to you later in the implementation process. Naming nets also enhances readability and aids in documenting your design.

Label the two input nets you just drew. When naming input and output pins, it is advisable to label the net between the pad and the buffer. This name is carried through the entire design flow including place and route. If you label only the output of the buffer (in the case of an input pin) or input of the buffer (in the case of an output pin), you will not be able to easily trace your I/O pins in implementation tools and reports.

  1. Double click the RESET net.

  2. In the Net Name field, type RESET as shown below.

    Figure 4.29 Labeling Nets

  3. Click OK.

  4. Repeat Steps 1 through 3 for the STRTSTOP pin. You have the option to click and drag the new attributes to better place them on the schematic.

    Figure 4.30 Labeled Nets

Assigning Pin Locations

Xilinx recommends that you let the automatic placement and routing program, PAR, define the pinout of your design. Pre-assigning locations to the pins can sometimes degrade the performance of the place and route tools. However, it is usually necessary, at some point, to lock the pinout of a design so that it can be integrated into a PCB (Printed Circuit Board).

Define the initial pinout by running the place-and-route tools without pin assignments, then locking down the pin placement so that it reflects the locations chosen by the tools. In this design, you assign locations to the pins in the Watch design so that the design can function in a Xilinx demonstration board. Because the design is simple and timing is not critical, these pin assignments will not adversely affect the ability of PAR to place and route the design.

Specify pin locations by attaching a LOC parameter to a pad component. Assign a LOC parameter to the pad associated with the RESET signal on the Watch schematic as follows.

  1. Double click the IPAD connected to the net labeled RESET. The Symbol Properties dialog box opens.

  2. In the Parameters section, add a new parameter with these values:

    Name: LOC

    Description: P28

    This step assigns the RESET signal to pin P28 of the target device.

    Figure 4.31 Assigning Pin Locations

  3. Click Add. The parameter appears in the list box.

    Notice the two black dots to the left of the parameter. This indicates that both the Name field and the Description field of the parameter will be displayed on the schematic. You can double click on the parameter to change the number of dots shown.

  4. Click Apply. You see the parameter next to the IPAD.

  5. Click OK to close the window.

  6. Repeat Steps 1 through 5 to assign the STRTSTOP input pin to pin P18.


    NOTE

    You may click and drag the attributes to position them where you wish on the schematic.


    Figure 4.32 STRTSTP Pin Assignment

Using the 4K Internal Oscillator

The XC4000 devices contain an on-chip oscillator which may be used to generate internal clock signals. To access the internal oscillator, place the OSC4 component from the XC4000 Unified Library on your schematic. Nominal clock frequencies of 8MHz, 500kHz, 16kHz, 490Hz, and 15Hz are available, and are specified by corresponding output pins of the OSC4 symbol. In the Watch design you use the 15Hz clock output of the OSC4 component as the system clock in the design. The frequency of these clock signals is not precise. Do not use the OSC4 when you require a high degree of clock speed precision.

From the SC Symbols list, locate the OSC4 component in the XC4000E library and place this component on the schematic as shown below.

Figure 4.33 Placing the OSC4

Using Global Buffers

All Xilinx devices contain a set of Global Buffers which provide low-skew distribution of high fanout signals. The number and type of global buffers differ depending on the Xilinx device family you target. Consult the Xilinx Libraries Guide for more information regarding the various types of global buffers available.

In the Watch design, you will use a BUFG component from the XC4000E library to drive the clock signal from the OSC4. The signal on the output of the BUFG is the buffered clock signal which will drive all the clocks in the system.

  1. From the SC Symbols toolbox, locate the BUFG component in the XC4000E library, and place it on the schematic as shown below.

  2. Draw a net (see the “Drawing Nets” section) between the F15 pin of the OSC4 and the input pin of the BUFG.

  3. Label this net CLK (see the “Labeling Nets” section).

    Figure 4.34 Placing the BUFG

Hardware Verification -- Startup and Readback (Optional)

This section describes the necessary preparations you must make in the design entry phase of the design flow in order to do in-circuit hardware debugging after implementation.

The last tutorial chapter of this manual is called the “In-Depth Tutorial - Hardware Verification” chapter. In this chapter, you have the option to both download the design to the Xilinx Demonstration Board and also perform on-chip hardware debugging using the Hardware Debugger tool.

In order to perform hardware debugging, place the READBACK symbol in your design, and provide access to an external clock source in order to perform the synchronous debugging. In the Watch design, a schematic-based macro called DEBUG_CKT is provided in the project library which contains the necessary circuitry to perform hardware debugging later in this tutorial.

If you wish to complete the hardware debugging chapter later, place the DEBUG_CKT on the Watch schematic as shown below. Disconnect the CLK net that you just drew in order to place the DEBUG_CKT in the design. To delete the CLK net, select it, then press the Del key on your keyboard. Label the new CLK net that you draw.


NOTE

If you only want to download the design to the Demo Board and do not want to perform in-circuit hardware debugging, then it is not necessary to use this DEBUG_CKT macro, and you can leave the schematic as is.


Figure 4.35 Placing the DEBUG_CKT Macro

Completing the Schematic

Complete the schematic by wiring the components you have created and placed, adding any additional necessary logic, and labeling nets appropriately. The following steps guide you through the process of completing the schematic, or you may want to use the completed schematic shown below for guidance. Each of the actions in this section has been discussed in detail in earlier sections of the tutorial. If you need to review these sections, you may return to them. The finished schematic is shown in the following figure as a guide.

Figure 4.36 Completed Watch Schematic

  1. Draw a net (see the “Drawing Nets” section) between the BUFG and the CLK pin of the STMACH state machine macro. Label this net CLK_INT.

  2. Draw a net (see the “Drawing Nets” section) between the IBUF of the RESET input and the RESET pin of the STMACH state machine macro.

  3. Place an INV (inverter) component (see the “Adding Components to CNT60” section) from the XC4000E library between the IBUF of the STRTSTOP input and the STRTSTOP pin of the STMACH state machine macro. Draw nets (see the “Drawing Nets” section) to connect the INV to the both the IBUF and the STMACH state machine macro.

  4. Place an AND2 component (see the “Adding Components to CNT60” section) to the left of the CNT60 macro.

  5. Draw a net (see the “Drawing Nets” section) to connect the output of the AND2 with the CE pin of the CNT60 macro.

  6. Draw a net (see the “Drawing Nets” section) to connect the TERM_CNT pin of the TENTHS macro to one of the inputs to the AND2.

  7. Draw a hanging net (see the “Drawing Nets” section) from the CLKOUT pin of the STMACH macro. To terminate a hanging wire, double click.

  8. Press Esc to get back into point/select mode and then label the net you drew in Step 7 CLKEN_INT.

  9. Draw a hanging net at the CLK_EN input pin of the TENTHS macro. Label this net CLKEN_INT (see the “Labeling Nets” section).

  10. Draw a hanging net (see the “Drawing Nets” section) at the other input of the AND2 component. Label this net CLKEN_INT again (see the “Labeling Nets” section).

  11. Draw a hanging net (see the “Drawing Nets” section) from the RST output pin of the STMACH macro. Label this net RST_INT.

  12. Draw two more hanging nets (see the “Drawing Nets” section), also named RST_INT, from the ASYNC_CTRL pin of the TENTHS macro and from the CLR pin of the CNT60 macro.

  13. Draw two hanging nets (see the “Drawing Nets” section), each named CLK_INT, from the CLOCK pin of the TENTHS macro and from the CLK pin of the CNT60 macro.


    NOTE

    Remember that nets are logically connected if their names are the same, even if the net is not physically drawn as a connection in the schematic. This method is used to make the logical connection of the RST_INT, CLKEN_INT and CLK_INT signals.


  14. Draw buses (see the “Adding Buses” section) to complete the schematic. Label them as shown on the preceding schematic diagram.

    The schematic is now complete!

  15. Save the design by selecting File Save.

Next