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 7: Illustrate the side-effects of a function return type

Verilog Examples

Runnable example from the Verilog Interview Questions Set 7 tutorial (Illustrate the side-effects of a function return type without a range.)

Open in IDE
testbench.v
module tb;

	// Should have been function [3:0] add(input [31:0] a, b);
	// Returns 1 bit value by default
  	function add(input [3:0] a, b); 	
    	add = a + b;
  	endfunction

	initial begin
		$display("Sum = %0d", add(4, 5)); 	// Returns 1
	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.