## Guide to the Build System (Xilinx Vivado Version) ### Table of content - [Concept](#user-content-concept) - [Set up system environment](#user-content-sysenv) - [Set up environment variables](#user-content-envvar) - [Compile UNISIM/UNIMACRO libraries for GHDL](#user-content-ghdllibs) - [Building test benches](#user-content-buildtb) - [With GHDL](#user-content-buildtb-ghdl) - [With Vivado xsim](#user-content-buildtb-xsim) - [Building FPGA bit files](#user-content-buildfpga) - [Building vivado projects, creating models](#user-content-buildviv) - [Configuring FPGAs (via make flow)](#user-content-config-fpga) - [Note on ISE](#user-content-ise) ### Concept This project uses GNU `make` to - generate bit files (with Vivado synthesis) - generate test benches (with GHDL or Vivado XSim) - configure the FPGA (with Vivado hardware server) The Makefile's in general contain only a few definitions. By far most of the build flow logic in Vivado is in tcl scripts, only a thin interface layer is needed at the make level, which is concentrated in a few master makefiles which are included. Simulation and synthesis tools usually need a list of the VHDL source files, sometimes in proper compilation order (libraries before components). The different tools have different formats of these 'project descriptions. The build system employed in this project is based on manifest files called 'vbom' or "VHDL bill of material" files which list for each VHDL source file the libraries and sources for the instantiated components, the latter via their vbom, and last but not least the name of the VHDL source file. All file names are relative to the current directory. A recursive traversal through all vbom's gives for each VHDL module all sources needed to compile it. The `vbomconv` script in `tools/bin` does this and generates depending on options - make dependency files - Vivado synthesis setup files - Vivado simulation setup files - GHDL commands for analysis, inspection and make step The master make files contain pattern rules like %.bit : %.vbom -- create bit file % : %.vbom -- build functional model test bench which encapsulate all the `vbomconv` magic A full w11a system is built from about 100 source files, test benches from even more. Using the vbom's a large number of designs can be easily maintained. For more details on `vbomconv` consult the man page. ### Set up system environment #### Set up environment variables The build flows require the environment variables: - `RETROBASE`: must refer to the installation root directory - `XTWV_PATH`: install path of the Vivado version For general instructions on the environment see [INSTALL.md](INSTALL.md). Notes: - The build system uses a small wrapper script called xtwv to encapsulate the Xilinx environment. It uses `XTWV_PATH` to set up the Vivado environment on the fly. For details consult 'man xtwv'. - don't run the Vivado setup scripts ..../settings(32|64).sh in your working shell. Set up only XTWV_PATH ! #### Compile UNISIM/UNIMACRO libraries for GHDL A few entities use `UNISIM` or `UNIMACRO` primitives, and post-synthesis models require also `UNISIM` primitives. In these cases, GHDL has to link against a compiled `UNISIM` or `UNIMACRO` libraries. To make the handling of the parallel installation of several Vivado versions easy the compiled libraries are stored in sub-directories under `$XTWV_PATH`: $XTWV_PATH/ghdl/unisim $XTWV_PATH/ghdl/unimacro A helper scripts will create these libraries: cd $RETROBASE xviv_ghdl_unisim # does UNISIM and UNIMACRO Run these scripts for each Vivado version that is installed. Notes: - Vivado supports `SIMPRIM` libraries only in Verilog form, there is no VHDL version anymore. - GHDL can therefore not be used to do timing simulations with Vivado. However: under ISE `SIMPRIM` was available in VHDL, but GHDL did never accept the sdf files, making GHDL timing simulations impossible under ISE too. ### Building test benches The build flows currently supports GHDL and the Vivado simulator xsim. #### With GHDL To compile a GHDL based test bench named `` all is needed is make The make file will use `.vbom`, create all make dependency files, and generate the needed GHDL commands. In some cases, the test benches can also be compiled against the gate level models derived after the synthesis or optimize step. Vivado only generated functional (`UNISIM` based) models in VHDL. Timing (`SIMPRIM` based) models are only available on Verilog. The combination Vivado + GHDL is therefore limited to functional model simulation. To compile them make ghdl_tmp_clean make _ssim # for post synthesis functional make _osim # for post optimize functional make _rsim # for post routing functional Individual working directories are used for the different models ghdl.bsim for bahavioral model ghdl.ssim for post synthesis ghdl.osim for post optimize ghdl.rsim for post routing and can co-exist. The `make ghdl_tmp_clean` can be used to flush the GHDL work areas, but in general this is not needed (since V0.73). Notes: - Many post-synthesis functional currently fail due to startup and initialization problems (see [issue #10](https://github.com/wfjm/w11/issues/10)). #### With Vivado xsim To compile a Vivado xsim based test bench named all is needed is make _XSim The make file will use `.vbom`, create all make dependency files, and generate the needed Vivado xsim project files and commands. In many cases, the test benches can also be compiled against the gate level models derived after the synthesis, optimize or routing step. Vivado supports functional (`UNISIM` based) models in VHDL and in Verilog, and timing (`SIMPRIM` based) models only in Verilog. Since practice showed that Verilog models compile and execute faster, Verilog is used for both functional and timing models. make _XSim_ssim # for post-synthesis functional make _XSim_osim # for post-optimize functional make _XSim_rsim # for post-routing functional make _XSim_esim # for post-synthesis timing make _XSim_psim # for post-optimize timing make _XSim_tsim # for post-routing timing Notes: - as of Vivado 2016.2 `xelab` shows sometimes extremely long build times, especially for generated post-synthesis VHDL models (see [issue #9](https://github.com/wfjm/w11/issues/9)). - Many post-synthesis functional and especially post-routing timing simulations currently fail due to startup and initialization problems (see [issue #10](https://github.com/wfjm/w11/issues/10)). ### Building FPGA bit files To generate a bit file for a system named `` all is needed is make .bit The make file will use `.vbom`, create all make dependency files and starts Vivado in batch mode with the proper scripts which will handle the build steps. The log files and reports are conveniently renamed _syn.log # synthesis log (from runme.log) _imp.log # implementation log (from runme.log) _bit.log # write_bitstream log (from runme.log) _syn_util.rpt # (from _utilization_synth.rpt) _opt_drc.rpt # (from _opt_drc.rpt) _pla_io.rpt # (from _io_placed.rpt) _pla_clk.rpt # (from _clock_utilization_placed.rpt) _pla_util.rpt # (from _utilization_placed.rpt) _pla_cset.rpt # (from _control_sets_placed.rpt) _rou_sta.rpt # (from _route_status.rpt) _rou_drc.rpt # (from _drc_routed.rpt) _rou_tim.rpt # (from _timing_summary_routed.rpt) _rou_pwr.rpt # (from _power_routed.rpt) _rou_util.rpt # (extra report_utilization) _rou_util_h.rpt # (extra report_utilization -hierarchical) _ds.rpt # (extra report_datasheet) The design check points are also kept _syn.dcp # (from .dcp) _opt.dcp # (from _opt.dcp) _pla.dcp # (from _placed.dcp) _rou.dcp # (from _routed.dcp) If only the post synthesis, optimize or route design checkpoints are wanted make _syn.dcp make _opt.dcp make _rou.dcp A simple _message filter_ system is also integrated into the make build flow. For many (though not all) systems a `.vmfset` file has been provided which defines the synthesis, implementation, and bitfile messages which are considered ok. To see only the remaining message extracted from the various `.log` files simply use the make target make .mfsum ### Building Vivado projects, creating gate level models Vivado is used in 'project mode', whenever one of the targets mentioned above is build a Vivado project is freshly created in the directory project_mflow with the project file project_mflow/project_mflow.xpr There are many make targets which - just create the project - start Vivado in gui mode to inspect the most recent project - create gate level models Specifically make .vivado # create Vivado project from .vbom make vivado # open project in project_mflow make _ssim.vhd # post-synthesis functional model (VHDL) make _osim.vhd # post-optimize functional model (VHDL) make _rsim.vhd # post-routing functional model (VHDL) make _ssim.v # post-synthesis functional model (Verilog) make _osim.v # post-optimize functional model (Verilog) make _rsim.v # post-routing functional model (Verilog) make _esim.v # post-synthesis timing model (Verilog) make _psim.v # post-optimize timing model (Verilog) make _tsim.v # post-routing timing model (Verilog) For timing model Verilog file an associated sdf file is also generated. ### Configuring FPGAs The make flow supports also loading the bitstream into FPGAs via the Vivado hardware server. Simply use make .vconfig Note: works with Arty, Basys3, Cmod A7, Nexys A7, and Nexys4, only one board must connected. ### Note on ISE The development for Nexys4 started in 2013 with ISE but moved to Vivado when it matured in 2014 (see [blog](https://wfjm.github.io/blogs/w11/2015-02-01-vivado-and-nexys4.html)). The make files for the ISE build flows have been kept for comparison are have the name `Makefile.ise`. So for some Nexys4 designs one can still start with a make -f Makefile.ise or makeise an ISE based build. To be used for tool comparisons, the ISE generated bit files were never tested in an FPGA.