HDLRuby 3.0.0 → 3.2.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.
- checksums.yaml +4 -4
- data/HDLRuby.gemspec +1 -0
- data/README.md +149 -79
- data/ext/hruby_sim/hruby_rcsim_build.c +2 -0
- data/ext/hruby_sim/hruby_sim_calc.c +33 -6
- data/ext/hruby_sim/hruby_sim_tree_calc.c +111 -22
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +2 -1
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +8 -7
- data/lib/HDLRuby/hdr_samples/dff_properties.rb +2 -0
- data/lib/HDLRuby/hdr_samples/enum_as_param.rb +52 -0
- data/lib/HDLRuby/hdr_samples/linear_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +6 -0
- data/lib/HDLRuby/hdr_samples/mei8.rb +6 -6
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +6 -6
- data/lib/HDLRuby/hdr_samples/memory_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +9 -5
- data/lib/HDLRuby/hdr_samples/ram.rb +7 -6
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +2 -0
- data/lib/HDLRuby/hdr_samples/struct.rb +15 -3
- data/lib/HDLRuby/hdr_samples/with_bram.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_channel.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_channel_other.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_class.rb +3 -1
- data/lib/HDLRuby/hdr_samples/with_connector.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +6 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint_adv.rb +73 -0
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_ref_expr.rb +30 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +49 -37
- data/lib/HDLRuby/hdr_samples/with_sequencer_channel.rb +58 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +113 -69
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +28 -14
- data/lib/HDLRuby/hdr_samples/with_sequencer_func.rb +63 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +2 -1
- data/lib/HDLRuby/hdrcc.rb +13 -1
- data/lib/HDLRuby/hruby_high.rb +105 -31
- data/lib/HDLRuby/hruby_low.rb +127 -3
- data/lib/HDLRuby/hruby_low2programs.rb +47 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +3 -2
- data/lib/HDLRuby/hruby_low_without_namespace.rb +133 -5
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +51 -12
- data/lib/HDLRuby/hruby_rcsim.rb +24 -1
- data/lib/HDLRuby/hruby_serializer.rb +2 -1
- data/lib/HDLRuby/hruby_types.rb +5 -5
- data/lib/HDLRuby/hruby_values.rb +7 -7
- data/lib/HDLRuby/hruby_verilog.rb +193 -35
- data/lib/HDLRuby/hruby_verilog_name.rb +35 -42
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +10 -1
- data/lib/HDLRuby/std/function_generator.rb +1 -1
- data/lib/HDLRuby/std/linear.rb +7 -7
- data/lib/HDLRuby/std/sequencer.rb +538 -60
- data/lib/HDLRuby/std/sequencer_channel.rb +90 -0
- data/lib/HDLRuby/std/sequencer_func.rb +546 -0
- data/lib/HDLRuby/std/std.rb +2 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/tutorial_sw.md +267 -61
- metadata +25 -4
- data/lib/HDLRuby/hdr_samples/with_register_stack.rb +0 -150
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# A class for a handshake transmission.
|
|
2
2
|
|
|
3
|
+
raise "Deprecated code."
|
|
4
|
+
|
|
3
5
|
class Handshaker
|
|
4
6
|
|
|
5
7
|
## Create a new handshaker for transmitting +type+ data.
|
|
@@ -179,7 +181,7 @@ end
|
|
|
179
181
|
|
|
180
182
|
# A system testing the producer/consumer.
|
|
181
183
|
system :hs_test do
|
|
182
|
-
|
|
184
|
+
inner :clk,:rst
|
|
183
185
|
|
|
184
186
|
# Declares the handshaker
|
|
185
187
|
hs = Handshaker.new([8])
|
|
@@ -11,6 +11,12 @@ system :fix_test do
|
|
|
11
11
|
bit[3..0,3..0].inner :x,:y,:z
|
|
12
12
|
# Declare three 8-bit integer part 8-bit fractional part
|
|
13
13
|
signed[3..0,3..0].inner :a,:b,:c,:d
|
|
14
|
+
# Declare the comparison results.
|
|
15
|
+
bit.inner :cmpU, :cmpS
|
|
16
|
+
|
|
17
|
+
cmpU <= (x >= y)
|
|
18
|
+
cmpS <= (a >= b)
|
|
19
|
+
|
|
14
20
|
|
|
15
21
|
# Performs calculation between then
|
|
16
22
|
timed do
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Sample for testing advanced expressions with fixpoint.
|
|
2
|
+
|
|
3
|
+
system :with_fixpoint_adv do
|
|
4
|
+
inner :clk,:rst
|
|
5
|
+
signed[8,8].inner :x,:y,:z,:u,:v,:w,:a,:b,:c,:d
|
|
6
|
+
bit.inner :cmp
|
|
7
|
+
|
|
8
|
+
cmp <= (x >= y)
|
|
9
|
+
u <= (x >= y)
|
|
10
|
+
|
|
11
|
+
sequencer(clk,rst) do
|
|
12
|
+
hif(5>4) { w <= _hFFFF }
|
|
13
|
+
helse { w <= _h0000 }
|
|
14
|
+
swhile(w<_h0000) do
|
|
15
|
+
hif(5>6) { w <= _hFFFF }
|
|
16
|
+
helse { w <= _h0000 }
|
|
17
|
+
end
|
|
18
|
+
5.stimes do
|
|
19
|
+
x <= _h0100
|
|
20
|
+
y <= _hFF34
|
|
21
|
+
a <= _h0100
|
|
22
|
+
b <= _h0100
|
|
23
|
+
c <= _h0100
|
|
24
|
+
step
|
|
25
|
+
x <= x*a
|
|
26
|
+
hif(x>=y) { z <= _hFFFF }
|
|
27
|
+
helse { z <= _h0000 }
|
|
28
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
29
|
+
hif(10>0) { w <= _hFFFF }
|
|
30
|
+
helse { w <= _h0000 }
|
|
31
|
+
d <= a*b*c
|
|
32
|
+
step
|
|
33
|
+
x <= _h0000
|
|
34
|
+
x <= x*a
|
|
35
|
+
y <= _hFE68
|
|
36
|
+
hif(x>=y) { z <= _hFFFF }
|
|
37
|
+
helse { z <= _h0000 }
|
|
38
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
39
|
+
hif(1>20) { w <= _hFFFF }
|
|
40
|
+
helse { w <= _h0000 }
|
|
41
|
+
a <= _h0200
|
|
42
|
+
d <= a*b*c
|
|
43
|
+
step
|
|
44
|
+
x <= _hFE00
|
|
45
|
+
x <= x*a
|
|
46
|
+
y <= _hFE02
|
|
47
|
+
hif(x>=y) { z <= _hFFFF }
|
|
48
|
+
helse { z <= _h0000 }
|
|
49
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
50
|
+
b <= _h0200
|
|
51
|
+
d <= a*b*c
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def cstep(n=1)
|
|
56
|
+
n.times do
|
|
57
|
+
clk <= ~clk
|
|
58
|
+
!10.ns
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
timed do
|
|
63
|
+
clk <= 0
|
|
64
|
+
rst <= 0
|
|
65
|
+
!10.ns
|
|
66
|
+
cstep(2)
|
|
67
|
+
rst <= 1
|
|
68
|
+
cstep(2)
|
|
69
|
+
rst <= 0
|
|
70
|
+
cstep(40)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
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
|
|
@@ -16,74 +16,75 @@ include HDLRuby::High::Std
|
|
|
16
16
|
# - One sequencer puts the sum of two arrays in a third one.
|
|
17
17
|
# - One sequencer iterates over two arrays.
|
|
18
18
|
# - One sequencer iterates downward.
|
|
19
|
+
# - One sequencer checks sub iterators (HDLRuby special).
|
|
19
20
|
system :my_seqencer do
|
|
20
21
|
|
|
21
22
|
inner :clk,:rst
|
|
22
23
|
[16].inner :u, :v,:res0
|
|
23
24
|
|
|
24
25
|
sequencer(clk.posedge,rst) do
|
|
25
|
-
hprint("#0\n")
|
|
26
|
+
# hprint("#0\n")
|
|
26
27
|
u <= 0
|
|
27
28
|
v <= 1
|
|
28
29
|
step
|
|
29
30
|
res0 <= 0
|
|
30
|
-
hprint("#1 res0=",res0,"\n")
|
|
31
|
+
# hprint("#1 res0=",res0,"\n")
|
|
31
32
|
swhile(v < 100) do
|
|
32
33
|
v <= u + v
|
|
33
34
|
u <= v - u
|
|
34
|
-
hprint("#2 v=",v,"\n")
|
|
35
|
+
# hprint("#2 v=",v,"\n")
|
|
35
36
|
end
|
|
36
37
|
res0 <= v
|
|
37
|
-
hprint("#3 res0=",res0,"\n")
|
|
38
|
+
# hprint("#3 res0=",res0,"\n")
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
[16].inner :uu, :vv
|
|
41
42
|
sequencer(clk.posedge,rst) do
|
|
42
|
-
hprint("##0\n")
|
|
43
|
+
# hprint("##0\n")
|
|
43
44
|
uu <= 0
|
|
44
45
|
vv <= 1
|
|
45
46
|
swhile(vv<10000) do
|
|
46
47
|
vv <= uu + vv
|
|
47
48
|
uu <= vv - uu
|
|
48
49
|
step
|
|
49
|
-
hprint("##1 vv=",vv,"\n")
|
|
50
|
+
# hprint("##1 vv=",vv,"\n")
|
|
50
51
|
sif(vv >= 100) { sterminate }
|
|
51
52
|
end
|
|
52
|
-
hprint("##2 vv=",vv,"... But should not be here!\n")
|
|
53
|
+
# hprint("##2 vv=",vv,"... But should not be here!\n")
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
[16].inner :uuu, :vvv, :res00
|
|
56
57
|
|
|
57
58
|
sequencer(clk.posedge,rst) do
|
|
58
|
-
hprint("###0\n")
|
|
59
|
+
# hprint("###0\n")
|
|
59
60
|
res00 <= 0
|
|
61
|
+
steps(3) # Checks 3 steps
|
|
60
62
|
uuu <= 0
|
|
61
63
|
vvv <= 1
|
|
62
64
|
swhile(vvv<10000) do
|
|
63
65
|
vvv <= uuu + vvv
|
|
64
66
|
uuu <= vvv - uuu
|
|
65
|
-
|
|
66
|
-
hprint("##1 vvv=",vvv,"\n")
|
|
67
|
+
# hprint("##1 vvv=",vvv,"\n")
|
|
67
68
|
sif(vvv >= 100) { sbreak }
|
|
68
69
|
selse { res00 <= res00 + 1 }
|
|
69
70
|
end
|
|
70
|
-
hprint("##2 res00=",res00,"... and should be here!\n")
|
|
71
|
+
# hprint("##2 res00=",res00,"... and should be here!\n")
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
[8].inner :a,:b
|
|
74
75
|
|
|
75
76
|
sequencer(clk.posedge,rst) do
|
|
76
|
-
hprint("=0\n")
|
|
77
|
+
# hprint("=0\n")
|
|
77
78
|
a <= 0
|
|
78
79
|
b <= 0
|
|
79
80
|
sfor(0..19) do
|
|
80
81
|
a <= a + 1
|
|
81
|
-
hprint("=1 a=",a,"\n")
|
|
82
|
+
# hprint("=1 a=",a,"\n")
|
|
82
83
|
sif(a % 4) { scontinue }
|
|
83
84
|
b <= b + 1
|
|
84
|
-
hprint("=2 b=",b,"\n")
|
|
85
|
+
# hprint("=2 b=",b,"\n")
|
|
85
86
|
end
|
|
86
|
-
hprint("=3 a=",a," b=",b,"\n")
|
|
87
|
+
# hprint("=3 a=",a," b=",b,"\n")
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
|
|
@@ -93,41 +94,36 @@ system :my_seqencer do
|
|
|
93
94
|
|
|
94
95
|
sequencer(clk.posedge,rst) do
|
|
95
96
|
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
|
|
97
|
+
# hprint("$0 res1=",res1,"\n")
|
|
102
98
|
buf.seach do |elem|
|
|
103
99
|
res1 <= elem * elem
|
|
104
|
-
hprint("$1 elem=",elem," res1=",res1,"\n")
|
|
100
|
+
# hprint("$1 elem=",elem," res1=",res1,"\n")
|
|
105
101
|
end
|
|
106
|
-
hprint("$2 res1=",res1,"\n")
|
|
102
|
+
# hprint("$2 res1=",res1,"\n")
|
|
107
103
|
end
|
|
108
104
|
|
|
109
105
|
[32].inner :res2
|
|
110
106
|
|
|
111
107
|
sequencer(clk.posedge,rst) do
|
|
112
108
|
res2 <= 0
|
|
113
|
-
hprint("%0 res2=",res2,"\n")
|
|
114
|
-
(
|
|
109
|
+
# hprint("%0 res2=",res2,"\n")
|
|
110
|
+
(_h00000000.._h00000007).seach do |elem|
|
|
115
111
|
res2 <= elem * elem
|
|
116
|
-
hprint("%1 elem=",elem," res2=",res2,"\n")
|
|
112
|
+
# hprint("%1 elem=",elem," res2=",res2,"\n")
|
|
117
113
|
end
|
|
118
|
-
hprint("%2 res2=",res2,"\n")
|
|
114
|
+
# hprint("%2 res2=",res2,"\n")
|
|
119
115
|
end
|
|
120
116
|
|
|
121
117
|
[32].inner :res3
|
|
122
118
|
|
|
123
119
|
sequencer(clk.posedge,rst) do
|
|
124
120
|
res3 <= 0
|
|
125
|
-
hprint("&0 res3=",res3,"\n")
|
|
121
|
+
# hprint("&0 res3=",res3,"\n")
|
|
126
122
|
5.supto(10).with_index do |elem,idx|
|
|
127
123
|
res3 <= [elem[15..0],idx[15..0]]
|
|
128
|
-
hprint("&1 elem=",elem," idx=",idx," res3=",res3,"\n")
|
|
124
|
+
# hprint("&1 elem=",elem," idx=",idx," res3=",res3,"\n")
|
|
129
125
|
end
|
|
130
|
-
hprint("&2 res3=",res3,"\n")
|
|
126
|
+
# hprint("&2 res3=",res3,"\n")
|
|
131
127
|
end
|
|
132
128
|
|
|
133
129
|
bit[8][-8].inner ar0: [_h01,_h02,_h04,_h08, _h10,_h20,_h40,_h80]
|
|
@@ -138,19 +134,19 @@ system :my_seqencer do
|
|
|
138
134
|
sfor(ar0) do |elem,idx|
|
|
139
135
|
res4[idx] <= elem + ar1[idx]
|
|
140
136
|
end
|
|
141
|
-
hprint("res4=",res4,"\n")
|
|
137
|
+
# hprint("res4=",res4,"\n")
|
|
142
138
|
end
|
|
143
139
|
|
|
144
140
|
[8].inner :res5
|
|
145
141
|
|
|
146
142
|
sequencer(clk.posedge,rst) do
|
|
147
143
|
res5 <= 0
|
|
148
|
-
hprint("(0 res5=",res5,"\n")
|
|
144
|
+
# hprint("(0 res5=",res5,"\n")
|
|
149
145
|
(ar0.seach + ar1).seach do |elem|
|
|
150
146
|
res5 <= elem
|
|
151
|
-
hprint("(1 res5=",res5,"\n")
|
|
147
|
+
# hprint("(1 res5=",res5,"\n")
|
|
152
148
|
end
|
|
153
|
-
hprint("(2 res5=",res5,"\n")
|
|
149
|
+
# hprint("(2 res5=",res5,"\n")
|
|
154
150
|
end
|
|
155
151
|
|
|
156
152
|
|
|
@@ -158,12 +154,28 @@ system :my_seqencer do
|
|
|
158
154
|
|
|
159
155
|
sequencer(clk.posedge,rst) do
|
|
160
156
|
res6 <= 0
|
|
161
|
-
hprint(")0 res6=",res6,"\n")
|
|
157
|
+
# hprint(")0 res6=",res6,"\n")
|
|
162
158
|
10.sdownto(1) do |elem|
|
|
163
159
|
res6 <= elem
|
|
164
|
-
hprint(")1 res6=",res6,"\n")
|
|
160
|
+
# hprint(")1 res6=",res6,"\n")
|
|
161
|
+
end
|
|
162
|
+
# hprint(")2 res6=",res6,"\n")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
[8].inner :res7,:res8
|
|
166
|
+
|
|
167
|
+
sequencer(clk.posedge,rst) do
|
|
168
|
+
res7 <= 0
|
|
169
|
+
res8 <= 0
|
|
170
|
+
ar0.seach_range(0..3) do |elem|
|
|
171
|
+
res7 <= elem
|
|
172
|
+
end
|
|
173
|
+
ar0.seach_range(4..9) do |elem|
|
|
174
|
+
res7 <= elem
|
|
175
|
+
end
|
|
176
|
+
(_h00.._h07).seach_range(1..4) do |elem|
|
|
177
|
+
res8 <= elem
|
|
165
178
|
end
|
|
166
|
-
hprint(")2 res6=",res6,"\n")
|
|
167
179
|
end
|
|
168
180
|
|
|
169
181
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'std/sequencer.rb'
|
|
2
|
+
|
|
3
|
+
include HDLRuby::High::Std
|
|
4
|
+
|
|
5
|
+
# Checking the usage of sequencers' channels.
|
|
6
|
+
system :my_seqencer do
|
|
7
|
+
|
|
8
|
+
inner :clk,:rst,filled: 0
|
|
9
|
+
bit[16][-16].inner :mem
|
|
10
|
+
[16].inner :res0, :res1, :res2, :res3
|
|
11
|
+
|
|
12
|
+
ch_read = schannel(bit[16],16) do |i|
|
|
13
|
+
mem[i]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ch_write = schannel(bit[16],16) do |i,val|
|
|
17
|
+
mem[i] <= val
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
sequencer(clk.posedge,rst) do
|
|
21
|
+
16.stimes { |i| ch_write.snext!(i) }
|
|
22
|
+
filled <= 1
|
|
23
|
+
16.stimes do |i|
|
|
24
|
+
res0 <= ch_read.snext
|
|
25
|
+
res1 <= ch_read[15-i]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sequencer(clk.posedge,rst) do
|
|
30
|
+
swhile(~filled);
|
|
31
|
+
16.stimes do |i|
|
|
32
|
+
res2 <= ch_read.snext
|
|
33
|
+
res3 <= ch_read[15-i]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
timed do
|
|
39
|
+
clk <= 0
|
|
40
|
+
rst <= 0
|
|
41
|
+
!10.ns
|
|
42
|
+
clk <= 1
|
|
43
|
+
!10.ns
|
|
44
|
+
clk <= 0
|
|
45
|
+
rst <= 1
|
|
46
|
+
!10.ns
|
|
47
|
+
clk <= 1
|
|
48
|
+
!10.ns
|
|
49
|
+
clk <= 0
|
|
50
|
+
rst <= 0
|
|
51
|
+
!10.ns
|
|
52
|
+
clk <= 1
|
|
53
|
+
repeat(100) do
|
|
54
|
+
!10.ns
|
|
55
|
+
clk <= ~clk
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|