HDLRuby 3.7.8 → 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.
- checksums.yaml +4 -4
- data/README.md +140 -3
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +366 -0
- data/lib/HDLRuby/std/hruby_enum.rb +924 -0
- data/lib/HDLRuby/std/sequencer.rb +1 -1
- data/lib/HDLRuby/std/sequencer_sw.rb +305 -4
- data/lib/HDLRuby/std/std.rb +1 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cd33c7551f3da873475ca05e7047b40cd83abf4016e97fcdcbf266dca32b9b2
|
4
|
+
data.tar.gz: 4bce7700302da9f025b7bea65102973375746d6f767013a0b4db9259b7aea464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9914adec792666008ce4a122d9014ede48b27c7c649c26b969d9eddf34e08a742382feda2925991522f0a9d632763d3d65df444ac48ad3ac5927bc0f44750ed7
|
7
|
+
data.tar.gz: 297426eacd2fe788c6fb2f7ea239106a3c4eab1ea48e1506f36058ec259479e49a9c2d7aa746b090fe16f147e46568c6cb101b8351bb70ec3b226ccdbf965069
|
data/README.md
CHANGED
@@ -17,6 +17,12 @@ hdrcc --get-tuto
|
|
17
17
|
|
18
18
|
__What's new_
|
19
19
|
|
20
|
+
For HDLRuby version 3.7.9:
|
21
|
+
|
22
|
+
* Added Python code generation from the software sequencers.
|
23
|
+
|
24
|
+
* Added [parallel enumerators](#parallel-enumerators-stdhruby_enumrb).
|
25
|
+
|
20
26
|
For HDLRuby versions 3.7.7/3.7.8:
|
21
27
|
|
22
28
|
* Various fixes regqrding the software sequencers.
|
@@ -3256,6 +3262,125 @@ fsm(clk.posedge,rst,:static)
|
|
3256
3262
|
end
|
3257
3263
|
```
|
3258
3264
|
|
3265
|
+
|
3266
|
+
## Parallel Enumerators:: `std/hruby_enum.rb`
|
3267
|
+
<a name="enumertor"></a>
|
3268
|
+
|
3269
|
+
HDLRuby parallel enumerators are objects for generating hardware processing series of signals in parallel. They are created using the method `heach` on parallel enumerable objects.
|
3270
|
+
|
3271
|
+
Parallel enumerable objects include, arrays of signals and ranges.
|
3272
|
+
A parallel enumerable object can also be generated from an integer values using one of the following method:
|
3273
|
+
|
3274
|
+
|
3275
|
+
- `<integer>.htimes`: is equivalent to the range `0..<integer-1>`.
|
3276
|
+
|
3277
|
+
- `<integer>.supto(<last>)`: is equivalent to the range `<integer>..<last>`.
|
3278
|
+
|
3279
|
+
- `<integer>.sdownto(<last>)`: is equivalent to the range `<last>..<integer>`.
|
3280
|
+
|
3281
|
+
The parallel enumerators can be controlled using the following methods:
|
3282
|
+
|
3283
|
+
- `hsize`: returns the number of elements the enumerator can access.
|
3284
|
+
|
3285
|
+
- `htype`: returns the type of the elements accessed by the enumerator.
|
3286
|
+
|
3287
|
+
- `heach`: returns the current enumerator. If a block is given, it performs the iteration instead of returning an enumerator.
|
3288
|
+
|
3289
|
+
- `heach_with_index`: returns an enumerator over the elements of the current enumerator associated with their index position. If a block is given, it performs the iteration instead of returning an enumerator.
|
3290
|
+
|
3291
|
+
- `heach_with_object(<obj>)`: returns an enumerator over the elements of the current enumerator associated with object `obj` (any object, HDLRuby or not, can be used). If a block is given, it performs the iteration instead of returning an enumerator.
|
3292
|
+
|
3293
|
+
- `with_index`: identical to `seach_with_index`.
|
3294
|
+
|
3295
|
+
- `with_object(<obj>)`: identical to `seach_with_object`.
|
3296
|
+
|
3297
|
+
- `clone`: create a new enumerator on the same elements.
|
3298
|
+
|
3299
|
+
- `+`: concatenation of enumerators.
|
3300
|
+
|
3301
|
+
|
3302
|
+
With this basis, several algorithms have been implemented using enumerators and are usable for all the enumerable objects inside and outside proceses. All these algorithms are HW implantation of the Ruby Enumerable methods. They are accessible using the corresponding ruby method prefixed by character `h`. For example, the HW implementation of the ruby `all?` method is generated by the `hall?` method. In details:
|
3303
|
+
|
3304
|
+
- `hall?`: HW implementation of the Ruby `all?` method. Returns a single-bit signal. When 0 this value means false and when 1 it means true.
|
3305
|
+
|
3306
|
+
- `hany?`: HW implementation of the Ruby `any?` method. Returns a single-bit signal. When 0 this value means false and when 1 it means true.
|
3307
|
+
|
3308
|
+
- `hchain`: HW implementation of the Ruby `chain`.
|
3309
|
+
|
3310
|
+
- `hmap`: HW implementation of the Ruby `map` method. When used with a block returns a vector signal containing each computation result.
|
3311
|
+
|
3312
|
+
<!-- - `hcompact`: HW implementation of the Ruby `compact` method. However, since there is no nil value in HW, use 0 instead for compacting. Returns a vector signal containing the compaction result. -->
|
3313
|
+
|
3314
|
+
- `hcount`: HW implementation of the Ruby `count` method. Returns a signal whose bit width matches the size of the enumerator containing the count result.
|
3315
|
+
|
3316
|
+
<!-- - `hcycle`: HW implementation of the Ruby `cycle` method. -->
|
3317
|
+
|
3318
|
+
- `hfind`: HW implementation of the Ruby `find` method. Returns a signal containing the found element, or 0 if not found.
|
3319
|
+
|
3320
|
+
- `hdrop`: HW implementation of the Ruby `drop` method. Returns a vector signal containing the remaining elements.
|
3321
|
+
|
3322
|
+
<!-- - `hdrop_while`: HW implementation of the Ruby `drop_while` method. Returns a vector signal containing the remaining elements. -->
|
3323
|
+
|
3324
|
+
- `heach_cons`: HW implementation of the Ruby `each_cons` method.
|
3325
|
+
|
3326
|
+
- `heach_slice`: HW implementation of the Ruby `each_slice` method.
|
3327
|
+
|
3328
|
+
- `heach_with_index`: HW implementation of the Ruby `each_with_index` method.
|
3329
|
+
|
3330
|
+
- `heach_with_object`: HW implementation of the Ruby `each_with_object` method.
|
3331
|
+
|
3332
|
+
- `hto_a`: HW implementation of the Ruby `to_a` method. Returns a vector signal containing all the elements of the enumerator.
|
3333
|
+
|
3334
|
+
<!-- - `hselect`: HW implementation of the Ruby `select` method. Returns a vector signal containing the selected elements. -->
|
3335
|
+
|
3336
|
+
- `hfind_index`: HW implementation of the Ruby `find_index` method. Returns the index of the found element or -1 if not.
|
3337
|
+
|
3338
|
+
- `hfirst`: HW implementation of the Ruby `first` method. Returns a vector signal containing the first elements.
|
3339
|
+
|
3340
|
+
- `hinclude?`: HW implementation of the Ruby `include?` method. Returns a single-bit signal. When 0 this value means false and when 1 it means true.
|
3341
|
+
|
3342
|
+
- `hinject`: HW implementation of the Ruby `inject` method. Return a signal of the type of elements containing the computation result.
|
3343
|
+
|
3344
|
+
- `hmax`: HW implementation of the Ruby `max` method. Return a vector signal containing the found max values.
|
3345
|
+
*Note:* For now only one max value can be returned.
|
3346
|
+
|
3347
|
+
- `hmax_by`: HW implementation of the Ruby `max_by` method. Return a vector signal containing the found max values.
|
3348
|
+
*Note:* For now only one max value can be returned.
|
3349
|
+
|
3350
|
+
- `hmin`: HW implementation of the Ruby `min` method. Return a vector signal containing the found min values.
|
3351
|
+
*Note:* For now only one min value can be returned.
|
3352
|
+
|
3353
|
+
- `hmin_by`: HW implementation of the Ruby `min_by` method. Return a vector signal containing the found min values.
|
3354
|
+
*Note:* For now only one min value can be returned.
|
3355
|
+
|
3356
|
+
- `hminmax`: HW implementation of the Ruby `minmax` method. Returns a 2-element vector signal containing the resulting min and max values.
|
3357
|
+
|
3358
|
+
- `hminmax_by`: HW implementation of the Ruby `minmax_by` method. Returns a 2-element vector signal containing the resulting min and max values.
|
3359
|
+
|
3360
|
+
- `hnone?`: HW implementation of the Ruby `none?` method. Returns a single-bit signal. When 0 this value means false and when 1 it means true.
|
3361
|
+
|
3362
|
+
- `hone?`: HW implementation of the Ruby `one?` method. Returns a single-bit signal. When 0 this value means false and when 1 it means true.
|
3363
|
+
|
3364
|
+
<!-- - `hreject`: HW implementation of the Ruby `reject` method. Returns a vector signal containing the remaining elements. -->
|
3365
|
+
|
3366
|
+
- `hreverse_each`: HW implementation of the Ruby `reverse_each` method.
|
3367
|
+
*Note:* This algorithm makes sense inside a `seq` process.
|
3368
|
+
|
3369
|
+
- `hsort`: HW implementation of the Ruby `sort` method. Returns a vector signal containing the sorted elements.
|
3370
|
+
*Note:* If you use a custom comparison (passed as a Ruby block) and the number of elements to sort is not a power of 2, you need to provide as argument the maximum possible value (or minimum in case of decreasing order).
|
3371
|
+
|
3372
|
+
- `hsort_by`: HW implementation of the Ruby `sort_by` method. Returns a vector signal containing the sorted elements.
|
3373
|
+
*Note:* If the number of elements to sort is not a power of 2, you need to provide as argument the maximum possible value (or minimum in case of decreasing order).
|
3374
|
+
|
3375
|
+
- `hsum`: HW implementation of the Ruby `sum` method. Returns a signal with the type of elements containing the sum result.
|
3376
|
+
|
3377
|
+
- `htake`: HW implementation of the Ruby `take` method. Returns a vector signal containing the taken elements.
|
3378
|
+
|
3379
|
+
<!-- - `htake_while`: HW implementation of the Ruby `take_while` method. Returns a vector signal containing the taken elements. -->
|
3380
|
+
|
3381
|
+
<!-- - `huniq`: HW implementation the Ruby `uniq` method. Returns a vector signal containing the selected elements. -->
|
3382
|
+
|
3383
|
+
|
3259
3384
|
## Sequencer (software-like hardware coding):: `std/sequencer.rb`
|
3260
3385
|
<a name="sequencer"></a>
|
3261
3386
|
|
@@ -3394,9 +3519,9 @@ end
|
|
3394
3519
|
```
|
3395
3520
|
|
3396
3521
|
|
3397
|
-
### HDLRuby enumerators and enumerable objects: `std/sequencer.rb`
|
3522
|
+
### HDLRuby sequential enumerators and enumerable objects: `std/sequencer.rb`
|
3398
3523
|
|
3399
|
-
HDLRuby enumerators are objects for generating iterations within sequencers. They are created using the method `seach` on enumerable objects as presented in the previous section.
|
3524
|
+
HDLRuby sequential enumerators are objects for generating iterations within sequencers. They are created using the method `seach` on enumerable objects as presented in the previous section.
|
3400
3525
|
|
3401
3526
|
The enumerators can be controlled using the following methods:
|
3402
3527
|
|
@@ -3850,6 +3975,18 @@ File.open("sequencer_in_ruby.rb","w") do |f|
|
|
3850
3975
|
end
|
3851
3976
|
```
|
3852
3977
|
|
3978
|
+
It is also possible to generate C or Python code from the sequencer using the `to_c` and `to_python` methods, respectively. For example, the commands below generate a C file and a Python file from `my_seq`. However, the synchronization commands are not yet supported.
|
3979
|
+
|
3980
|
+
```ruby
|
3981
|
+
File.open("seqiemcer_in_c.c","w" do |f|
|
3982
|
+
f << my_seq.to_c
|
3983
|
+
end
|
3984
|
+
|
3985
|
+
File.open("seqiemcer_in_python.py","w" do |f|
|
3986
|
+
f << my_seq.to_python
|
3987
|
+
end
|
3988
|
+
```
|
3989
|
+
|
3853
3990
|
__Note__: the ruby code for sequencers is compatible with mruby for execution on embedded systems.
|
3854
3991
|
|
3855
3992
|
|
@@ -3990,7 +4127,7 @@ end.()
|
|
3990
4127
|
|
3991
4128
|
Both method are functionally equivalent. However, the first is safer as potential errors are detected at the compile stage, but is incompatible with separated code generation and is slow, while the second allows separate code generation, if fast, but is less safe since it is only at the execution stage that the code is checked.
|
3992
4129
|
|
3993
|
-
__Note__: Since the string in text is grafted as is into the generated Ruby (or C) code, you cannot directly access the value of a signal. However, you can use to_ruby or
|
4130
|
+
__Note__: Since the string in text is grafted as is into the generated Ruby (or C) code, you cannot directly access the value of a signal. However, you can use to_ruby, to_c or to_python to access the underlying raw value, or use value_text to retrieve the value with proper type adjustment in case of overflow or underflow. For example, the following will display the raw value of signal sig0 and the hardware-accurate value of signal sig1:
|
3994
4131
|
|
3995
4132
|
```ruby
|
3996
4133
|
sequencer do
|
@@ -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
|