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 9: How to generate array without randomization?

SystemVerilog Interview Questions

Runnable example from the SystemVerilog Interview Questions Set 9 tutorial (How to generate array without randomization?)

Open in IDE
testbench.sv
module tb;
	byte 	data_q [10];

	initial begin
		// Store numbers 0 through 9
		foreach (data_q [i])
			data_q[i] = i;

		// Shuffle the array
		data_q.shuffle();
	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.