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

logic: Example 1: Driven from Both a Procedural Block and a Continuous Assign

SystemVerilog Data Types

Runnable example from the SystemVerilog logic tutorial (Example 1: Driven from Both a Procedural Block and a Continuous Assign)

Open in IDE
testbench.sv
module tb;
	logic [3:0]  my_data; 		// Declare a 4-bit logic type variable
	logic        en; 			// Declare a 1-bit logic type variable

	initial begin
    	$display ("my_data=0x%0h en=%0b", my_data, en);    	// Default value of logic type is X
		my_data = 4'hB; 									// logic datatype can be driven in initial/always blocks
      	$display ("my_data=0x%0h en=%0b", my_data, en);
      	#1;
      	$display ("my_data=0x%0h en=%0b", my_data, en);
	end
  
  	assign en = my_data[0]; 								// logic datatype can also be driven via assign statements
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.