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
|
@@ -34,6 +34,35 @@ include HDLRuby::High::Std
|
|
|
34
34
|
# - The twenty nineth sequencer checks stake and stake_while
|
|
35
35
|
# - The thirtieth sequencer checks suniq
|
|
36
36
|
# - The thirty first sequencer checks szip
|
|
37
|
+
# - The thirty second sequnecer checks seach_nexts (HDLRuby special)
|
|
38
|
+
#
|
|
39
|
+
# __WARNING__: All the operations on enumerators generate their own result
|
|
40
|
+
# signal. Therefore, in a real circuit, there is no need to
|
|
41
|
+
# declare your own signal for it, as demonstrated in this sample.
|
|
42
|
+
# In other words, the res<num> signals are unnecessary, and
|
|
43
|
+
# assigning the result to them only slows down the circuit without
|
|
44
|
+
# any benefit. Instead, they can be replaced with Ruby variables
|
|
45
|
+
# as shown below:
|
|
46
|
+
# from: res<num> <= <enumerator operation>
|
|
47
|
+
# to: <ruby variable> = <enumerator operation>
|
|
48
|
+
# In this sample it is done this way for an easy vizualization of
|
|
49
|
+
# the multiple results.
|
|
50
|
+
#
|
|
51
|
+
# For instance the first example should be rewritten from:
|
|
52
|
+
# [16].inner :res0, :res1
|
|
53
|
+
# sequencer(clk.posedge,rst) do
|
|
54
|
+
# res0 <= 0; res1 <= 1
|
|
55
|
+
# step
|
|
56
|
+
# res0 <= vals.sall? { |val| val!= _h11 }
|
|
57
|
+
# res1 <= vals.sall? { |val| val!= _h5C }
|
|
58
|
+
# end
|
|
59
|
+
# to:
|
|
60
|
+
# res0 = nil; res1 = nil
|
|
61
|
+
# sequencer(clk.posedge,rst) do
|
|
62
|
+
# res0 = vals.sall? { |val| val!= _h11 }
|
|
63
|
+
# res1 = vals.sall? { |val| val!= _h5C }
|
|
64
|
+
# end
|
|
65
|
+
#
|
|
37
66
|
system :my_seqencer do
|
|
38
67
|
|
|
39
68
|
inner :clk,:rst
|
|
@@ -43,258 +72,258 @@ system :my_seqencer do
|
|
|
43
72
|
[16].inner :res0, :res1
|
|
44
73
|
|
|
45
74
|
sequencer(clk.posedge,rst) do
|
|
46
|
-
hprint("#0\n")
|
|
75
|
+
# hprint("#0\n")
|
|
47
76
|
res0 <= 0
|
|
48
77
|
res1 <= 0
|
|
49
78
|
step
|
|
50
79
|
res0 <= vals.sall? { |val| val != _h11 }
|
|
51
80
|
res1 <= vals.sall? { |val| val != _h5C }
|
|
52
|
-
hprint("#1 res0=",res0," res1=",res1,"\n")
|
|
81
|
+
# hprint("#1 res0=",res0," res1=",res1,"\n")
|
|
53
82
|
end
|
|
54
83
|
|
|
55
84
|
[16].inner :res2, :res3
|
|
56
85
|
|
|
57
86
|
sequencer(clk.posedge,rst) do
|
|
58
|
-
hprint("$0\n")
|
|
87
|
+
# hprint("$0\n")
|
|
59
88
|
res2 <= 0
|
|
60
89
|
res3 <= 0
|
|
61
90
|
step
|
|
62
91
|
res2 <= vals.sany? { |val| val == _h11 }
|
|
63
92
|
res3 <= vals.sany? { |val| val == _h5C }
|
|
64
|
-
hprint("$1 res2=",res2," res3=",res3,"\n")
|
|
93
|
+
# hprint("$1 res2=",res2," res3=",res3,"\n")
|
|
65
94
|
end
|
|
66
95
|
|
|
67
96
|
[16].inner :res4
|
|
68
97
|
|
|
69
98
|
sequencer(clk.posedge,rst) do
|
|
70
|
-
hprint("!0\n")
|
|
99
|
+
# hprint("!0\n")
|
|
71
100
|
res4 <= 0
|
|
72
101
|
vals.schain(0..10).seach do |elem|
|
|
73
102
|
res4 <= elem
|
|
74
|
-
hprint("!1 res4=",res4,"\n")
|
|
103
|
+
# hprint("!1 res4=",res4,"\n")
|
|
75
104
|
end
|
|
76
|
-
hprint("!2 res4=",res4,"\n")
|
|
105
|
+
# hprint("!2 res4=",res4,"\n")
|
|
77
106
|
end
|
|
78
107
|
|
|
79
108
|
[8*8].inner :res5
|
|
80
109
|
|
|
81
110
|
sequencer(clk.posedge,rst) do
|
|
82
|
-
hprint("%0\n");
|
|
111
|
+
# hprint("%0\n");
|
|
83
112
|
res5 <= 0
|
|
84
113
|
res5 <= vals.smap { |val| val + 1 }
|
|
85
|
-
hprint("%1 res5=",res5,"\n");
|
|
114
|
+
# hprint("%1 res5=",res5,"\n");
|
|
86
115
|
end
|
|
87
116
|
|
|
88
117
|
[8*8].inner :res6
|
|
89
118
|
|
|
90
119
|
sequencer(clk.posedge,rst) do
|
|
91
|
-
hprint("&0\n");
|
|
120
|
+
# hprint("&0\n");
|
|
92
121
|
res6 <= 0
|
|
93
122
|
res6 <= vals.smap.with_index { |val,i| val + i }
|
|
94
|
-
hprint("&1 res6=",res6,"\n");
|
|
123
|
+
# hprint("&1 res6=",res6,"\n");
|
|
95
124
|
end
|
|
96
125
|
|
|
97
126
|
bit[8][-8].inner vals2: [ _h00, _h10, _h00, _h0B, _hFE, _h00, _h5C, _h00 ]
|
|
98
127
|
[8*8].inner :res7
|
|
99
128
|
|
|
100
129
|
sequencer(clk.posedge,rst) do
|
|
101
|
-
hprint("|0\n");
|
|
130
|
+
# hprint("|0\n");
|
|
102
131
|
res7 <= 0
|
|
103
132
|
res7 <= vals2.scompact
|
|
104
|
-
hprint("|1 res7=",res7,"\n");
|
|
133
|
+
# hprint("|1 res7=",res7,"\n");
|
|
105
134
|
end
|
|
106
135
|
|
|
107
136
|
[8].inner :res8, :res9, :res10
|
|
108
137
|
|
|
109
138
|
sequencer(clk.posedge,rst) do
|
|
110
|
-
hprint("(0\n");
|
|
139
|
+
# hprint("(0\n");
|
|
111
140
|
res8 <= 0
|
|
112
141
|
res9 <= 0
|
|
113
142
|
res10 <= 0
|
|
114
143
|
res8 <= vals2.scount
|
|
115
144
|
res9 <= vals2.scount(_h00)
|
|
116
145
|
res10 <= vals2.scount {|elem| elem > _h10 }
|
|
117
|
-
hprint("(1 res8=",res8," res9=",res9," res10=",res10,"\n");
|
|
146
|
+
# hprint("(1 res8=",res8," res9=",res9," res10=",res10,"\n");
|
|
118
147
|
end
|
|
119
148
|
|
|
120
149
|
[8].inner :res11, :res12
|
|
121
150
|
|
|
122
151
|
sequencer(clk.posedge,rst) do
|
|
123
|
-
hprint(")0\n")
|
|
152
|
+
# hprint(")0\n")
|
|
124
153
|
res11 <= 0
|
|
125
154
|
res12 <= 0
|
|
126
155
|
vals.scycle(2) { |elem| res11 <= elem }
|
|
127
|
-
hprint(")1 res11=",res11,"\n")
|
|
156
|
+
# hprint(")1 res11=",res11,"\n")
|
|
128
157
|
vals2.scycle { |elem| res12 <= elem }
|
|
129
|
-
hprint(")2 Should never be here! ... res12=",res12,"\n")
|
|
158
|
+
# hprint(")2 Should never be here! ... res12=",res12,"\n")
|
|
130
159
|
end
|
|
131
160
|
|
|
132
161
|
[8].inner :res13, :res14
|
|
133
162
|
|
|
134
163
|
sequencer(clk.posedge,rst) do
|
|
135
|
-
hprint("=0\n")
|
|
164
|
+
# hprint("=0\n")
|
|
136
165
|
res13 <= 0
|
|
137
166
|
res14 <= 0
|
|
138
167
|
res13 <= vals.sfind(-1) { |elem| elem > 0 }
|
|
139
168
|
res14 <= vals.sfind(-1) { |elem| elem == _hAA }
|
|
140
|
-
hprint("=1 res13=",res13," res14=",res14,"\n")
|
|
169
|
+
# hprint("=1 res13=",res13," res14=",res14,"\n")
|
|
141
170
|
end
|
|
142
171
|
|
|
143
172
|
[8*8].inner :res15, :res16
|
|
144
173
|
|
|
145
174
|
sequencer(clk.posedge,rst) do
|
|
146
|
-
hprint("+0\n")
|
|
175
|
+
# hprint("+0\n")
|
|
147
176
|
res15 <= 0
|
|
148
177
|
res16 <= 0
|
|
149
178
|
res15 <= vals.sdrop(3)
|
|
150
179
|
res16 <= vals.sdrop_while { |elem| elem < _hAA }
|
|
151
|
-
hprint("+1 res15=",res15," res16=",res16,"\n")
|
|
180
|
+
# hprint("+1 res15=",res15," res16=",res16,"\n")
|
|
152
181
|
end
|
|
153
182
|
|
|
154
183
|
[8].inner :res17
|
|
155
184
|
|
|
156
185
|
sequencer(clk.posedge,rst) do
|
|
157
|
-
hprint("*0\n")
|
|
186
|
+
# hprint("*0\n")
|
|
158
187
|
res17 <= 0
|
|
159
188
|
vals.seach_cons(3) { |a,b,c| res17 <= a+b+c }
|
|
160
|
-
hprint("*1 res17=",res17,"\n")
|
|
189
|
+
# hprint("*1 res17=",res17,"\n")
|
|
161
190
|
end
|
|
162
191
|
|
|
163
192
|
[8].inner :res18
|
|
164
193
|
|
|
165
194
|
sequencer(clk.posedge,rst) do
|
|
166
|
-
hprint("/0\n")
|
|
195
|
+
# hprint("/0\n")
|
|
167
196
|
res18 <= 0
|
|
168
197
|
vals.seach_slice(3) { |a,b,c| res18 <= a+b+c }
|
|
169
|
-
hprint("/1 res18=",res18,"\n")
|
|
198
|
+
# hprint("/1 res18=",res18,"\n")
|
|
170
199
|
end
|
|
171
200
|
|
|
172
201
|
[32*4].inner :res19
|
|
173
202
|
|
|
174
203
|
sequencer(clk.posedge,rst) do
|
|
175
|
-
hprint("~0\n")
|
|
204
|
+
# hprint("~0\n")
|
|
176
205
|
res19 <= 0
|
|
177
|
-
res19 <= (
|
|
178
|
-
hprint("~1 res19=",res19,"\n")
|
|
206
|
+
res19 <= (_h00000001.._h00000004).seach.sto_a
|
|
207
|
+
# hprint("~1 res19=",res19,"\n")
|
|
179
208
|
end
|
|
180
209
|
|
|
181
210
|
[8].inner :res21, :res22
|
|
182
211
|
|
|
183
212
|
sequencer(clk.posedge,rst) do
|
|
184
|
-
hprint(">0\n")
|
|
213
|
+
# hprint(">0\n")
|
|
185
214
|
res21 <= 0
|
|
186
215
|
res22 <= 0
|
|
187
216
|
res21 <= vals.sfind_index(_h0B)
|
|
188
217
|
res22 <= vals.sfind_index { |elem| elem < _hAA }
|
|
189
|
-
hprint(">1 res21=",res21," res22=",res22,"\n")
|
|
218
|
+
# hprint(">1 res21=",res21," res22=",res22,"\n")
|
|
190
219
|
end
|
|
191
220
|
|
|
192
221
|
[4*8].inner :res23
|
|
193
222
|
|
|
194
223
|
sequencer(clk.posedge,rst) do
|
|
195
|
-
hprint("<0\n")
|
|
224
|
+
# hprint("<0\n")
|
|
196
225
|
res23 <= 0
|
|
197
226
|
res23 <= vals.sfirst(4)
|
|
198
|
-
hprint("<1 res23=",res23,"\n")
|
|
227
|
+
# hprint("<1 res23=",res23,"\n")
|
|
199
228
|
end
|
|
200
229
|
|
|
201
230
|
inner :res24, :res25
|
|
202
231
|
|
|
203
232
|
sequencer(clk.posedge,rst) do
|
|
204
|
-
hprint("!0\n")
|
|
233
|
+
# hprint("!0\n")
|
|
205
234
|
res24 <= 0
|
|
206
235
|
res25 <= 0
|
|
207
236
|
res24 <= vals.sinclude?(_h0B)
|
|
208
237
|
res25 <= vals.sinclude?(_hAA)
|
|
209
|
-
hprint("!1 res24=",res24," res25=",res25,"\n")
|
|
238
|
+
# hprint("!1 res24=",res24," res25=",res25,"\n")
|
|
210
239
|
end
|
|
211
240
|
|
|
212
241
|
[8].inner :res26, :res27
|
|
213
242
|
|
|
214
243
|
sequencer(clk.posedge,rst) do
|
|
215
|
-
hprint(":0\n")
|
|
244
|
+
# hprint(":0\n")
|
|
216
245
|
res26 <= 0
|
|
217
246
|
res27 <= 0
|
|
218
|
-
res26 <= vals.sinject(
|
|
247
|
+
res26 <= vals.sinject(_h01) { |a,b| a+b }
|
|
219
248
|
res27 <= vals.sinject(:+)
|
|
220
|
-
hprint(":1 res26=",res26," res27=",res27,"\n")
|
|
249
|
+
# hprint(":1 res26=",res26," res27=",res27,"\n")
|
|
221
250
|
end
|
|
222
251
|
|
|
223
252
|
[8].inner :res28
|
|
224
253
|
[8*3].inner :res29
|
|
225
254
|
|
|
226
255
|
sequencer(clk.posedge,rst) do
|
|
227
|
-
hprint(";0\n")
|
|
256
|
+
# hprint(";0\n")
|
|
228
257
|
res28 <= 0
|
|
229
258
|
res29 <= 0
|
|
230
259
|
res28 <= vals.smax
|
|
231
260
|
res29 <= vals.smax(3)
|
|
232
|
-
hprint(";1 res28=",res28," res29=",res29,"\n")
|
|
261
|
+
# hprint(";1 res28=",res28," res29=",res29,"\n")
|
|
233
262
|
end
|
|
234
263
|
|
|
235
264
|
[8].inner :res30
|
|
236
265
|
[8*3].inner :res31
|
|
237
266
|
|
|
238
267
|
sequencer(clk.posedge,rst) do
|
|
239
|
-
hprint(",0\n")
|
|
268
|
+
# hprint(",0\n")
|
|
240
269
|
res30 <= 0
|
|
241
270
|
res31 <= 0
|
|
242
271
|
res30 <= vals.smax_by {|e| e.to_signed }
|
|
243
272
|
res31 <= vals.smax_by(3) {|e| e.to_signed }
|
|
244
|
-
hprint(",1 res30=",res30," res31=",res31,"\n")
|
|
273
|
+
# hprint(",1 res30=",res30," res31=",res31,"\n")
|
|
245
274
|
end
|
|
246
275
|
|
|
247
276
|
[8].inner :res32
|
|
248
277
|
[8*3].inner :res33
|
|
249
278
|
|
|
250
279
|
sequencer(clk.posedge,rst) do
|
|
251
|
-
hprint(".0\n")
|
|
280
|
+
# hprint(".0\n")
|
|
252
281
|
res32 <= 0
|
|
253
282
|
res33 <= 0
|
|
254
283
|
res32 <= vals.smin
|
|
255
284
|
res33 <= vals.smin(3)
|
|
256
|
-
hprint(".1 res32=",res32," res33=",res33,"\n")
|
|
285
|
+
# hprint(".1 res32=",res32," res33=",res33,"\n")
|
|
257
286
|
end
|
|
258
287
|
|
|
259
288
|
[8].inner :res34
|
|
260
289
|
[8*3].inner :res35
|
|
261
290
|
|
|
262
291
|
sequencer(clk.posedge,rst) do
|
|
263
|
-
hprint(":0\n")
|
|
292
|
+
# hprint(":0\n")
|
|
264
293
|
res34 <= 0
|
|
265
294
|
res35 <= 0
|
|
266
295
|
res34 <= vals.smin_by {|e| e.to_signed }
|
|
267
296
|
res35 <= vals.smin_by(3) {|e| e.to_signed }
|
|
268
|
-
hprint(":1 res34=",res34," res35=",res35,"\n")
|
|
297
|
+
# hprint(":1 res34=",res34," res35=",res35,"\n")
|
|
269
298
|
end
|
|
270
299
|
|
|
271
300
|
[16].inner :res36, :res37
|
|
272
301
|
|
|
273
302
|
sequencer(clk.posedge,rst) do
|
|
274
|
-
hprint("]0\n")
|
|
303
|
+
# hprint("]0\n")
|
|
275
304
|
res36 <= 0
|
|
276
305
|
res37 <= 0
|
|
277
306
|
res36 <= vals.sminmax
|
|
278
307
|
res37 <= vals.sminmax_by {|e| e.to_signed }
|
|
279
|
-
hprint("]1 res36=",res36," res37=",res37,"\n")
|
|
308
|
+
# hprint("]1 res36=",res36," res37=",res37,"\n")
|
|
280
309
|
end
|
|
281
310
|
|
|
282
311
|
[8].inner :res38, :res39
|
|
283
312
|
|
|
284
313
|
sequencer(clk.posedge,rst) do
|
|
285
|
-
hprint("[0\n")
|
|
314
|
+
# hprint("[0\n")
|
|
286
315
|
res38 <= 0
|
|
287
316
|
res39 <= 0
|
|
288
317
|
step
|
|
289
318
|
res38 <= vals.snone? { |val| val == _h11 }
|
|
290
319
|
res39 <= vals.snone?(_h5C)
|
|
291
|
-
hprint("[1 res38=",res38," res39=",res39,"\n")
|
|
320
|
+
# hprint("[1 res38=",res38," res39=",res39,"\n")
|
|
292
321
|
end
|
|
293
322
|
|
|
294
323
|
[8].inner :res40, :res41, :res42
|
|
295
324
|
|
|
296
325
|
sequencer(clk.posedge,rst) do
|
|
297
|
-
hprint("[0\n")
|
|
326
|
+
# hprint("[0\n")
|
|
298
327
|
res40 <= 0
|
|
299
328
|
res41 <= 0
|
|
300
329
|
res42 <= 0
|
|
@@ -302,54 +331,60 @@ system :my_seqencer do
|
|
|
302
331
|
res40 <= vals.sone?(_h5C)
|
|
303
332
|
res41 <= vals.sone? { |val| val == _h11 }
|
|
304
333
|
res42 <= vals2.sone? { |val| val == _h00 }
|
|
305
|
-
hprint("[1 res40=",res40," res41=",res41," res42=",res42,"\n")
|
|
334
|
+
# hprint("[1 res40=",res40," res41=",res41," res42=",res42,"\n")
|
|
306
335
|
end
|
|
307
336
|
|
|
308
337
|
[8].inner :res43
|
|
309
338
|
|
|
310
339
|
sequencer(clk.posedge,rst) do
|
|
311
|
-
hprint("_0\n")
|
|
340
|
+
# hprint("_0\n")
|
|
312
341
|
res43 <= 0
|
|
313
342
|
step
|
|
314
343
|
(4..10).sreverse_each { |val| res43 <= val }
|
|
315
|
-
hprint("_1 res43=",res43,"\n")
|
|
344
|
+
# hprint("_1 res43=",res43,"\n")
|
|
316
345
|
end
|
|
317
346
|
|
|
347
|
+
[8*10].inner :res44X, :res45X
|
|
318
348
|
[8*8].inner :res44, :res45
|
|
349
|
+
bit[8][-10].inner valsX: [ _h00, _h10, _hA5, _h0B, _hFE, _h34, _h5C, _h44, _h01, _h82 ]
|
|
319
350
|
|
|
320
351
|
sequencer(clk.posedge,rst) do
|
|
321
|
-
hprint("@0\n")
|
|
322
|
-
res44
|
|
323
|
-
res45
|
|
352
|
+
# hprint("@0\n")
|
|
353
|
+
res44 <= 0
|
|
354
|
+
res45 <= 0
|
|
355
|
+
res44X <= 0
|
|
356
|
+
res45X <= 0
|
|
324
357
|
step
|
|
325
|
-
res44
|
|
326
|
-
res45
|
|
327
|
-
|
|
358
|
+
res44 <= vals.ssort
|
|
359
|
+
res45 <= vals.ssort_by { |val| val.to_signed }
|
|
360
|
+
res44X <= valsX.ssort
|
|
361
|
+
res45X <= valsX.ssort_by { |val| val.to_signed }
|
|
362
|
+
# hprint("@1 res44=",res44," res45=",res45,"\n")
|
|
328
363
|
end
|
|
329
364
|
|
|
330
365
|
[8].inner :res46, :res47
|
|
331
366
|
|
|
332
367
|
sequencer(clk.posedge,rst) do
|
|
333
|
-
hprint("`0\n")
|
|
368
|
+
# hprint("`0\n")
|
|
334
369
|
res46 <= 0
|
|
335
370
|
res47 <= 0
|
|
336
371
|
step
|
|
337
372
|
res46 <= vals.ssum
|
|
338
373
|
res47 <= vals.ssum { |val| val & _h0F }
|
|
339
|
-
hprint("`1 res46=",res46," res47=",res47,"\n")
|
|
374
|
+
# hprint("`1 res46=",res46," res47=",res47,"\n")
|
|
340
375
|
end
|
|
341
376
|
|
|
342
377
|
[8*3].inner :res48
|
|
343
378
|
[8*8].inner :res49
|
|
344
379
|
|
|
345
380
|
sequencer(clk.posedge,rst) do
|
|
346
|
-
hprint("`0\n")
|
|
381
|
+
# hprint("`0\n")
|
|
347
382
|
res48 <= 0
|
|
348
383
|
res49 <= 0
|
|
349
384
|
step
|
|
350
385
|
res48 <= vals.stake(3)
|
|
351
386
|
res49 <= vals.stake_while { |val| val < _hAA }
|
|
352
|
-
hprint("`1 res48=",res48," res49=",res49,"\n")
|
|
387
|
+
# hprint("`1 res48=",res48," res49=",res49,"\n")
|
|
353
388
|
end
|
|
354
389
|
|
|
355
390
|
bit[8][-8].inner vals3: [ _hFE, _h10, _hA5, _h10, _hFE, _h34, _h5C, _h10 ]
|
|
@@ -357,13 +392,13 @@ system :my_seqencer do
|
|
|
357
392
|
[8*8].inner :res50,:res51
|
|
358
393
|
|
|
359
394
|
sequencer(clk.posedge,rst) do
|
|
360
|
-
hprint("
|
|
395
|
+
# hprint("~0\n")
|
|
361
396
|
res50 <= 0
|
|
362
397
|
res51 <= 0
|
|
363
398
|
step
|
|
364
399
|
res50 <= vals3.suniq
|
|
365
400
|
res51 <= vals.suniq { |val| val & _h0F }
|
|
366
|
-
hprint("
|
|
401
|
+
# hprint("~1 res50=",res50," res51=",res51,"\n")
|
|
367
402
|
end
|
|
368
403
|
|
|
369
404
|
[8*4*2].inner :res52
|
|
@@ -371,13 +406,22 @@ system :my_seqencer do
|
|
|
371
406
|
[3].inner :idx
|
|
372
407
|
|
|
373
408
|
sequencer(clk.posedge,rst) do
|
|
374
|
-
hprint("}0\n")
|
|
409
|
+
# hprint("}0\n")
|
|
375
410
|
res52 <= 0
|
|
376
411
|
idx <= 0
|
|
377
412
|
step
|
|
378
413
|
res52 <= vals.szip((1..6).to_a.map {|i| i.to_expr.as(bit[8]) })
|
|
379
414
|
vals.szip([_h12]*8) { |a,b| res53[idx] <= a+b; idx <= idx + 1 }
|
|
380
|
-
hprint("}1 res52=",res52," res53=",res53,"\n")
|
|
415
|
+
# hprint("}1 res52=",res52," res53=",res53,"\n")
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
[8].inner :res54,:res55
|
|
419
|
+
|
|
420
|
+
sequencer(clk.posedge,rst) do
|
|
421
|
+
res54 <= 0
|
|
422
|
+
res55 <= 0
|
|
423
|
+
vals.seach_nexts(6) { |i| res54 <= i }
|
|
424
|
+
res55 <= vals.seach_nexts(4).ssum
|
|
381
425
|
end
|
|
382
426
|
|
|
383
427
|
|
|
@@ -397,7 +441,7 @@ system :my_seqencer do
|
|
|
397
441
|
rst <= 0
|
|
398
442
|
!10.ns
|
|
399
443
|
clk <= 1
|
|
400
|
-
repeat(
|
|
444
|
+
repeat(500) do
|
|
401
445
|
!10.ns
|
|
402
446
|
clk <= ~clk
|
|
403
447
|
end
|
|
@@ -16,34 +16,34 @@ system :my_seqencer do
|
|
|
16
16
|
[8].inner :res0, :res1
|
|
17
17
|
|
|
18
18
|
sequencer(clk.posedge,rst) do
|
|
19
|
-
hprint("#0\n")
|
|
19
|
+
# hprint("#0\n")
|
|
20
20
|
res0 <= 0
|
|
21
21
|
res1 <= 0
|
|
22
22
|
res0 <= vals.ssum
|
|
23
23
|
res1 <= res0.ssum(_h00)
|
|
24
|
-
hprint("#1 res0=",res0," res1=",res1,"\n")
|
|
24
|
+
# hprint("#1 res0=",res0," res1=",res1,"\n")
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
[8].inner :res2, :res3
|
|
28
28
|
|
|
29
29
|
sequencer(clk.posedge,rst) do
|
|
30
|
-
hprint("$0\n")
|
|
30
|
+
# hprint("$0\n")
|
|
31
31
|
res2 <= 0
|
|
32
32
|
res3 <= 0
|
|
33
|
-
res2 <= (1..5).
|
|
33
|
+
res2 <= (1..5).ssum(_h00)
|
|
34
34
|
res3 <= (res3..res2).ssum
|
|
35
|
-
hprint("$1 res2=",res2," res3=",res3,"\n")
|
|
35
|
+
# hprint("$1 res2=",res2," res3=",res3,"\n")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
[8].inner :res4, :res5
|
|
39
39
|
|
|
40
40
|
sequencer(clk.posedge,rst) do
|
|
41
|
-
hprint("!0\n")
|
|
41
|
+
# hprint("!0\n")
|
|
42
42
|
res4 <= 0
|
|
43
43
|
res5 <= 0
|
|
44
44
|
res4 <= [_h01,_h02,_h03,_h04].ssum
|
|
45
|
-
res5 <= [1,2,3,4,5].ssum
|
|
46
|
-
hprint("!1 res4=",res4," res5=",res5,"\n")
|
|
45
|
+
res5 <= [1,2,3,4,5].ssum(_h00)
|
|
46
|
+
# hprint("!1 res4=",res4," res5=",res5,"\n")
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
bit[8][-8].inner mem: [ _h01, _h02, _h03, _h04, _h30, _h30, _h30, _h30 ]
|
|
@@ -52,17 +52,31 @@ system :my_seqencer do
|
|
|
52
52
|
|
|
53
53
|
data <= mem[addr]
|
|
54
54
|
|
|
55
|
-
mem_enum = senumerator(bit[8],8) do |i|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
mem_enum = senumerator(bit[8],8) do |i,val|
|
|
56
|
+
if val then
|
|
57
|
+
# Write
|
|
58
|
+
mem[i] <= val
|
|
59
|
+
step
|
|
60
|
+
val
|
|
61
|
+
else
|
|
62
|
+
# Read
|
|
63
|
+
addr <= i
|
|
64
|
+
step
|
|
65
|
+
data
|
|
66
|
+
end
|
|
59
67
|
end
|
|
60
68
|
|
|
61
69
|
sequencer(clk.posedge,rst) do
|
|
62
|
-
hprint("~0\n")
|
|
70
|
+
# hprint("~0\n")
|
|
63
71
|
res6 <= 0
|
|
64
72
|
res6 <= mem_enum.ssum
|
|
65
|
-
|
|
73
|
+
mem_enum.srewind
|
|
74
|
+
mem_enum.snext!(_hAA)
|
|
75
|
+
mem_enum.snext!(_hBB)
|
|
76
|
+
mem_enum.srewind
|
|
77
|
+
res6 <= mem_enum.snext
|
|
78
|
+
res6 <= mem_enum.snext
|
|
79
|
+
# hprint("~1 res6=",res6,"\n")
|
|
66
80
|
end
|
|
67
81
|
|
|
68
82
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'std/sequencer_func.rb'
|
|
2
|
+
|
|
3
|
+
include HDLRuby::High::Std
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# A factorial with default stack depth.
|
|
7
|
+
sdef(:fact) do |n|
|
|
8
|
+
hprint("n=",n,"\n")
|
|
9
|
+
sif(n > 1) { sreturn(n*fact(n-1,20)) } #Recurse setting the stack depth to 20
|
|
10
|
+
selse { sreturn(1) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# A factiorial with very low stack depth for checking overflow.
|
|
14
|
+
sdef(:fact_over,2,proc { stack_overflow_error <= 1 }) do |n|
|
|
15
|
+
hprint("n2=",n,"\n")
|
|
16
|
+
sif(n > 1) { sreturn(n*fact_over(n-1)) }
|
|
17
|
+
selse { sreturn(1) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Checking the usage of sequencers functions.
|
|
21
|
+
system :my_seqencer do
|
|
22
|
+
|
|
23
|
+
inner :clk,:rst
|
|
24
|
+
|
|
25
|
+
[16].inner :val
|
|
26
|
+
[16].inner :res
|
|
27
|
+
|
|
28
|
+
inner stack_overflow_error: 0
|
|
29
|
+
|
|
30
|
+
sequencer(clk.posedge,rst) do
|
|
31
|
+
5.stimes do |i|
|
|
32
|
+
val <= i
|
|
33
|
+
res <= fact(val)
|
|
34
|
+
end
|
|
35
|
+
hprint("Going to overflow...\n")
|
|
36
|
+
4.stimes do |i|
|
|
37
|
+
val <= i
|
|
38
|
+
res <= fact_over(val)
|
|
39
|
+
end
|
|
40
|
+
hprint("stack_overflow_error=",stack_overflow_error,"\n")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
timed do
|
|
44
|
+
clk <= 0
|
|
45
|
+
rst <= 0
|
|
46
|
+
!10.ns
|
|
47
|
+
clk <= 1
|
|
48
|
+
!10.ns
|
|
49
|
+
clk <= 0
|
|
50
|
+
rst <= 1
|
|
51
|
+
!10.ns
|
|
52
|
+
clk <= 1
|
|
53
|
+
!10.ns
|
|
54
|
+
clk <= 0
|
|
55
|
+
rst <= 0
|
|
56
|
+
!10.ns
|
|
57
|
+
clk <= 1
|
|
58
|
+
repeat(500) do
|
|
59
|
+
!10.ns
|
|
60
|
+
clk <= ~clk
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|