# What is a Constraints file

When programming an FPGA through software such as Xilinx's Vivado, you need to inform the software what physical pins on the FPGA that you plan on using or connecting to in relation to the HDL code that you wrote to describe the behavior of the FPGA.

In microcontroller land, this is very much like writing a register high or low on the microcontroller to turn an LED on or off, drive a clock, or to act as a data line. However, in a microcontroller many of these pins are “hard-wired” in the sense that you cannot relocate pins that are connected to a SPI controller to a physically different pin on the microcontroller. Generally speaking, it's just not an option.

This isn't the case for an FPGA; instead, you can create a hardware interface in HDL and then constrain the corresponding inputs and outputs on that interface to (essentially) whichever pins you want on the FPGA, making FPGAs very flexible for complex and custom designs.

However, this isn't to say that you can physically rearrange the PCB layout on the board through software. FPGA board manufacturers, such as Digilent, may physically connect some of the FPGA pins to certain on-board components within reason, such as routing some of the high speed transceiver lanes on the FPGA to an HDMI port rather than a Pmod host port or an on-board LED. You will not be able to change those physical locations. This doesn't stop you from assigning your clock pin in your code to be constrained to the clock pin that is inside an HDMI connector…you just may have a hard time physically accessing it (and using HDMI normally at the same time).

The constraints file that Xilinx's Vivado uses is called an XDC file (Xilinx Design Constraints file). Writing your own constraints file for inexperienced users can be very difficult since you are restricted by which FPGA pin is connected to which physical location on the board, and if you don't know where those are and what electrical property standard they support…it can become very frustrating very quickly.

## Where can I find an XDC file

For Digilent boards, it is instead recommended to use a master XDC file that is available for each of the boards on the bottom right hand side of their respective Resource Centers.

The master XDC file lists all of the FPGA pins that are routed out to physical pins on the board; they are arranged by external component groups on the board for general convenience. All of the pins on the master XDC files are commented out so users will only need to uncomment the pins that they intend to use.

## How do I actually use an XDC file in my project?

Aye, there's the rub; and likely why you clicked on this page in the first place.

In general, the only portion of the XDC file you will change is the name of the external pin after get_ports that is surrounded by curly braces {} to match the input/output that you created in your main module code, as shown in the image below. You'll also need to make sure you uncomment the pins that you are using by deleting the first pound sign, #, in the line.