HDLRuby 2.11.12 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.html +3274 -0
  3. data/README.md +660 -128
  4. data/ext/hruby_sim/hruby_sim_calc.c +2 -0
  5. data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
  6. data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
  7. data/lib/HDLRuby/hdr_samples/constant_in_function.rb +2 -1
  8. data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
  9. data/lib/HDLRuby/hdr_samples/with_bram.rb +3 -3
  10. data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
  11. data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
  12. data/lib/HDLRuby/hdr_samples/with_ref_expr.rb +30 -0
  13. data/lib/HDLRuby/hdr_samples/with_sequencer.rb +185 -0
  14. data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
  15. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +439 -0
  16. data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
  17. data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +63 -0
  18. data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
  19. data/lib/HDLRuby/hdrcc.rb +16 -3
  20. data/lib/HDLRuby/hdrlib.rb +1 -1
  21. data/lib/HDLRuby/hruby_db.rb +2 -2
  22. data/lib/HDLRuby/hruby_high.rb +61 -25
  23. data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
  24. data/lib/HDLRuby/hruby_low.rb +2 -2
  25. data/lib/HDLRuby/hruby_low2c.rb +58 -43
  26. data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
  27. data/lib/HDLRuby/hruby_low2high.rb +86 -44
  28. data/lib/HDLRuby/hruby_low2seq.rb +26 -18
  29. data/lib/HDLRuby/hruby_low2sym.rb +14 -13
  30. data/lib/HDLRuby/hruby_low2vhd.rb +78 -43
  31. data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
  32. data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
  33. data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
  34. data/lib/HDLRuby/hruby_low_fix_types.rb +64 -32
  35. data/lib/HDLRuby/hruby_low_mutable.rb +53 -118
  36. data/lib/HDLRuby/hruby_low_resolve.rb +26 -31
  37. data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
  38. data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
  39. data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
  40. data/lib/HDLRuby/hruby_low_without_concat.rb +19 -13
  41. data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
  42. data/lib/HDLRuby/hruby_low_without_parinseq.rb +18 -12
  43. data/lib/HDLRuby/hruby_low_without_select.rb +36 -23
  44. data/lib/HDLRuby/hruby_low_without_subsignals.rb +79 -39
  45. data/lib/HDLRuby/hruby_rcsim.rb +79 -64
  46. data/lib/HDLRuby/hruby_rsim.rb +64 -15
  47. data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
  48. data/lib/HDLRuby/hruby_rsim_vcd.rb +28 -25
  49. data/lib/HDLRuby/hruby_types.rb +5 -5
  50. data/lib/HDLRuby/hruby_values.rb +19 -8
  51. data/lib/HDLRuby/hruby_verilog.rb +191 -65
  52. data/lib/HDLRuby/hruby_verilog_name.rb +49 -42
  53. data/lib/HDLRuby/soft/stacks.rb +219 -0
  54. data/lib/HDLRuby/std/bram.rb +9 -5
  55. data/lib/HDLRuby/std/clocks.rb +1 -1
  56. data/lib/HDLRuby/std/fsm.rb +39 -10
  57. data/lib/HDLRuby/std/sequencer.rb +2085 -0
  58. data/lib/HDLRuby/std/sequencer_func.rb +533 -0
  59. data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
  60. data/lib/HDLRuby/std/std.rb +13 -0
  61. data/lib/HDLRuby/version.rb +1 -1
  62. data/tuto/adder_sat_flags_vcd.png +0 -0
  63. data/tuto/addsub_vcd.png +0 -0
  64. data/tuto/alu_vcd.png +0 -0
  65. data/tuto/bit_pong_vcd.png +0 -0
  66. data/tuto/checksum_vcd.png +0 -0
  67. data/tuto/circuit_hdr.odg +0 -0
  68. data/tuto/circuit_hdr.png +0 -0
  69. data/tuto/circuit_hie.odg +0 -0
  70. data/tuto/circuit_hie.png +0 -0
  71. data/tuto/circuit_view.odg +0 -0
  72. data/tuto/circuit_view.png +0 -0
  73. data/tuto/clock_counter_vcd.png +0 -0
  74. data/tuto/counter_ext_vcd.png +0 -0
  75. data/tuto/fact_vcd.png +0 -0
  76. data/tuto/hw_flow.odg +0 -0
  77. data/tuto/hw_flow.png +0 -0
  78. data/tuto/maxxer_vcd.png +0 -0
  79. data/tuto/pingpong0_vcd.png +0 -0
  80. data/tuto/pingpong1_vcd.png +0 -0
  81. data/tuto/pingpong2_vcd.png +0 -0
  82. data/tuto/ram_vcd.png +0 -0
  83. data/tuto/serializer_vcd.png +0 -0
  84. data/tuto/sw_flow.odg +0 -0
  85. data/tuto/sw_flow.png +0 -0
  86. data/tuto/the_counter_vcd.png +0 -0
  87. data/tuto/tutorial_sw.html +2359 -0
  88. data/tuto/tutorial_sw.md +2890 -0
  89. data/tuto/tutorial_sw.pdf +0 -0
  90. data/tuto/tutorial_sw_jp.md +417 -0
  91. metadata +46 -2
@@ -1777,6 +1777,8 @@ Value write_range_bitstring_no_z(Value src,
1777
1777
  unsigned long long bw = type_width(base);
1778
1778
  first *= bw;
1779
1779
  last *= bw;
1780
+ last += bw-1;
1781
+ // printf("bw=%lld, first=%lld, last=%lld\n",bw,first,last);
1780
1782
  /* Access the source and destination bitstring data. */
1781
1783
  char* dst_data = dst->data_str;
1782
1784
  char* src_data = src->data_str;
@@ -1,14 +1,14 @@
1
1
  require "HDLRuby/hruby_error"
2
2
 
3
+ module HDLRuby::Low
3
4
 
4
5
 
5
6
  ##
6
7
  # Adds methods for allocating addresses to signals in Code objects.
7
8
  #
8
9
  ########################################################################
9
- module HDLRuby::Low
10
10
 
11
- ## An allocator.
11
+ ## Describes an allocator.
12
12
  class Allocator
13
13
 
14
14
  # The space range for the allocation.
@@ -3,16 +3,16 @@ require "HDLRuby/hruby_low_resolve"
3
3
  require "HDLRuby/backend/hruby_allocator"
4
4
 
5
5
 
6
+ module HDLRuby::Low
6
7
 
7
8
  ##
8
9
  # Adds methods for allocating addresses to signals in Code objects and
9
10
  # integrate the result into C code.
10
11
  #
11
12
  ########################################################################
12
- module HDLRuby::Low
13
13
 
14
- ## Extends the SystemT class with support for C allocation of signals.
15
14
  class SystemT
15
+ ## Extends the SystemT class with support for C allocation of signals.
16
16
 
17
17
  ## Allocates signals within C code using +allocator+.
18
18
  def c_code_allocate(allocator)
@@ -21,8 +21,8 @@ module HDLRuby::Low
21
21
  end
22
22
 
23
23
 
24
- ## Extends the scope class with support for C allocation of signals.
25
24
  class Scope
25
+ ## Extends the scope class with support for C allocation of signals.
26
26
 
27
27
  ## Allocates signals within C code using +allocator+.
28
28
  def c_code_allocate(allocator)
@@ -34,10 +34,10 @@ module HDLRuby::Low
34
34
  end
35
35
 
36
36
 
37
- ## Extends the chunk class with support for self modification with
38
- # allocation.
39
- # NOTE: only work if the chunk is in C language.
40
37
  class Chunk
38
+ ## Extends the chunk class with support for self modification with
39
+ # allocation.
40
+ # NOTE: only works if the chunk is in C language.
41
41
 
42
42
  ## Allocates signal within C code using +allocator+ and self-modify
43
43
  # the code correspondingly.
@@ -61,8 +61,8 @@ module HDLRuby::Low
61
61
  end
62
62
 
63
63
 
64
- ## Extends the code class with support for C allocation of signals.
65
64
  class Code
65
+ ## Extends the code class with support for C allocation of signals.
66
66
 
67
67
  ## Allocates signals within C code using +allocator+.
68
68
  def c_code_allocate(allocator)
@@ -1,7 +1,8 @@
1
1
  # Sample for testing constant declaration in function.
2
2
 
3
3
 
4
- function :func do |addr|
4
+ # function :func do |addr|
5
+ hdef :func do |addr|
5
6
  bit[4][-4].constant tbl: [ _b1000, _b1001, _b1010, _b1011 ]
6
7
 
7
8
  tbl[addr]
@@ -28,7 +28,7 @@ system :mei8 do |prog_file = "./prog.obj"|
28
28
  bit[7..0][-256].constant mem: # The content of the memory
29
29
  ( File.readlines(prog_file).map {|l| l.split[0] }.select do |l|
30
30
  ["0","1"].include?(l[2])
31
- end.map {|l| l[2..9].to_i(2) } )
31
+ end.map {|l| l[2..9].to_i(2).to_expr.as(bit[8]) } )
32
32
  instr <= mem[addr] # The access procedure
33
33
  end
34
34
 
@@ -18,13 +18,13 @@ system :bram_test do
18
18
 
19
19
  timed do
20
20
  clk <= 0
21
- rwb <= 1
21
+ rwb <= 0
22
22
  addr <= 0
23
23
  din <= 0
24
24
  !10.ns
25
25
  clk <= 1
26
26
  !10.ns
27
- rwb <= 1
27
+ rwb <= 0
28
28
  repeat(16) do
29
29
  clk <= 0
30
30
  !10.ns
@@ -33,7 +33,7 @@ system :bram_test do
33
33
  din <= din + 1
34
34
  !10.ns
35
35
  end
36
- rwb <= 0
36
+ rwb <= 1
37
37
  repeat(16) do
38
38
  clk <= 0
39
39
  !10.ns
@@ -0,0 +1,105 @@
1
+ require 'soft/stacks.rb'
2
+
3
+ include HDLRuby::High::Soft
4
+
5
+
6
+ # A system testing the bram-based stack.
7
+ system :bram_stach_test do
8
+
9
+ widthD = 8
10
+ size = 1024
11
+ depth = 16
12
+
13
+
14
+ input :clk, :rst, :ce
15
+ [2].inner :cmd
16
+ { frame: bit[depth.width], offset: bit[size.width] }.inner :loc
17
+ [size.width].inner :frame_size
18
+ [widthD].inner :din,:dout
19
+ inner :empty, :full
20
+
21
+ bram_frame_stack(widthD,size,depth).(:stack0).(clk,rst,ce,cmd,loc,din,dout,empty,full)
22
+
23
+ timed do
24
+ clk <= 0
25
+ rst <= 0
26
+ ce <= 0
27
+ cmd <= READ
28
+ loc.frame <= 0
29
+ loc.offset <= 0
30
+ frame_size <= 0
31
+ din <= 0
32
+ !10.ns
33
+ clk <= 1
34
+ !10.ns
35
+ clk <= 0
36
+ rst <= 1
37
+ !10.ns
38
+ clk <= 1
39
+ !10.ns
40
+ clk <= 0
41
+ rst <= 0
42
+ !10.ns
43
+ clk <= 1
44
+ repeat(9) do
45
+ !10.ns
46
+ clk <= 0
47
+ ce <= 1
48
+ cmd <= PUSH
49
+ frame_size <= frame_size + 16
50
+ loc.offset <= frame_size
51
+ !10.ns
52
+ clk <= 1
53
+ !10.ns
54
+ clk <= 0
55
+ cmd <= WRITE
56
+ din <= 5
57
+ loc.frame <= 0
58
+ loc.offset <= 1
59
+ !10.ns
60
+ clk <= 1
61
+ !10.ns
62
+ clk <= 0
63
+ cmd <= READ
64
+ loc.frame <= 0
65
+ loc.offset <= 1
66
+ !10.ns
67
+ clk <= 1
68
+ !10.ns
69
+ clk <= 0
70
+ cmd <= WRITE
71
+ din <= 55
72
+ loc.frame <= 1
73
+ loc.offset <= 14
74
+ !10.ns
75
+ clk <= 1
76
+ !10.ns
77
+ clk <= 0
78
+ cmd <= READ
79
+ loc.frame <= 1
80
+ loc.offset <= 14
81
+ !10.ns
82
+ clk <= 1
83
+ end
84
+ !10.ns
85
+ clk <= 0
86
+ ce <= 0
87
+ !10.ns
88
+ clk <= 1
89
+ repeat(9) do
90
+ !10.ns
91
+ clk <= 0
92
+ ce <= 1
93
+ cmd <= POP
94
+ !10.ns
95
+ clk <= 1
96
+ end
97
+ !10.ns
98
+ clk <= 0
99
+ ce <= 0
100
+ !10.ns
101
+ clk <= 1
102
+ !10.ns
103
+ end
104
+
105
+ end
@@ -0,0 +1,69 @@
1
+ require 'soft/stacks.rb'
2
+
3
+ include HDLRuby::High::Soft
4
+
5
+
6
+ # A system testing the bram-based stack.
7
+ system :bram_stach_test do
8
+
9
+ size = 8
10
+ widthD = 8
11
+
12
+
13
+ input :clk, :rst, :ce
14
+ inner :cmd
15
+ [widthD].inner :din,:dout
16
+ inner :empty, :full
17
+
18
+ bram_stack(widthD,size).(:stack0).(clk,rst,ce,cmd,din,dout,empty,full)
19
+
20
+ timed do
21
+ clk <= 0
22
+ rst <= 0
23
+ ce <= 0
24
+ cmd <= PUSH
25
+ din <= 0
26
+ !10.ns
27
+ clk <= 1
28
+ !10.ns
29
+ clk <= 0
30
+ rst <= 1
31
+ !10.ns
32
+ clk <= 1
33
+ !10.ns
34
+ clk <= 0
35
+ rst <= 0
36
+ din <= 0
37
+ !10.ns
38
+ clk <= 1
39
+ repeat(9) do
40
+ !10.ns
41
+ clk <= 0
42
+ ce <= 1
43
+ cmd <= PUSH
44
+ din <= din + 1
45
+ !10.ns
46
+ clk <= 1
47
+ end
48
+ !10.ns
49
+ clk <= 0
50
+ ce <= 0
51
+ !10.ns
52
+ clk <= 1
53
+ repeat(9) do
54
+ !10.ns
55
+ clk <= 0
56
+ ce <= 1
57
+ cmd <= POP
58
+ !10.ns
59
+ clk <= 1
60
+ end
61
+ !10.ns
62
+ clk <= 0
63
+ ce <= 0
64
+ !10.ns
65
+ clk <= 1
66
+ !10.ns
67
+ end
68
+
69
+ end
@@ -0,0 +1,30 @@
1
+
2
+ # A benchmark for testing range reference and index reference on expressions.
3
+ system :with_concat do
4
+ [8].inner :val0,:val1
5
+ inner :val2
6
+ [4].inner :val3, :count
7
+ inner :val4
8
+ [4].inner :val5
9
+
10
+ val2 <= (val0+val1)[4]
11
+ val3 <= (val0+val1)[3..0]
12
+
13
+ val4 <= val0[4]
14
+ val5 <= val0[3..0]
15
+
16
+ timed do
17
+ val0 <= _b00001111
18
+ val1 <= _b11000011
19
+ count <= 0
20
+ !10.ns
21
+ val0 <= _b11110000
22
+ val1 <= _b00111100
23
+ count <= 1
24
+ !10.ns
25
+ val0 <= _b10101010
26
+ val1 <= _b01010101
27
+ count <= 2
28
+ !10.ns
29
+ end
30
+ end
@@ -0,0 +1,185 @@
1
+ require 'std/sequencer.rb'
2
+
3
+ include HDLRuby::High::Std
4
+
5
+ # Checking the usage of sequencers:
6
+ # - One sequencer computes a fibbnacci series until 100
7
+ # - One sequencer computes a fibbnacci series until 1000 with early termination
8
+ # for testing sterminate.
9
+ # - One sequencer computes a fibbnacci series until 1000 with ealry break
10
+ # for testing sbreak.
11
+ # - One sequence that increase a first counter and the other one every four
12
+ # increases of the first one for testing scontinue.
13
+ # - One sequencer computes the square value of each elements of a buffer.
14
+ # - One sequencer computes the square value of each elements of a range.
15
+ # - One sequencer concatenates the value of a counter with its index.
16
+ # - One sequencer puts the sum of two arrays in a third one.
17
+ # - One sequencer iterates over two arrays.
18
+ # - One sequencer iterates downward.
19
+ system :my_seqencer do
20
+
21
+ inner :clk,:rst
22
+ [16].inner :u, :v,:res0
23
+
24
+ sequencer(clk.posedge,rst) do
25
+ # hprint("#0\n")
26
+ u <= 0
27
+ v <= 1
28
+ step
29
+ res0 <= 0
30
+ # hprint("#1 res0=",res0,"\n")
31
+ swhile(v < 100) do
32
+ v <= u + v
33
+ u <= v - u
34
+ # hprint("#2 v=",v,"\n")
35
+ end
36
+ res0 <= v
37
+ # hprint("#3 res0=",res0,"\n")
38
+ end
39
+
40
+ [16].inner :uu, :vv
41
+ sequencer(clk.posedge,rst) do
42
+ # hprint("##0\n")
43
+ uu <= 0
44
+ vv <= 1
45
+ swhile(vv<10000) do
46
+ vv <= uu + vv
47
+ uu <= vv - uu
48
+ step
49
+ # hprint("##1 vv=",vv,"\n")
50
+ sif(vv >= 100) { sterminate }
51
+ end
52
+ # hprint("##2 vv=",vv,"... But should not be here!\n")
53
+ end
54
+
55
+ [16].inner :uuu, :vvv, :res00
56
+
57
+ sequencer(clk.posedge,rst) do
58
+ # hprint("###0\n")
59
+ res00 <= 0
60
+ steps(3) # Checks 3 steps
61
+ uuu <= 0
62
+ vvv <= 1
63
+ swhile(vvv<10000) do
64
+ vvv <= uuu + vvv
65
+ uuu <= vvv - uuu
66
+ # hprint("##1 vvv=",vvv,"\n")
67
+ sif(vvv >= 100) { sbreak }
68
+ selse { res00 <= res00 + 1 }
69
+ end
70
+ # hprint("##2 res00=",res00,"... and should be here!\n")
71
+ end
72
+
73
+ [8].inner :a,:b
74
+
75
+ sequencer(clk.posedge,rst) do
76
+ # hprint("=0\n")
77
+ a <= 0
78
+ b <= 0
79
+ sfor(0..19) do
80
+ a <= a + 1
81
+ # hprint("=1 a=",a,"\n")
82
+ sif(a % 4) { scontinue }
83
+ b <= b + 1
84
+ # hprint("=2 b=",b,"\n")
85
+ end
86
+ # hprint("=3 a=",a," b=",b,"\n")
87
+ end
88
+
89
+
90
+ bit[16][-8].inner buf: 8.times.map {|i| i.to_expr.as(bit[16]) }
91
+ [16].inner :res1
92
+ # [8].inner :idx
93
+
94
+ sequencer(clk.posedge,rst) do
95
+ res1 <= 0
96
+ # hprint("$0 res1=",res1,"\n")
97
+ buf.seach do |elem|
98
+ res1 <= elem * elem
99
+ # hprint("$1 elem=",elem," res1=",res1,"\n")
100
+ end
101
+ # hprint("$2 res1=",res1,"\n")
102
+ end
103
+
104
+ [32].inner :res2
105
+
106
+ sequencer(clk.posedge,rst) do
107
+ res2 <= 0
108
+ # hprint("%0 res2=",res2,"\n")
109
+ (_h00000000.._h00000007).seach do |elem|
110
+ res2 <= elem * elem
111
+ # hprint("%1 elem=",elem," res2=",res2,"\n")
112
+ end
113
+ # hprint("%2 res2=",res2,"\n")
114
+ end
115
+
116
+ [32].inner :res3
117
+
118
+ sequencer(clk.posedge,rst) do
119
+ res3 <= 0
120
+ # hprint("&0 res3=",res3,"\n")
121
+ 5.supto(10).with_index do |elem,idx|
122
+ res3 <= [elem[15..0],idx[15..0]]
123
+ # hprint("&1 elem=",elem," idx=",idx," res3=",res3,"\n")
124
+ end
125
+ # hprint("&2 res3=",res3,"\n")
126
+ end
127
+
128
+ bit[8][-8].inner ar0: [_h01,_h02,_h04,_h08, _h10,_h20,_h40,_h80]
129
+ bit[8][-8].inner ar1: [_h01,_h02,_h03,_h04, _h05,_h06,_h07,_h08]
130
+ bit[8][-8].inner :res4
131
+
132
+ sequencer(clk.posedge,rst) do
133
+ sfor(ar0) do |elem,idx|
134
+ res4[idx] <= elem + ar1[idx]
135
+ end
136
+ # hprint("res4=",res4,"\n")
137
+ end
138
+
139
+ [8].inner :res5
140
+
141
+ sequencer(clk.posedge,rst) do
142
+ res5 <= 0
143
+ # hprint("(0 res5=",res5,"\n")
144
+ (ar0.seach + ar1).seach do |elem|
145
+ res5 <= elem
146
+ # hprint("(1 res5=",res5,"\n")
147
+ end
148
+ # hprint("(2 res5=",res5,"\n")
149
+ end
150
+
151
+
152
+ [32].inner :res6
153
+
154
+ sequencer(clk.posedge,rst) do
155
+ res6 <= 0
156
+ # hprint(")0 res6=",res6,"\n")
157
+ 10.sdownto(1) do |elem|
158
+ res6 <= elem
159
+ # hprint(")1 res6=",res6,"\n")
160
+ end
161
+ # hprint(")2 res6=",res6,"\n")
162
+ end
163
+
164
+
165
+ timed do
166
+ clk <= 0
167
+ rst <= 0
168
+ !10.ns
169
+ clk <= 1
170
+ !10.ns
171
+ clk <= 0
172
+ rst <= 1
173
+ !10.ns
174
+ clk <= 1
175
+ !10.ns
176
+ clk <= 0
177
+ rst <= 0
178
+ !10.ns
179
+ clk <= 1
180
+ repeat(100) do
181
+ !10.ns
182
+ clk <= ~clk
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,91 @@
1
+ require 'std/sequencer.rb'
2
+
3
+ include HDLRuby::High::Std
4
+
5
+ # Checking the usage of sequencers with multiple and deep loops.
6
+ # Also checks empty loops and loops controlled from the outside.
7
+ system :my_seqencer do
8
+
9
+ inner :clk,:rst,:req
10
+
11
+ [16].inner :u, :v
12
+
13
+ sequencer(clk,rst) do
14
+ hprint("#0\n")
15
+ u <= 0
16
+ v <= 1
17
+ swhile(v<10) { v <= v + 1 }
18
+ hprint("#1\n")
19
+ swhile(u<10) { u <= u + 1 }
20
+ hprint("#2\n")
21
+ end
22
+
23
+ [16].inner :x, :y
24
+
25
+ sequencer(clk,rst) do
26
+ hprint("!0\n")
27
+ x <= 1
28
+ y <= 0
29
+ swhile(x<20) do
30
+ hprint("!1\n")
31
+ x <= x + 4
32
+ swhile(y<x) { y <= y + 1 }
33
+ end
34
+ hprint("!2\n")
35
+ end
36
+
37
+ [16].inner :z
38
+
39
+ sequencer(clk,rst) do
40
+ hprint("$0\n")
41
+ z <= 10
42
+ swhile(x==0)
43
+ z <= 0
44
+ hprint("$1\n")
45
+ swhile(x<10)
46
+ z <= 1
47
+ hprint("$2\n")
48
+ end
49
+
50
+ [16].inner :w
51
+
52
+ sequencer(clk,rst) do
53
+ hprint(":0\n")
54
+ w <= 0
55
+ sloop do
56
+ swhile(req == 1) { w <= 1 }
57
+ w <= w + 1
58
+ end
59
+ end
60
+
61
+
62
+ timed do
63
+ clk <= 0
64
+ rst <= 0
65
+ req <= 0
66
+ !10.ns
67
+ clk <= 1
68
+ !10.ns
69
+ clk <= 0
70
+ rst <= 1
71
+ !10.ns
72
+ clk <= 1
73
+ !10.ns
74
+ clk <= 0
75
+ rst <= 0
76
+ req <= 1
77
+ !10.ns
78
+ clk <= 1
79
+ repeat(10) do
80
+ !10.ns
81
+ clk <= ~clk
82
+ end
83
+ !10.ns
84
+ req <= 0
85
+ clk <= ~clk
86
+ repeat(60) do
87
+ !10.ns
88
+ clk <= ~clk
89
+ end
90
+ end
91
+ end