Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Interview Questions Set 5: How to disable randomization?

SystemVerilog Interview Questions

Runnable example from the SystemVerilog Interview Questions Set 5 tutorial (How to disable randomization?)

Open in IDE
testbench.sv
class ABC;
	rand bit [3:0] data;
endclass

module tb;
	initial begin
		ABC m_abc = new;
		m_abc.data.rand_mode(0); 	// Disable randomization
		
		m_abc.data.rand_mode(1); 	// Enable randomization
	end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.