HDLRuby 2.11.12 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.html +3274 -0
- data/README.md +556 -84
- data/ext/hruby_sim/hruby_sim_calc.c +2 -0
- data/lib/HDLRuby/backend/hruby_allocator.rb +2 -2
- data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +105 -0
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -0
- data/lib/HDLRuby/hdr_samples/with_register_stack.rb +150 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +190 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +405 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
- data/lib/HDLRuby/hdrcc.rb +15 -2
- data/lib/HDLRuby/hdrlib.rb +1 -1
- data/lib/HDLRuby/hruby_db.rb +2 -2
- data/lib/HDLRuby/hruby_high.rb +38 -20
- data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
- data/lib/HDLRuby/hruby_low.rb +2 -2
- data/lib/HDLRuby/hruby_low2c.rb +58 -43
- data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
- data/lib/HDLRuby/hruby_low2high.rb +86 -44
- data/lib/HDLRuby/hruby_low2seq.rb +26 -18
- data/lib/HDLRuby/hruby_low2sym.rb +14 -13
- data/lib/HDLRuby/hruby_low2vhd.rb +78 -43
- data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
- data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
- data/lib/HDLRuby/hruby_low_fix_types.rb +64 -32
- data/lib/HDLRuby/hruby_low_mutable.rb +53 -118
- data/lib/HDLRuby/hruby_low_resolve.rb +26 -31
- data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
- data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
- data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
- data/lib/HDLRuby/hruby_low_without_concat.rb +19 -13
- data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +18 -12
- data/lib/HDLRuby/hruby_low_without_select.rb +36 -23
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +29 -28
- data/lib/HDLRuby/hruby_rcsim.rb +79 -64
- data/lib/HDLRuby/hruby_rsim.rb +64 -15
- data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
- data/lib/HDLRuby/hruby_rsim_vcd.rb +28 -25
- data/lib/HDLRuby/hruby_values.rb +13 -2
- data/lib/HDLRuby/hruby_verilog.rb +90 -48
- data/lib/HDLRuby/soft/stacks.rb +219 -0
- data/lib/HDLRuby/std/bram.rb +9 -5
- data/lib/HDLRuby/std/clocks.rb +1 -1
- data/lib/HDLRuby/std/fsm.rb +29 -9
- data/lib/HDLRuby/std/sequencer.rb +1857 -0
- data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
- data/lib/HDLRuby/std/std.rb +12 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/adder_sat_flags_vcd.png +0 -0
- data/tuto/addsub_vcd.png +0 -0
- data/tuto/alu_vcd.png +0 -0
- data/tuto/bit_pong_vcd.png +0 -0
- data/tuto/checksum_vcd.png +0 -0
- data/tuto/circuit_hdr.odg +0 -0
- data/tuto/circuit_hdr.png +0 -0
- data/tuto/circuit_hie.odg +0 -0
- data/tuto/circuit_hie.png +0 -0
- data/tuto/circuit_view.odg +0 -0
- data/tuto/circuit_view.png +0 -0
- data/tuto/clock_counter_vcd.png +0 -0
- data/tuto/counter_ext_vcd.png +0 -0
- data/tuto/fact_vcd.png +0 -0
- data/tuto/hw_flow.odg +0 -0
- data/tuto/hw_flow.png +0 -0
- data/tuto/maxxer_vcd.png +0 -0
- data/tuto/pingpong0_vcd.png +0 -0
- data/tuto/pingpong1_vcd.png +0 -0
- data/tuto/pingpong2_vcd.png +0 -0
- data/tuto/ram_vcd.png +0 -0
- data/tuto/serializer_vcd.png +0 -0
- data/tuto/sw_flow.odg +0 -0
- data/tuto/sw_flow.png +0 -0
- data/tuto/the_counter_vcd.png +0 -0
- data/tuto/tutorial_sw.html +2359 -0
- data/tuto/tutorial_sw.md +2684 -0
- data/tuto/tutorial_sw.pdf +0 -0
- data/tuto/tutorial_sw_jp.md +417 -0
- metadata +44 -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
|
-
##
|
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)
|
@@ -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 <=
|
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 <=
|
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 <=
|
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,150 @@
|
|
1
|
+
require 'soft/stacks.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Soft
|
4
|
+
|
5
|
+
|
6
|
+
# A system testing the bram-based stack.
|
7
|
+
system :register_stack_test do
|
8
|
+
|
9
|
+
widthA = 3
|
10
|
+
size = 2**widthA
|
11
|
+
widthD = 8
|
12
|
+
|
13
|
+
|
14
|
+
input :clk,:rst,:ce
|
15
|
+
[2].inner :cmd
|
16
|
+
[widthD].inner :din,:dout
|
17
|
+
inner :empty, :full
|
18
|
+
douts = size.times.map { |i| [widthD].inner :"dout#{i}" }
|
19
|
+
|
20
|
+
register_stack(widthA,widthD,size).(:stackI).(clk,rst,ce,cmd,din,dout,empty,full,*douts)
|
21
|
+
|
22
|
+
[widthD].inner :count # Additional counter for the test.
|
23
|
+
|
24
|
+
timed do
|
25
|
+
clk <= 0
|
26
|
+
ce <= 0
|
27
|
+
rst <= 0
|
28
|
+
cmd <= READ
|
29
|
+
din <= 0
|
30
|
+
!10.ns
|
31
|
+
clk <= 1
|
32
|
+
!10.ns
|
33
|
+
clk <= 0
|
34
|
+
rst <= 1
|
35
|
+
!10.ns
|
36
|
+
clk <= 1
|
37
|
+
!10.ns
|
38
|
+
clk <= 0
|
39
|
+
rst <= 0
|
40
|
+
ce <= 1
|
41
|
+
din <= 1
|
42
|
+
!10.ns
|
43
|
+
clk <= 1
|
44
|
+
repeat(9) do
|
45
|
+
!10.ns
|
46
|
+
clk <= 0
|
47
|
+
cmd <= PUSH
|
48
|
+
din <= din + 1
|
49
|
+
!10.ns
|
50
|
+
clk <= 1
|
51
|
+
end
|
52
|
+
!10.ns
|
53
|
+
clk <= 0
|
54
|
+
!10.ns
|
55
|
+
clk <= 1
|
56
|
+
din <= -1
|
57
|
+
repeat(8) do
|
58
|
+
!10.ns
|
59
|
+
clk <= 0
|
60
|
+
cmd <= READ
|
61
|
+
din <= din + 1
|
62
|
+
!10.ns
|
63
|
+
clk <= 1
|
64
|
+
end
|
65
|
+
!10.ns
|
66
|
+
clk <= 0
|
67
|
+
!10.ns
|
68
|
+
clk <= 1
|
69
|
+
count <= 0
|
70
|
+
repeat(4) do
|
71
|
+
!10.ns
|
72
|
+
clk <= 0
|
73
|
+
din <= 1
|
74
|
+
cmd <= POP
|
75
|
+
!10.ns
|
76
|
+
clk <= 1
|
77
|
+
!10.ns
|
78
|
+
clk <= 0
|
79
|
+
count <= count + 1
|
80
|
+
din <= count
|
81
|
+
cmd <= PUSH
|
82
|
+
!10.ns
|
83
|
+
clk <= 1
|
84
|
+
end
|
85
|
+
!10.ns
|
86
|
+
clk <= 0
|
87
|
+
!10.ns
|
88
|
+
clk <= 1
|
89
|
+
repeat(9) do
|
90
|
+
!10.ns
|
91
|
+
clk <= 0
|
92
|
+
din <= 1
|
93
|
+
cmd <= POP
|
94
|
+
!10.ns
|
95
|
+
clk <= 1
|
96
|
+
end
|
97
|
+
!10.ns
|
98
|
+
clk <= 0
|
99
|
+
din <= _b8hAA
|
100
|
+
cmd <= PUSH
|
101
|
+
!10.ns
|
102
|
+
clk <= 1
|
103
|
+
!10.ns
|
104
|
+
clk <= 0
|
105
|
+
din <= 7
|
106
|
+
cmd <= WRITE
|
107
|
+
!10.ns
|
108
|
+
clk <= 1
|
109
|
+
din <= -1
|
110
|
+
repeat(8) do
|
111
|
+
!10.ns
|
112
|
+
clk <= 0
|
113
|
+
cmd <= WRITE
|
114
|
+
din <= din + 1
|
115
|
+
!10.ns
|
116
|
+
clk <= 1
|
117
|
+
end
|
118
|
+
!10.ns
|
119
|
+
clk <= 0
|
120
|
+
din <= size-1
|
121
|
+
cmd <= READ
|
122
|
+
!10.ns
|
123
|
+
clk <= 1
|
124
|
+
!10.ns
|
125
|
+
clk <= 0
|
126
|
+
din <= -3
|
127
|
+
cmd <= POP
|
128
|
+
!10.ns
|
129
|
+
clk <= 1
|
130
|
+
!10.ns
|
131
|
+
clk <= 0
|
132
|
+
din <= 31
|
133
|
+
cmd <= PUSH
|
134
|
+
!10.ns
|
135
|
+
clk <= 1
|
136
|
+
!10.ns
|
137
|
+
clk <= 0
|
138
|
+
din <= 3
|
139
|
+
cmd <= POP
|
140
|
+
!10.ns
|
141
|
+
clk <= 1
|
142
|
+
!10.ns
|
143
|
+
clk <= 0
|
144
|
+
din <= size-1
|
145
|
+
cmd <= READ
|
146
|
+
!10.ns
|
147
|
+
clk <= 1
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,190 @@
|
|
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
|
+
uuu <= 0
|
61
|
+
vvv <= 1
|
62
|
+
swhile(vvv<10000) do
|
63
|
+
vvv <= uuu + vvv
|
64
|
+
uuu <= vvv - uuu
|
65
|
+
step
|
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
|
+
# sfor(buf) do |elem,idx|
|
98
|
+
# buf.seach.with_index do |elem,idx|
|
99
|
+
# res1 <= elem * elem
|
100
|
+
# hprint("$1 res1=",res1," idx=",idx,"\n")
|
101
|
+
# end
|
102
|
+
buf.seach do |elem|
|
103
|
+
res1 <= elem * elem
|
104
|
+
hprint("$1 elem=",elem," res1=",res1,"\n")
|
105
|
+
end
|
106
|
+
hprint("$2 res1=",res1,"\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
[32].inner :res2
|
110
|
+
|
111
|
+
sequencer(clk.posedge,rst) do
|
112
|
+
res2 <= 0
|
113
|
+
hprint("%0 res2=",res2,"\n")
|
114
|
+
(0..7).seach do |elem|
|
115
|
+
res2 <= elem * elem
|
116
|
+
hprint("%1 elem=",elem," res2=",res2,"\n")
|
117
|
+
end
|
118
|
+
hprint("%2 res2=",res2,"\n")
|
119
|
+
end
|
120
|
+
|
121
|
+
[32].inner :res3
|
122
|
+
|
123
|
+
sequencer(clk.posedge,rst) do
|
124
|
+
res3 <= 0
|
125
|
+
hprint("&0 res3=",res3,"\n")
|
126
|
+
5.supto(10).with_index do |elem,idx|
|
127
|
+
res3 <= [elem[15..0],idx[15..0]]
|
128
|
+
hprint("&1 elem=",elem," idx=",idx," res3=",res3,"\n")
|
129
|
+
end
|
130
|
+
hprint("&2 res3=",res3,"\n")
|
131
|
+
end
|
132
|
+
|
133
|
+
bit[8][-8].inner ar0: [_h01,_h02,_h04,_h08, _h10,_h20,_h40,_h80]
|
134
|
+
bit[8][-8].inner ar1: [_h01,_h02,_h03,_h04, _h05,_h06,_h07,_h08]
|
135
|
+
bit[8][-8].inner :res4
|
136
|
+
|
137
|
+
sequencer(clk.posedge,rst) do
|
138
|
+
sfor(ar0) do |elem,idx|
|
139
|
+
res4[idx] <= elem + ar1[idx]
|
140
|
+
end
|
141
|
+
hprint("res4=",res4,"\n")
|
142
|
+
end
|
143
|
+
|
144
|
+
[8].inner :res5
|
145
|
+
|
146
|
+
sequencer(clk.posedge,rst) do
|
147
|
+
res5 <= 0
|
148
|
+
hprint("(0 res5=",res5,"\n")
|
149
|
+
(ar0.seach + ar1).seach do |elem|
|
150
|
+
res5 <= elem
|
151
|
+
hprint("(1 res5=",res5,"\n")
|
152
|
+
end
|
153
|
+
hprint("(2 res5=",res5,"\n")
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
[32].inner :res6
|
158
|
+
|
159
|
+
sequencer(clk.posedge,rst) do
|
160
|
+
res6 <= 0
|
161
|
+
hprint(")0 res6=",res6,"\n")
|
162
|
+
10.sdownto(1) do |elem|
|
163
|
+
res6 <= elem
|
164
|
+
hprint(")1 res6=",res6,"\n")
|
165
|
+
end
|
166
|
+
hprint(")2 res6=",res6,"\n")
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
timed do
|
171
|
+
clk <= 0
|
172
|
+
rst <= 0
|
173
|
+
!10.ns
|
174
|
+
clk <= 1
|
175
|
+
!10.ns
|
176
|
+
clk <= 0
|
177
|
+
rst <= 1
|
178
|
+
!10.ns
|
179
|
+
clk <= 1
|
180
|
+
!10.ns
|
181
|
+
clk <= 0
|
182
|
+
rst <= 0
|
183
|
+
!10.ns
|
184
|
+
clk <= 1
|
185
|
+
repeat(100) do
|
186
|
+
!10.ns
|
187
|
+
clk <= ~clk
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|