How to change random seed using command line parameter

I know that in VERA simulation, we can use +vera_random_seed=$(SEED) to change random seed without to re-compile. In fact i use shell script to get current time and pass it to vera seed. Every time I run simulaiton, the random data is not the same, it is very convenient.

I was wondering whether systemverilog has the same mechanics to change rand seed at command line.

Thanks!

Command line switches may be tool dependent.

In Questa, you can use the vsim switch -sv_seed [value]. You can also use random as value to generate unique seeds. It will print out the seed so you can replay it.

In reply to dave_59:

Thanks! Dave!
Got it!

In reply to Jonathan_Alvarez:

This is going to be tool specific, so you should contact your tool vendor directly. In general, the simulator must seed all the original starting processes (initial/always/static initialization processes) before even getting to the run command.

In reply to Jules:

Thanks Dave. I have a related question :). Is it possible to change the seed from the GUI of QuestaSim 10.3e?. Sometimes you don’t want to close the GUI to simulate a new seed. How do you do that? I haven’t found any command to do this from command line. The “run” options doesn’t allow you to change the seed. Isn’t it?
Thanks in advance

In reply to dave_59:

Hi Dave,
Thanks for your answer.
I would like to know about QuestaSIM 10.3e. I use Questa with UVM. Is it possible with the Mentor simulator?
Bye the way thanks a lot for all the contributions in Verification Academy. The forum is very useful
Thanks

In reply to Jonathan_Alvarez:

Simply enter your new vsim command in Transcript window.
This will quit the current simulation and run the new simulation with the new -sv_seed.

In reply to Nigele:

Thanks Nigele!
that was easy :)

In reply to Jonathan_Alvarez:

The variable name is echoed in the transcript: Sv_Seed

In reply to Jonathan_Alvarez:

I have another question.
If you want to reseed your simulation using “-sv_seed random” and then you want to see the value (without using logs/transcript) of the used seed, is there any variable in Questa to display the current seed?
We currently have some buttons in the modelsim GUI one to generate a random seed just for fun :) and other to rerun simulation cleaning the transcript. After cleaning the transcript the printed value from the original vsim seed get lost, however we would like to request always that value.
Is it possible?
Thanks in advance

I have used a workaround to solve my problem
See my button code in tcl below


#we need to wait some time (for the GUI) to load the buttons
after 5000 init_gui

# add the buttons
proc init_gui {} {
    global buttons_added
    if { ![info exists buttons_added] } {
	add_button
    }
    set buttons_added 1
}

proc add_button {} {
    apply_button_adder main controls right green black reseed {reseedbutton}
}


proc reseedbutton {} {
#vsim $argv -sv_seed random

    set tmpwave "/tmp/$::tcl_platform(user)_[clock microseconds]_wave.do"
    # avoid error message if wave window does not exist
    if { [catch { write format wave -window .main_pane.wave.interior.cs.body.pw.wf $tmpwave }]  == 0 } {
        delete wave *        
        transcript file tmp
        transcript file transcript
		set random [expr {int(rand()*1000000)}]
		regsub -all {\-sv_seed +[0-9]+} $::argv {} ::argv
        set ::argv  "$::argv -sv_seed $random"
		echo "vsim $::argv"
		if { $::argv != {}} { eval vsim $::argv}
        run 0	# we run 0 to make the transactions visible in questa
        do  $tmpwave
        file delete $tmpwave
       
    }
}

# BONUS button do rerunbutton
proc do_rerunbutton_cmd {{cmd {}}} {
    set tmpwave "/tmp/$::tcl_platform(user)_[clock microseconds]_wave.do"
    # avoid error message if wave window does not exist
    if { [catch { write format wave -window .main_pane.wave.interior.cs.body.pw.wf $tmpwave }]  == 0 } {
	delete wave *
	restart -f
	transcript file tmp
	transcript file transcript
	run 0
	do  $tmpwave
	file delete $tmpwave
	if { $cmd != {}} { eval $cmd}
    }
}

Then each time we push reseed button the seed variable will be in the “echo $argv” variable