Sunday, October 6, 2013

How To apply inputs from Tcl Script - ModelSim


ModelSim Simulator allows us to run tcl script from its CLI.The input stimulus to be generated and output signals to be monitored (ie., examine <signal>) can be given in tcl script.

File name : <file-name>.tcl
                Example : stimulus.tcl 


How to Run tcl script from ModelSim CLI  ?

source  <path>/<file-name>.tcl
Example : source  stimulus.tcl 

In this example the script file is located in project base directory.
Below are some sample tcl scripts ,use and modify according to your needs.

Example 1.  

 This script will restart the simulation from time 0 ,adds input signals and runs the simulation .Open a file in text editor and save it with tcl extension (ie., stimulus.tcl) and then copy paste the below code.
  # This is a TCL script #  
  # File Name : stimulus.tcl #  
  # How To run : source stimulus.tcl #  
  #       execute this command in Isim CLI#  
  #       and path to stimulus.tcl should be given#  
  #       if its in different directory #   
  puts "..restarting simulation.."  
  restart  
  puts "..inserting input stimulus.."  
  force sig 0 0 ns, 1 40 ns -repeat 100 ns  
  force clock 0 0 ns , 1 20 ns  -repeat 40 ns  
  puts "..running simulation.."  
  run  





Saturday, October 5, 2013

How To Load VHDL Project in ModelSim


How to Load Vhdl File directly to ModelSim Simulator :

  Step 1:

  •  Start modelSim simulator (ModelSim PE student Edition 10.2)



















Step 2 :
  • Go to File -> New -> Project 
  • Give a project name and click OK.




















Step 3 :

 Adding items to your project 
  • Create New File -> to create a new vhdl file.
  • Add Existing File -> to add a existing vhdl file.
  • Create Simulation.
  • Create Folder.

















Say, D flip-flop vhdl file (here its testing.vhd ) is already present, then click on Add Existing File .It will open a new window asking for the file. After finding the file Click Ok.














Now the file is listed in Project window.
























Select this File (if more than one file select all files) .Right Click on selected file and then do Compile -> Compile All. 




























Step 4 :

  • go to Library Window
  • select the project ie., work -> dff    



Right Click on Project (ie., Dff) and Then click on Simulate.






















Now go to Objects Window , select the required signal and add it to wave window.



















Step 5 :

  Wave window is opened.
































Thursday, October 3, 2013

How To Run ModelSim Simulator - Xilinx


Step 1 :
  









Step 2:
  •  After Right Clicking go to Design Properties.
  •  Click on Simulator option and select type of simulator.
  •  Select ModelSim PE VHDL (student edition)
  •  Click  Ok.



 Step 3 :   

  • In the Design Window select Simulation and Select your module (Here its Dff) . 
  • Then Right Click on Simulate Behavioral Model.
  • Now Go to Process Properties -> Simulation Properties.
    In Simulation Properties Set 
  •   Simulation Runtime time = 0 ns (it will start the simulation from time 0 ns)
  •   Set the Step Size or keep default value.
  •   Click Apply and Ok after setting everything.





Step 4 :

  • Right Click on Simulate Behavioral Model.
  • And do Run.
  • ModelSim Simulator window will open with the loaded project.




Errors :

1.) Simulator Version Mismatch ! 
       






     How to Fix It :
  • Right Click on Simulate Behavioral Model.
  • And Go to Process Properties -> Simulation Properties.
  • Then Select Ignore Simulator / Compiled Library Version Check.
  • Re Run the simulation.