Setting Up Simulation in ModelSim - jhu-cisst/mechatronics-firmware GitHub Wiki

Compile Xilinx Libraries

Xilinx documentation

  1. In ISE, click on xc6slx45-3fgg484 under Design panel, Hierarchy.
  2. In the window below, expand Design Utilities.
  3. Right-click on Compile HDL Simulation Libraries.
  4. Set target simulator to correct Modelsim version and Verilog.
  5. Set language to Verilog.
  6. Set simulator path to where modelsim.exe has been installed. (ex. "C:\modeltech64_10.0d\win64")
  7. Set compiled library directory (ex. "C:\Xilinx\Compiled") and apply.
  8. Make sure unisim and xilinxcorelib are checked for compilation.
  9. Back in main window, go to Preferences in the Edit menu.
  10. Under ISE General, click on Integrated Tools Options. (ex. "C:\modeltech64_10.0d\win64\modelsim.exe")
  11. Back in main window, go to Design Properties in the Project menu.
  12. Select the same Simulator as above.
  13. Set language to Verilog.
  14. Right-click on Compile HDL Simulation Libraries and Implement Top Module.

Set up ModelSim

  1. From File dropdown menu, change directory to where the Simulation folder should go.
  2. Create a new project. (ex. FPGA1394_QLA_Simulation)
  3. Choose a default library name (ex. "work") and copy settings from modelsim.ini.
  4. Add all .v files in FPGA1394_QLA/Verilog to project, as well as hub_mem_gen.v and pkt_mem_gen.v from ipcore_dir.
  5. This will not compile since it is missing Xilinx libraries that were just compiled. To link to them, create a new library.
  6. Choose "a map to an existing library" and set a name (ex. "unisims_ver"). Set the path to be where the UNISIM library was compiled previously. (ex. "C:\Xilinx\Compiled\unisims_ver")
  7. Repeat and create a map to xinlinxcorelib_ver.
  8. Add glbl.v to project from "$XILINX/verilog/src/glbl.v".
  9. Compile all. This may fail depending on Firmware version since ModelSim has stricter syntax requirements than Xilinx ISE. Double click on the x for the failed files to see error log.
  10. Add a testbench file. For example, see FPGA1394_QLA_tb.v in the Simulation folder.
  11. Under the Project menu, select Add to Project, Simulation Configuration...
  12. In Design Unit(s), add the testbench you'd like to simulate and the glbl file. (ex. work.FPGA1394_QLA_tb work.glbl)
  13. Uncheck Enable optimization.
  14. In Libraries tab, add unisims_ver and xilinxcorelib_ver.
  15. Save and double-click entry to run simulation.