File: stmt004_ifelse.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 (45 lines) | stat: -rw-r--r-- 923 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
44
45
/*
 * Test if/else statement.
 *  dependencies:
 *	register declaration
 *	initial procedural block
 *	system tasks
 *	blocking assignment
 */

module main ;
	reg [1:4] a;

	initial
		begin
		if (0)
			$write("incorrect, passed a false test.\n");
		else
			$write("correct, failed a false test.\n");
		if (1)
			$write("correct, passed a true test.\n", a);
		else
			$write("incorrect, failed a true test.\n");
		a = 0;
		if (a)
			$write("incorrect, a = %h (0x0).\n", a);
		else
			$write("correct, a = %h (0x0).\n", a);
		a = 4'hf;
		if (a)
			$write("correct, a = %h (0xf)\n", a);
		else
			$write("incorrect, a = %h (0xf).\n", a);
		a = 6;
		if (a[2:3])
			$write("correct, a[2:3] = %h (0x3)\n", a[2:3]);
		else
			$write("incorrect, a[2:3] = %h (0x3).\n", a[2:3]);
		if (a[4:4])
			$write("incorrect, a[4:4] = %h (0x0)\n", a[4:4]);
		else
			$write("correct, a[4:4] = %h (0x0)\n", a[4:4]);
		$finish;
		end

endmodule