mixed vhdl-verilog tutorial

Download Mixed VHDL-Verilog Tutorial

Post on 11-Sep-2015

8 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

tut

TRANSCRIPT

  • Active-HDL Help Copyright Aldec, Inc.

    Mixed VHDL-Verilog Tutorial

  • Table Of Contents Mixed VHDL-Verilog Tutorial ........................................................................................................... 1

    Introduction .................................................................................................................................. 1 VHDL Model................................................................................................................................. 2 Verilog Module ............................................................................................................................. 5 Top-Level Schematic ................................................................................................................... 6 Simulation .................................................................................................................................. 11

    i

  • Mixed VHDL-Verilog Tutorial

    Introduction

    The focus of this tutorial is to get you acquainted with Active-HDL's ability to mix VHDL and Verilog descriptions in a single project. 1. After starting the Active-HDL environment, the Getting Started window appears. Select the Create new workspace option and click the OK button. The New Workspace wizard will start. The wizard consists of one dialog in which you should provide a name and location for the new workspace.

    Make sure that the Add New Design to Workspace checkbox is selected and click the OK button. As a result, the New Design Wizard will be invoked. 2. In the first window of the wizard select the design sources creation method, choose the Create an empty design option and click the Next button. 3. The subsequent wizard window allows selecting synthesis and implementation tools, programmable device vendor and family, Block Diagram configuration, and target language. In this window, choose Verilog as the default HDL language and click the Next button. 4. As a result, the New Design Wizard window is opened. To create a new design, type mixed_tutorial as a name for the design in the Type the design name field.

    1

  • Mixed VHDL-Verilog Tutorial

    Advance to the next window by clicking the Next button. 5. To complete the wizard process click the Finish button in the last wizard window. 6. The Design Browser window contains an empty mixed_tutorial project along with a working library named by default after the design.

    VHDL Model

    7. Double-click the Add New File label in the Design Browser window. This will open the Add New File window where you need to switch to the Wizards tab and select the VHDL Source Code Wizard. Accept your choice with the OK button. 8. As a result, the New Source File Wizard window appears. Make sure that the Add the generated file to design field is checked and click the Next button. 9. Now you have to enter the name of the file and optionally enter the entity and architecture names as well. In the Type the name of source file to create field type counter and advance to the next step by clicking the Next button.

    2

  • Mixed VHDL-Verilog Tutorial

    10. The next window lets you specify the ports of the model being generated. To add a new model port, click the New button and type its name in the Name field. To choose the port direction, select the appropriate one in the Port part of the window. Then, create the following ports:

    clk - 1-bit input reset - 1-bit input Q[3:0] - 4-bit output

    When creating buses you can set their width by clicking on the Array Indexes arrows. The figure below shows all created ports.

    When you finish adding the model's ports, click the Finish button to end the wizard process. 11. The generated VHDL source is automatically loaded to the HDL Editor window.

    Before you complete the next step, place the editing cursor below the -- enter your statements here -- line.

    3

  • Mixed VHDL-Verilog Tutorial

    12. Active-HDL comes with a Language Assistant, which is a tool for inserting templates and language constructs into the source code. To open the Language Assistant window click the

    button located in the main toolbar.

    In the Language Assistant window, expand the Tutorial branch and choose the Counter template as shown in the figure. To place the selected template in your code, click the Use

    template button. 13. As you can see in the following figure, a process with a counter description has been automatically inserted in the HDL Editor window.

    14. To compile the prepared source without any error messages, you need to add the following clause after the IEEE library declaration:

    use IEEE.std_logic_unsigned.all; After completing this operation, the HDL Editor contents should look as shown below.

    4

  • Mixed VHDL-Verilog Tutorial

    15. Now the source code is complete and ready for compilation. To compile any source code,

    click the Compile button located in the main toolbar. Successful compilation is indicated in the Design Browser by a green check mark next to the file name. As you can notice in the figure below, a successfully compiled file can be expanded and has an entity-architecture pair attached to it. Additionally, the elaborated code is placed in the working library.

    Verilog Module

    16. At this stage you will expand your design by a code converter written in Verilog. To do so, double-click the Add New File label in Design Browser. In the opened window, choose the Verilog Source Code option and type hex2led name in the Name field. Accept the choices with the OK button.

    17. This will open an empty HDL Editor window. The complete converter's code is located in the

    Language Assistant window. To open it, click the button located in the main toolbar. Select Verilog Language to view templates written in Verilog. Expand the Synthesis templates branch and locate the HEX2LED Converter as shown in the figure below.

    5

  • Mixed VHDL-Verilog Tutorial

    Click the Insert template button to place the selected template in the source file. Then add the `timescale 1ps / 1ps directive at the beginning of the code. 18. The contents of the HDL Editor window after the converter's code insertion should look as follows.

    19. Now, compile the file using the Compile button. 20. Successful compilation is marked by a green check mark next to the hex2led.v file in the Design Browser and the appropriate message is displayed in the Console window. The elaborated source is also placed in the design library.

    Top-Level Schematic

    21. To bind the VHDL and Verilog descriptions together you will utilize the Block Diagram Editor. To add a new file to the project, double-click the Add New File label in Design Browser. In the Add New File window, choose the Wizards tab and select the Block Diagram Wizard option. Accept your choices with the OK button. 22. This will launch the New Source File Wizard. Make sure that the Add the generated file to the design field is checked and click the Next button. 23. Choose the VHDL as the target language and click the Next button.

    6

  • Mixed VHDL-Verilog Tutorial

    24. In the next window, type top in the Type the name of the source file to create field and select Next.

    25. The next window lets you specify the ports of the model being generated. To add a new model port, click the New button and type its name in the Name field. To choose the port direction, select the appropriate one in the Port part of the window. With this in mind, create the following ports:

    CLK - 1 bit input RESET - 1 bit input Output[6:0] - 7 bit output

    When creating buses, you can set their width by clicking on the Array Indexes buttons. The figure below shows all created ports.

    26. After clicking the Finish button, the Design Browser window displays a new top.bde file.

    7

  • Mixed VHDL-Verilog Tutorial

    27. This file is also automatically opened in the Block Diagram Editor. As you can see, all created ports have already been placed on the diagram.

    28. First, you will place the symbols of the previously created components. Each compiled source file is given a symbol representation for its usage with block diagrams. To open the Symbol

    Toolbox window, use the Show Symbols Toolbox button located in the main toolbar. As you can see in the figure below, this window contains symbols for the VHDL counter and Verilog converter.

    29. To place the symbol on the schematic, drag it from the Symbol Toolbox and drop it within the diagram area. Using this technique, place the counter and converter symbols as shown in the figure below.

    8

  • Mixed VHDL-Verilog Tutorial

    30. To draw a single connection between components, use the Wire button located in the Block Diagram Editor toolbar. Click this button and draw the wires between the CLK and RESET pins of the counter and input terminals. To draw a wire, anchor one of its ends at the source pin and drag it to the desired location by clicking the remaining pin. The connections of the symbols are shown below.

    31. To draw buses, use the Bus button located in the Block Diagram Editor toolbar. After clicking it, draw the connection between the converter and counter symbols. Next create a connection between the converter's output and output terminal as shown in the figure.

    32. In this step, you will name the drawn connections. To do so switch to the Select mode, double click the bus connecting the converter and the OUTPUT(6:0) terminal. In the Bus Properties window type the bus1 name in the Segment field. In the Index range field, set the width to 6 downto 0.

    9

  • Mixed VHDL-Verilog Tutorial

    A

Recommended

View more >