package pkg;

	class instr_cls;
		rand int opnd1, opnd2;
 		rand byte op;
		rand byte id;
	
		function void print();
			$display("%d: op=%d, opnd1=%d, opnd2=%d", id, op, opnd1, opnd2);
		endfunction
	
	endclass

	instr_cls instr = new;

	task gen_stim(byte idx, bit use_thread);

		if (use_thread) begin
			assert (std::randomize(instr) with { instr.id == idx; } );
		end else begin
			assert (instr.randomize() with { instr.id == idx; } );
		end
			
		instr.print();
	endtask
		

endpackage
	
module core #(byte id=0)();
	import pkg::*;

	bit use_thread;

	initial begin
		use_thread = 0;
		for (int i=0; i<4; i++) begin
			#10;
			gen_stim(id,use_thread);
		end
		use_thread = 1;
		for (int i=0; i<4; i++) begin
			#10;
			gen_stim(id,use_thread);
		end
	end
		
endmodule

module top;

	core #(.id(1)) c1();
	core #(.id(2)) c2();

endmodule


