HDLRuby 3.7.7 → 3.7.9

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.
@@ -42,6 +42,28 @@ system :comparison_bench do
42
42
  sgeL <= (uL >= vL)
43
43
  end
44
44
 
45
+ [8].inner :xND
46
+ [96].inner :yND
47
+ signed[8].inner :uND
48
+ signed[128].inner :vND
49
+ inner :ueND, :ultND, :uleND, :ugtND, :ugeND
50
+ inner :seND, :sltND, :sleND, :sgtND, :sgeND
51
+
52
+ par do
53
+ ueND <= (xND == yND)
54
+ ultND <= (xND < yND)
55
+ uleND <= (xND <= yND)
56
+ ugtND <= (xND > yND)
57
+ ugeND <= (xND >= yND)
58
+
59
+ seND <= (uND == vND)
60
+ sltND <= (uND < vND)
61
+ sleND <= (uND <= vND)
62
+ sgtND <= (uND > vND)
63
+ sgeND <= (uND >= vND)
64
+ end
65
+
66
+
45
67
  timed do
46
68
  x <= 0
47
69
  y <= 0
@@ -51,26 +73,38 @@ system :comparison_bench do
51
73
  yL <= 0
52
74
  uL <= 0
53
75
  vL <= 0
76
+ xND <= 0
77
+ yND <= 0
78
+ uND <= 0
79
+ vND <= 0
54
80
  !10.ns
55
81
  x <= 1
56
82
  u <= 1
57
83
  xL <= 2**80 - 1
58
84
  uL <= 2**80 - 1
85
+ xND <= 1
86
+ uND <= 1
59
87
  !10.ns
60
88
  y <= 2
61
89
  v <= 2
62
90
  yL <= 2**81 - 1
63
91
  vL <= 2**81 - 1
92
+ yND <= 2
93
+ vND <= 2
64
94
  !10.ns
65
95
  x <= 3
66
96
  u <= 3
67
97
  xL <= 2**81 + 2**80 - 1
68
98
  uL <= 2**81 + 2**80 - 1
99
+ xND <= 3
100
+ uND <= 3
69
101
  !10.ns
70
102
  x <= 2
71
103
  u <= -2
72
104
  xL <= 2**81 - 1
73
105
  uL <= -2**81 + 1
106
+ xND <= 2
107
+ uND <= -2
74
108
  !10.ns
75
109
  end
76
110
  end
@@ -0,0 +1,366 @@
1
+ require 'std/sequencer.rb'
2
+
3
+ include HDLRuby::High::Std
4
+
5
+ # Checking the usage of hardware enumerable capabilities.
6
+ # - The first check is for hall?
7
+ # - The second check is for hany?
8
+ # - The third check is for hchain
9
+ # - The forth check is for hmap
10
+ # - The fifth check is for hmap with with_index
11
+ # - The sixth check is for hcompact
12
+ # - The seventh checks is for hcount
13
+ # - The eighth check is for hcycle
14
+ # - The nineth check is for hfind
15
+ # - The tenth check is for hdrop and hdrop_while
16
+ # - The eleventh check is for heach_cons
17
+ # - The twelveth check is for heach_slice
18
+ # - The thirteenth check is for hto_a
19
+ # - The forteenth check is for hselect
20
+ # - The fifteenth check is for hfind_index
21
+ # - The sixteenth check is for hfirst
22
+ # - The seventeenth check is for hinject
23
+ # - The eighteenth check is for hmax
24
+ # - The nineteenth check is for hmax_by
25
+ # - The twentieth check is for hmax_by
26
+ # - The twenty firth check is for hmin
27
+ # - The twenty second check is for hmin_by
28
+ # - The twenty third check is for hminmax and hminmax_by
29
+ # - The twenty fourth check is for hnone?
30
+ # - The twenty fifth check is for hone?
31
+ # - The twenty sixth check is for hreverse_each
32
+ # - The twenty seventh check is for hsort and hsort_by
33
+ # - The twenty eighth check is for hsum
34
+ # - The twenty nineth check is for htake and htake_while
35
+ # - The thirtieth check is for suniq
36
+ # - The thirty first check is for hzip
37
+ #
38
+
39
+ system :henmerable_checks do
40
+
41
+ inner :clk,:rst
42
+
43
+ bit[8][-8].inner vals: [ _h00, _h10, _hA5, _h0B, _hFE, _h34, _h5C, _h44 ]
44
+ rvals = 8.times.to_a.reverse
45
+
46
+ [16].inner :res0, :res1, :res2, :res3
47
+
48
+ res0 <= vals.hall? { |val| val != _h11 }
49
+ res1 <= vals.hall? { |val| val != _h5C }
50
+
51
+ par(clk.posedge) do
52
+ # hprint("#0\n")
53
+ res2 <= rvals.hall? { |val| val.to_expr != 11 }
54
+ res3 <= rvals.hall? { |val| val.to_expr != 4 }
55
+ # hprint("#1 res0=",res0," res1=",res1," res2=",res2," res3=",res3,"\n")
56
+ end
57
+
58
+ [16].inner :res4, :res5, :res6, :res7
59
+
60
+ res4 <= vals.hany? { |val| val == _h11 }
61
+ res5 <= vals.hany? { |val| val == _h5C }
62
+
63
+ par(clk.posedge) do
64
+ # hprint("$0\n")
65
+ res6 <= rvals.hany? { |val| val == 11 }
66
+ res7 <= rvals.hany? { |val| val == 4 }
67
+ # hprint("#1 res4=",res4," res5=",res5," res6=",res6," res7=",res7,"\n")
68
+ end
69
+
70
+ [16].inner :res8, :res9, :res10, :res11
71
+
72
+ res8 <= vals.hchain(0..10).hany? { |val| val.as(bit[8]) == _h11 }
73
+ res9 <= vals.hchain(0..10).hany? { |val| val.as(bit[8]) == _h05 }
74
+
75
+ par(clk.posedge) do
76
+ # hprint("!0\n")
77
+ res10 <= rvals.hchain(vals).hany? { |val| val.as(bit[8]) == _h11 }
78
+ res11 <= rvals.hchain(vals).hany? { |val| val.as(bit[8]) == _h04 }
79
+ end
80
+
81
+ bit[8][-8].inner :res12, :res13
82
+
83
+ res12 <= vals.hmap { |val| val + 1 }
84
+
85
+ par(clk.posedge) do
86
+ # hprint("%0\n");
87
+ res13 <= vals.hmap { |val| val + 1 }
88
+ end
89
+
90
+ bit[8][-8].inner :res14, :res15
91
+
92
+ res14 <= vals.hmap.with_index { |val,i| val + i }
93
+
94
+ par(clk.posedge) do
95
+ # hprint("&0\n");
96
+ res15 <= vals.hmap.with_index { |val,i| val + i }
97
+ end
98
+
99
+ bit[8][-8].inner vals2: [ _h00, _h10, _h00, _h0B, _hFE, _h00, _h5C, _h00 ]
100
+ # bit[8][-8].inner :res16, :res17
101
+
102
+ # res16 <= vals2.hcompact
103
+
104
+ # sequencer(clk.posedge,rst) do
105
+ # # hprint("|0\n");
106
+ # res17 <= vals2.hcompact
107
+ # end
108
+
109
+ [8].inner :res18, :res19, :res20
110
+
111
+ res18 <= vals2.hcount
112
+ res19 <= vals2.hcount(_h00)
113
+
114
+ par(clk.posedge) do
115
+ # hprint("(0\n");
116
+ res20 <= vals2.hcount {|elem| elem > _h10 }
117
+ end
118
+
119
+ # [8].inner :res21, :res22
120
+
121
+ # vals.hcycle(2) { |elem| res21 <= elem }
122
+
123
+ # par(clk.posedge) do
124
+ # # hprint(")0\n")
125
+ # vals2.hcycle { |elem| res22 <= elem }
126
+ # end
127
+
128
+ [8].inner :res23, :res24
129
+
130
+ res23 <= vals.hfind(proc {-1}) { |elem| elem > _h00 }
131
+
132
+ par(clk.posedge) do
133
+ # hprint("=0\n")
134
+ res24 <= vals.hfind(proc {-1}) { |elem| elem == _hAA }
135
+ end
136
+
137
+ bit[8][-8].inner :res25 #, :res26
138
+
139
+ res25 <= vals.hdrop(3)
140
+
141
+ # par(clk.posedge) do
142
+ # # hprint("+0\n")
143
+ # res26 <= vals.hdrop_while { |elem| elem < _hAA }
144
+ # end
145
+
146
+ bit[8][-8].inner :res27
147
+
148
+ par(clk.posedge) do
149
+ # hprint("*0\n")
150
+ vals.heach_cons(3).with_index { |(a,b,c),i| res27[i] <= a+b+c }
151
+ end
152
+
153
+ bit[8][-8].inner :res28
154
+
155
+ par(clk.posedge) do
156
+ # hprint("/0\n")
157
+ vals.heach_slice(3).with_index do |(a,b,c),i|
158
+ if c then
159
+ res28[i] <= a+b+c
160
+ elsif b then
161
+ res28[i] <= a+b
162
+ else
163
+ res28[i] <= a
164
+ end
165
+ end
166
+ end
167
+
168
+ bit[32][-4].inner :res29
169
+
170
+ par(clk.posedge) do
171
+ # hprint("~0\n")
172
+ res29 <= (_h00000001.._h00000004).heach.hto_a
173
+ end
174
+
175
+ [8].inner :res30, :res31, :res31x
176
+
177
+ res30 <= vals.hfind_index(_h0B)
178
+
179
+ par(clk.posedge) do
180
+ # hprint(">0\n")
181
+ res31 <= vals.hfind_index { |elem| elem < _hAA }
182
+ res31x <= vals.hfind_index { |elem| elem == _hAA }
183
+ end
184
+
185
+ bit[8][-4].inner :res32
186
+
187
+ par(clk.posedge) do
188
+ # hprint("<0\n")
189
+ res32 <= vals.hfirst(4)
190
+ end
191
+
192
+ inner :res33, :res34
193
+
194
+ res33 <= vals.hinclude?(_h0B)
195
+
196
+ par(clk.posedge) do
197
+ # hprint("!0\n")
198
+ res34 <= vals.hinclude?(_hAA)
199
+ end
200
+
201
+ [8].inner :res35, :res36
202
+
203
+ res35 <= vals.hinject(_h01) { |a,b| a+b }
204
+
205
+ par(clk.posedge) do
206
+ # hprint(":0\n")
207
+ res36 <= vals.hinject(:+)
208
+ end
209
+
210
+ [8].inner :res37
211
+ bit[8][-3].inner :res38
212
+
213
+ res37 <= vals.hmax
214
+
215
+ par(clk.posedge) do
216
+ # hprint(";0\n")
217
+ # res38 <= vals.hmax(3)
218
+ res38 <= vals.hmax(1)
219
+ end
220
+
221
+ [8].inner :res39
222
+ # bit[8][-3].inner :res40
223
+ [8].inner :res40
224
+
225
+ res39 <= vals.hmax_by {|e| e.to_signed }
226
+
227
+ par(clk.posedge) do
228
+ # hprint(",0\n")
229
+ # res40 <= vals.hmax_by(3) {|e| e.to_signed }
230
+ res40 <= vals.hmax_by(1) {|e| e.to_signed }
231
+ end
232
+
233
+ [8].inner :res41
234
+ bit[8][-3].inner :res42
235
+
236
+ res41 <= vals.hmin
237
+
238
+ par(clk.posedge) do
239
+ # hprint(".0\n")
240
+ # res42 <= vals.hmin(3)
241
+ res42 <= vals.hmin(1)
242
+ end
243
+
244
+ [8].inner :res43
245
+ bit[8][-3].inner :res44
246
+
247
+ res43 <= vals.hmin_by {|e| e.to_signed }
248
+
249
+ par(clk.posedge) do
250
+ # hprint(":0\n")
251
+ # res44 <= vals.hmin_by(3) {|e| e.to_signed }
252
+ res44 <= vals.hmin_by(1) {|e| e.to_signed }
253
+ end
254
+
255
+ [16].inner :res45, :res46
256
+
257
+ res45 <= vals.hminmax
258
+
259
+ par(clk.posedge) do
260
+ # hprint("]0\n")
261
+ res46 <= vals.hminmax_by {|e| e.to_signed }
262
+ end
263
+
264
+ [8].inner :res47, :res48
265
+
266
+ res47 <= vals.hnone? { |val| val == _h11 }
267
+
268
+ par(clk.posedge) do
269
+ # hprint("[0\n")
270
+ res48 <= vals.hnone?(_h5C)
271
+ end
272
+
273
+ [8].inner :res49, :res50, :res51
274
+
275
+ res49 <= vals.hone?(_h5C)
276
+
277
+ par(clk.posedge) do
278
+ # hprint("[0\n")
279
+ res50 <= vals.hone? { |val| val == _h11 }
280
+ res51 <= vals2.hone? { |val| val == _h00 }
281
+ end
282
+
283
+ bit[8][-6].inner :res52
284
+
285
+ par(clk.posedge) do
286
+ # hprint("_0\n")
287
+ (5..10).hreverse_each.with_index { |val,i| res52[i] <= val }
288
+ end
289
+
290
+ bit[8][-10].inner :res53X, :res54X
291
+ bit[8][-8].inner :res53, :res54
292
+ bit[8][-10].inner valsX: [ _h00, _h10, _hA5, _h0B, _hFE, _h34, _h5C, _h44, _h01, _h82 ]
293
+
294
+ res53 <= vals.hsort
295
+ res54 <= vals.hsort_by { |val| val.to_signed }
296
+
297
+ seq(clk.posedge) do
298
+ # hprint("@0\n")
299
+ res53X <= valsX.hsort
300
+ res54X <= valsX.hsort_by(_h7F) { |val| val.to_signed }
301
+ end
302
+
303
+ [8].inner :res55, :res56
304
+
305
+ res55 <= vals.hsum
306
+
307
+ par(clk.posedge) do
308
+ # hprint("`0\n")
309
+ res56 <= vals.hsum { |val| val & _h0F }
310
+ end
311
+
312
+ bit[8][-3].inner :res57
313
+ # bit[8][-8].inner :res58
314
+
315
+ res57 <= vals.htake(3)
316
+
317
+ # par(clk.posedge) do
318
+ # # hprint("`0\n")
319
+ # res58 <= vals.htake_while { |val| val < _hAA }
320
+ # end
321
+
322
+ bit[8][-8].inner vals3: [ _hFE, _h10, _hA5, _h10, _hFE, _h34, _h5C, _h10 ]
323
+
324
+ # bit[8][-8].inner :res59,:res60
325
+
326
+ # res59 <= vals3.huniq
327
+
328
+ # par(clk.posedge) do
329
+ # # hprint("~0\n")
330
+ # res60 <= vals.huniq { |val| val & _h0F }
331
+ # end
332
+
333
+ bit[8][-8].inner :res61
334
+ bit[8][-8].inner :res62
335
+
336
+ res61 <= vals.hzip((1..6).to_a.map {|i| i.to_expr.as(bit[8]) })
337
+
338
+ par(clk.posedge) do
339
+ # hprint("}0\n")
340
+ vals.hzip([_h12]*8).each_with_index { |(a,b),i| res62[i] <= a+b }
341
+ end
342
+
343
+
344
+
345
+
346
+ timed do
347
+ clk <= 0
348
+ rst <= 0
349
+ !10.ns
350
+ clk <= 1
351
+ !10.ns
352
+ clk <= 0
353
+ rst <= 1
354
+ !10.ns
355
+ clk <= 1
356
+ !10.ns
357
+ clk <= 0
358
+ rst <= 0
359
+ !10.ns
360
+ clk <= 1
361
+ repeat(500) do
362
+ !10.ns
363
+ clk <= ~clk
364
+ end
365
+ end
366
+ end