File: mi004_function.v

package info (click to toggle)
vbs 1.4.0-9
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,200 kB
  • ctags: 4,401
  • sloc: cpp: 17,648; yacc: 1,880; ansic: 884; makefile: 419; sh: 375; lex: 345
file content (43 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Test function definition.
 *  dependencies:
 *	register declaration
 *	initial procedural block
 *	sequential block
 *	system task/function
 *	blocking assignment
 */

module main;

	reg [0:3] a, main_a;

function [0:3] my_func;
	input [0:3] a, input_a; /* To test scope resolution. */
	reg [0:3] c, func_c;

	begin
	$write("entering my_func:\n");
	$write("a = %b, input_a = %b\n", a, input_a);
	$write("c = %b, func_c = %b\n", c, func_c);
	c = a + 4;
	func_c = input_a + 5;
	$write("leaving my_func:\n");
	$write("a = %b, input_a = %b\n", a, input_a);
	$write("c = %b, func_c = %b\n", c, func_c);
	my_func = 5;	
	end

endfunction

	initial
		begin
		a = 0;
		main_a = 0;
		$write("a = %b, main_a = %b\n", a, main_a);
		$write("result = %b (5)\n",
			my_func(a,main_a));
		$write("a = %b, main_a = %b\n", a, main_a);
		end

endmodule