HW 1: Tools Introduction

CMPE 415 UMBC


Prof. Ryan Robucci

Assigned Sept 11, 2018; Due Sept 18, 2017; students working in identified pairs are allowed to collaborate without restriction on this assignment but each students should install the software and complete steps on their computer and submit independently. Submission instructions are TBD, but expect them soon (back up your work in the meantime).

Objective

The objective of this lab is to learn the fundamental components of the Xilinx FGPA tools required to enter and assemble HDL code using a schematic entry tool and program an FPGA. This includes integrating HDL into a schematic, as well as creating and updating symbols.

Prerequisite

In this lab you will program an FPGA to display a rectangle on a monitor using a VGA cable. You will first create an implementation with an error in it and view the results. You will then modify the code, update the symbol in the schematic, and wire the schematic correctly to control the color of the rectangle using switches.

Tutorial Steps

Start Xilinx Vivado:

Create New Project

  1. In main window menu: File->New Project...
    1536675554776
  2. 1536676891733
  3. 15366769514401536683583726
  4. 1536676980323
  5. You’ll now need to enter information about the FPGA. You can look in the reference manual to find the information https://reference.digilentinc.com/reference/programmable-logic/nexys-4-ddr/reference-manual or you can use the board support files if you downloaded and installed them: 1536677013321
  6. The next screen shows a summary. 1536683789129
  7. Hit Finish. Result: 1536683860647

Download an HDL Module, Modify and Add to project

  1. Select a free HDL description of implementation of a vga module to a temporary directory or to your project directory. Our other module will be implmented using Verilog, but we can integrate Verilog and VHDL modules together in the schematic if desired. Here are examples of the type of vga modules for which you are looking. Make sure to respect any restrictions the authors place on copyrighted code that you use.

  2. Download the code to a src directory

  3. Modify code to work with a 100-MHz clock change the 1-bit counter to a 2-bit counter

    becomes

  4. Add the source to the project using File-> Add Sources...1536684582683

  5. We will use the second option: 1536684655701

  6. Click Add Files 1536684726441

    navigate to src dir (e.g. /home/robucci/CMPE415/homeworks/hw1/src) and select the vga_sync.v file

    1536684914896

    1536684990251

     

    You now have a new Design Source listed1536685117164

 

Create VGA Rectangle Generator Verilog Module

We will now create a second source file.

  1. Add a source as before, but this time select Create File1536685718698

  2. 15366857382881536685767748

  3. 1536686358981

  4. You should now have a shell created with port definitions. Double click the file to edit it and make the modifications below 1536686432458

  5. Set the reg, green, and blue outputs as reg. Implementing registers avoids glitching (not that it is critical here). change

    to

    Add the following module code which takes the coodinates as inputs and outputs the color:

Obtain, edit, and add a Contraints File to Specify Pin Locations, Voltage, and Clock Rate Compatable with the Board

The board that we are using can be considered as a reference board for learning to use the type of FPGA from Xilinx. Usually such boards come with a reference manual and what is called a constraint file that describes where pins are connected on the FPGA and the frequency the input clock generated on the board.

The provided file from one of these locations:

Place the file in your src directory

Uncomment the following lines set_property lines in the file:

Add the constraints file from the src directory.

1536689615023

1536689683833

1536689760799

 

1536690140309

Glue Logic 1-bit to 4-bit output

You can note that the vga_r,vga_g, and vga_b are 4 bits each, but our vga_rectangle reg,green, and blue outputs are 1-bit.

Before we connect modules and FPGA pins, lets create some "glue logic" that expands a 1-bit to 4-bit

Create another module called bit_replicator_4x (be sure to store it in the src directory) with a 1-bit input "dIn" and a 4-bit output dOut. Add one line of code to the module:

Create Top Level Design

We now want to create a top level design with modules connected using the following I/O names at the top level CLK100MHZ, VGA_R,VGA_G,VGA_B so that they match the provided constraints file and thus what you would find in the board documentation.

Two options are to create a Verilog file directly, and the second it to use a schematic tool to draw the design then generate the top level Verilog for it. We'll do the latter since it effectively shows both concepts.

We'll add a block design using Create Block Design

1536702751249

We'll choose a name "top" for the design and place it in the src directory

1536702724144

There is now a top.pd in your sources and a schematic waiting to be draw on the right:

1536703062630

 

To add your modules, and pins/ports use the right click menu within the Diagram area:

1536703193903

 

First add the vga_sync, then the vga_rectangle, then three of the bit_replicator_4x (can also use copy and paste get three)

1536703315296block diagram design

Pins/port can be added using the same menu. Create

1536703478140

 

1536703562641

 

 

1536703633822

 

For VGA_G and VGA_B I copy&paste VGA_R then change the name using the property box (modules not show in this screenshot):

1536703800720

 

Here is a final schematic:

1536707387049

You can validate the design using the checkbox:

1536706358700

 

To make actually create our top level design, Vivado seems to requires a Verilog file, so right click the top.bd and select Create HDL Wrapper

1536705931192

 

1536706461760

I WOULD HAVE asked you to right-click the top_wrapper and select Set as Top, but if you wait a moment Vivado figures this out and moves the top indicator icon (green box above two gray boxes).

Synthesize, Implement, and Generate Programming File

  1. You can now click Generate Bitstream on the left, found right under Program and Debug

    1536706846266

  2. Use the defaults and ok-click through the next dialog.

  3. You'll note progress/status/messaage in the upper-right corner of the Vivado window.

  4. “Synthesize” and “Implement Design” are run automatically as needed.

    1. Synthesize maps your design to a circuit based on FPGA building blocks.
    2. Implement Design maps the circuit to the FPGA including place and route.
  5. This is what you are hoping for:1536707895087

  6. You can select Open Hardware Manger or access it from the left panel.

    Proceed and then click the auto connect icon as show in the image:

1536708004280

Right Click the xc7z100t_0 and select Program Device:

1536708224994

OK-click through the dialogs (the correct .bit progamming file should be found automaticallly) and see if the magic happens. You should be able to connect a VGA monitor and see a Magenta rectangle on a Green Background.

Connect to Monitor

Connect a VGA cable to the starter board and a monitor. You should see a magenta/purple rectange on a blue background.

 

Your Design Assignment

Modify the design to have the ability to change the color of the rectangle based on switch positions.