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