File: string1.v

package info (click to toggle)
tkgate 2.1%2Brepack-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,384 kB
  • sloc: ansic: 62,300; tcl: 20,345; xml: 2,731; yacc: 1,177; lex: 839; sh: 664; makefile: 180; perl: 39
file content (50 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (7)
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
46
47
48
49
50

module top;
  reg [7:0] a,b;
  reg [4:0] c,d;
  reg [10*8-1:0] x,y;
  integer i;

  initial
    begin
	a = 8'h42;

	{c,d} = a;
	$display("c=%h  d=%h",c,d);

	b[7:4] = 4'h6;
	b[3:0] = 4'h8;
	$display("b=%h",b);

	{a[3:0],a[7:4]} = a & 8'hff;
	$display("a=%h",a);

	x = "ABCDEFGHIJ";
    	$display("x=%s  x=%h",x,x);
 	for (i = 0;i < 10;i = i+1)
	  $display("x[%d:%d]=%s",8*i+7,8*i,x[8*i +: 8]);

 	for (i = 0;i < 10;i = i+1)
	  x[8*i +: 8] = (i+1)*(i+1);
	$display("x=%h",x);

 	for (i = 0;i < 10;i = i+1)
 	  begin	
	    y[8*i +: 8] = x[8*(9-i) +: 8];
	  end
	$display("y=%020h",y);

	// 
	// i should be read only on entering the loop so updates to i in
	// the body should not affect the number of iterations.
	// 
	i = 5;
	repeat (i)
	  begin
	    i = 2*(i - 1);
	    $display("hello i = %d",i);
	  end
	$display("done hello");
    end

endmodule