====== What is a Constraints File? ====== ~~TechArticle~~ 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? ===== The master XDC files for all Digilent boards actively supported in Vivado can be found in the [[https://github.com/digilent/digilent-xdc|digilent-xdc]] repository on Github. Download this ZIP to get the latest versions of these files: {{https://github.com/Digilent/digilent-xdc/archive/refs/heads/master.zip|digilent-xdc-master.zip}} The master XDC file for your board 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 get an XDC file into my project? ===== {{section>/programmable-logic/guides/vivado-add-xdc&noheader}} ---- ===== What am I supposed to do with this XDC file anyway? ===== 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. {{:learn:software:tutorials:ModuleNamesAndXDCfileNamesMatching.png?800|An edited XDC and code module example(click to enlarge)}}