File: expr_ternary.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 (30 lines) | stat: -rw-r--r-- 494 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
/*
 * Test ternary expression.
 *  dependencies:
 *	register declaration
 *	initial procedural block
 *	system tasks
 *	blocking assignment
 */

module main ;

	reg [0:7] a, b, c;

	initial
		begin
		a = 5;
		b = 8'b0111_0100;
		c = 8'b1001_0110;
		$write("%b (0111_0100)\n", a ? b : c);
		a = 0;
		$write("%b (1001_0110)\n", a ? b : c);
		a = 8'b0000_00x0;
		$write("%b (xxx1_01x0)\n", a ? b : c);
		b = 0;
		c = 1;
		$write("%b (0000_00x0)\n", b ? b : c ? a : b);
		$finish;
		end

endmodule