HDLRuby 2.3.3 → 2.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +9 -0
- data/lib/HDLRuby/hdr_samples/with_linear.rb +3 -15
- data/lib/HDLRuby/hruby_high.rb +6 -3
- data/lib/HDLRuby/hruby_low.rb +93 -0
- data/lib/HDLRuby/hruby_low2c.rb +3 -1
- data/lib/HDLRuby/hruby_low_mutable.rb +90 -2
- data/lib/HDLRuby/hruby_low_without_connection.rb +13 -0
- data/lib/HDLRuby/hruby_tools.rb +2 -2
- data/lib/HDLRuby/sim/hruby_sim.h +6 -2
- data/lib/HDLRuby/sim/hruby_sim_calc.c +25 -12
- data/lib/HDLRuby/sim/hruby_sim_core.c +10 -4
- data/lib/HDLRuby/std/channel.rb +311 -63
- data/lib/HDLRuby/std/linear.rb +16 -8
- data/lib/HDLRuby/std/memory.rb +1 -1
- data/lib/HDLRuby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164191b6cbfda40e60bc6b253c95a0ff511164007c83adf53c7f86383b404464
|
4
|
+
data.tar.gz: 5344dd9f624089cab1488d9e10b67e542cb83639db81e397c0d2241c67a43527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e9b00b3fad458789078bcaca6d8d45e7ac5877ff14a3971ce2ddac186ed15a1ad2aa440d3c5619c66f324e9f6dbeda5c8bcf2aa5de3389aa12d631abbd780a4
|
7
|
+
data.tar.gz: '08dc450e1e3807d85f8ffb22888c037b081bed44dab318fac5fb33611f706c58191a2b06379b0798b61bbf3578d0e058b144ee8995e4212250826366bd306e9e'
|
@@ -9,6 +9,8 @@ system :fix_test do
|
|
9
9
|
|
10
10
|
# Declare three 4-bit integer part 4-bit fractional part
|
11
11
|
bit[3..0,3..0].inner :x,:y,:z
|
12
|
+
# Declare three 8-bit integer part 8-bit fractional part
|
13
|
+
signed[3..0,3..0].inner :a,:b,:c,:d
|
12
14
|
|
13
15
|
# Performs calculation between then
|
14
16
|
timed do
|
@@ -22,5 +24,12 @@ system :fix_test do
|
|
22
24
|
!10.ns
|
23
25
|
z <= z / x
|
24
26
|
!10.ns
|
27
|
+
a <= _00010000
|
28
|
+
b <= _00001111
|
29
|
+
!10.ns
|
30
|
+
c <= a * b
|
31
|
+
d <= 0
|
32
|
+
!10.ns
|
33
|
+
d <= d + c
|
25
34
|
end
|
26
35
|
end
|
@@ -22,9 +22,6 @@ system :testmat do
|
|
22
22
|
mem_dual([8],256,clk,rst, rinc: :rst,winc: :rst).(:memL1)
|
23
23
|
mem_dual([8],256,clk,rst, rinc: :rst,winc: :rst).(:memR)
|
24
24
|
# Access ports.
|
25
|
-
# # memL0.branch(:rinc).inner :readL0
|
26
|
-
# # memL1.branch(:rinc).inner :readL1
|
27
|
-
# # memR.branch(:rinc).inner :readR
|
28
25
|
# memL0.branch(:rinc).input :readL0
|
29
26
|
# memL1.branch(:rinc).input :readL1
|
30
27
|
# memR.branch(:rinc).input :readR
|
@@ -35,9 +32,9 @@ system :testmat do
|
|
35
32
|
|
36
33
|
# Accumulators memory.
|
37
34
|
mem_file([8],2,clk,rst,rinc: :rst).(:memAcc)
|
38
|
-
#
|
39
|
-
|
40
|
-
accs_out = [
|
35
|
+
# memAcc.branch(:anum).inout :accs
|
36
|
+
# accs_out = [accs.wrap(0), accs.wrap(1)]
|
37
|
+
accs_out = [memAcc.branch(:anum).wrap(0), memAcc.branch(:anum).wrap(1)]
|
41
38
|
|
42
39
|
# Layer 0 ack.
|
43
40
|
inner :ack0
|
@@ -52,8 +49,6 @@ system :testmat do
|
|
52
49
|
# Tarnslation result
|
53
50
|
mem_file([8],2,clk,rst,rinc: :rst).(:memF)
|
54
51
|
# Access ports.
|
55
|
-
# # memT.branch(:anum).inner :readT
|
56
|
-
# # memF.branch(:anum).inner :writeF
|
57
52
|
memT.branch(:anum).input :readT
|
58
53
|
memF.branch(:anum).output :writeF
|
59
54
|
regRs = [ readT.wrap(0), readT.wrap(1) ]
|
@@ -72,8 +67,6 @@ system :testmat do
|
|
72
67
|
# Input memories.
|
73
68
|
mem_dual([8],2,clk,rst, rinc: :rst,winc: :rst).(:mem2L0)
|
74
69
|
# Access ports.
|
75
|
-
# # mem2L0.branch(:rinc).inner :read2L0
|
76
|
-
# # memF.branch(:rinc).inner :readF
|
77
70
|
# mem2L0.branch(:rinc).input :read2L0
|
78
71
|
# memF.branch(:rinc).input :readF
|
79
72
|
|
@@ -93,11 +86,6 @@ system :testmat do
|
|
93
86
|
|
94
87
|
|
95
88
|
# The memory initializer.
|
96
|
-
# # memL0.branch(:winc).inner :writeL0
|
97
|
-
# # memL1.branch(:winc).inner :writeL1
|
98
|
-
# # memR.branch(:winc).inner :writeR
|
99
|
-
# # memT.branch(:winc).inner :writeT
|
100
|
-
# # mem2L0.branch(:winc).inner :write2L0
|
101
89
|
# memL0.branch(:winc).output :writeL0
|
102
90
|
# memL1.branch(:winc).output :writeL1
|
103
91
|
# memR.branch(:winc).output :writeR
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -1263,7 +1263,8 @@ module HDLRuby::High
|
|
1263
1263
|
# Converts the scope to HDLRuby::Low.
|
1264
1264
|
def to_low()
|
1265
1265
|
# Create the resulting low scope.
|
1266
|
-
scopeLow = HDLRuby::Low::Scope.new()
|
1266
|
+
# scopeLow = HDLRuby::Low::Scope.new()
|
1267
|
+
scopeLow = HDLRuby::Low::Scope.new(self.name)
|
1267
1268
|
# Push the private namespace for the low generation.
|
1268
1269
|
High.space_push(@namespace)
|
1269
1270
|
# Pushes on the name stack for converting the internals of
|
@@ -1858,7 +1859,8 @@ module HDLRuby::High
|
|
1858
1859
|
def function(name, &ruby_block)
|
1859
1860
|
if HDLRuby::High.in_system? then
|
1860
1861
|
define_singleton_method(name.to_sym) do |*args,&other_block|
|
1861
|
-
sub do
|
1862
|
+
# sub do
|
1863
|
+
sub(HDLRuby.uniq_name(name)) do
|
1862
1864
|
HDLRuby::High.top_user.instance_exec(*args,*other_block,
|
1863
1865
|
&ruby_block)
|
1864
1866
|
# ruby_block.call(*args)
|
@@ -1866,7 +1868,8 @@ module HDLRuby::High
|
|
1866
1868
|
end
|
1867
1869
|
else
|
1868
1870
|
define_method(name.to_sym) do |*args,&other_block|
|
1869
|
-
sub do
|
1871
|
+
# sub do
|
1872
|
+
sub(HDLRuby.uniq_name(name)) do
|
1870
1873
|
HDLRuby::High.top_user.instance_exec(*args,*other_block,
|
1871
1874
|
&ruby_block)
|
1872
1875
|
end
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -2633,6 +2633,11 @@ module HDLRuby::Low
|
|
2633
2633
|
def parent_system
|
2634
2634
|
return self.top_scope.parent
|
2635
2635
|
end
|
2636
|
+
|
2637
|
+
# Tell if the statement includes a signal whose name is one of +names+.
|
2638
|
+
def use_name?(*names)
|
2639
|
+
# By default, nothing to do.
|
2640
|
+
end
|
2636
2641
|
end
|
2637
2642
|
|
2638
2643
|
|
@@ -2747,6 +2752,11 @@ module HDLRuby::Low
|
|
2747
2752
|
# A ruby block?
|
2748
2753
|
# Nothing to do.
|
2749
2754
|
end
|
2755
|
+
|
2756
|
+
# Tell if the statement includes a signal whose name is one of +names+.
|
2757
|
+
def use_name?(*names)
|
2758
|
+
return @left.use_name?(*names) || @right.use_name?(*names)
|
2759
|
+
end
|
2750
2760
|
end
|
2751
2761
|
|
2752
2762
|
|
@@ -2925,6 +2935,12 @@ module HDLRuby::Low
|
|
2925
2935
|
@no.each_block_deep(&ruby_block) if @no
|
2926
2936
|
end
|
2927
2937
|
|
2938
|
+
# Tell if the statement includes a signal whose name is one of +names+.
|
2939
|
+
# NOTE: for the if check only the condition.
|
2940
|
+
def use_name?(*names)
|
2941
|
+
return @condition.use_name?(*name)
|
2942
|
+
end
|
2943
|
+
|
2928
2944
|
# Clones the If (deeply)
|
2929
2945
|
def clone
|
2930
2946
|
# Duplicate the if.
|
@@ -3038,6 +3054,12 @@ module HDLRuby::Low
|
|
3038
3054
|
def top_block
|
3039
3055
|
return self.parent.is_a?(Behavior) ? self : self.parent.top_block
|
3040
3056
|
end
|
3057
|
+
|
3058
|
+
# Tell if the statement includes a signal whose name is one of +names+.
|
3059
|
+
# NOTE: for the when check only the match.
|
3060
|
+
def use_name?(*names)
|
3061
|
+
return @match.use_name?(*name)
|
3062
|
+
end
|
3041
3063
|
end
|
3042
3064
|
|
3043
3065
|
|
@@ -3186,6 +3208,12 @@ module HDLRuby::Low
|
|
3186
3208
|
@default.each_statement_deep(&ruby_block) if @default
|
3187
3209
|
end
|
3188
3210
|
|
3211
|
+
# Tell if the statement includes a signal whose name is one of +names+.
|
3212
|
+
# NOTE: for the case check only the value.
|
3213
|
+
def use_name?(*names)
|
3214
|
+
return @value.use_name?(*name)
|
3215
|
+
end
|
3216
|
+
|
3189
3217
|
# Clones the Case (deeply)
|
3190
3218
|
def clone
|
3191
3219
|
# Clone the default if any.
|
@@ -3838,6 +3866,12 @@ module HDLRuby::Low
|
|
3838
3866
|
end
|
3839
3867
|
end
|
3840
3868
|
|
3869
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
3870
|
+
def use_name?(*names)
|
3871
|
+
# By default nothing.
|
3872
|
+
return false
|
3873
|
+
end
|
3874
|
+
|
3841
3875
|
# Clones the expression (deeply)
|
3842
3876
|
def clone
|
3843
3877
|
raise AnyError,
|
@@ -3991,6 +4025,12 @@ module HDLRuby::Low
|
|
3991
4025
|
@child.each_ref_deep(&ruby_block)
|
3992
4026
|
end
|
3993
4027
|
|
4028
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4029
|
+
def use_name?(*names)
|
4030
|
+
# Recurse on the child.
|
4031
|
+
return @child.use_name?(*names)
|
4032
|
+
end
|
4033
|
+
|
3994
4034
|
# Clones the value (deeply)
|
3995
4035
|
def clone
|
3996
4036
|
return Cast.new(@type,@child.clone)
|
@@ -4101,6 +4141,12 @@ module HDLRuby::Low
|
|
4101
4141
|
@child.each_ref_deep(&ruby_block)
|
4102
4142
|
end
|
4103
4143
|
|
4144
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4145
|
+
def use_name?(*names)
|
4146
|
+
# Recurse on the child.
|
4147
|
+
return @child.use_name?(*names)
|
4148
|
+
end
|
4149
|
+
|
4104
4150
|
# Clones the unary operator (deeply)
|
4105
4151
|
def clone
|
4106
4152
|
return Unary.new(@type,self.operator,@child.clone)
|
@@ -4187,6 +4233,12 @@ module HDLRuby::Low
|
|
4187
4233
|
@right.each_ref_deep(&ruby_block)
|
4188
4234
|
end
|
4189
4235
|
|
4236
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4237
|
+
def use_name?(*names)
|
4238
|
+
# Recurse on the left and the right.
|
4239
|
+
return @left.use_name?(*names) || @right.use_name?(*names)
|
4240
|
+
end
|
4241
|
+
|
4190
4242
|
# Clones the binary operator (deeply)
|
4191
4243
|
def clone
|
4192
4244
|
return Binary.new(@type, self.operator,
|
@@ -4311,6 +4363,14 @@ module HDLRuby::Low
|
|
4311
4363
|
end
|
4312
4364
|
end
|
4313
4365
|
|
4366
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4367
|
+
def use_name?(*names)
|
4368
|
+
# Recurse on the select.
|
4369
|
+
return true if @select.use_name?(*names)
|
4370
|
+
# Recurse on the choices.
|
4371
|
+
return @choices.include? { |choice| choice.use_name?(*names) }
|
4372
|
+
end
|
4373
|
+
|
4314
4374
|
# Clones the select (deeply)
|
4315
4375
|
def clone
|
4316
4376
|
return Select.new(@type, self.operator, @select.clone,
|
@@ -4390,6 +4450,12 @@ module HDLRuby::Low
|
|
4390
4450
|
end
|
4391
4451
|
end
|
4392
4452
|
|
4453
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4454
|
+
def use_name?(*names)
|
4455
|
+
# Recurse on the expressions.
|
4456
|
+
return @expressions.include? { |expr| expr.use_name?(*names) }
|
4457
|
+
end
|
4458
|
+
|
4393
4459
|
# Clones the concatenated expression (deeply)
|
4394
4460
|
def clone
|
4395
4461
|
return Concat.new(@type,
|
@@ -4532,6 +4598,12 @@ module HDLRuby::Low
|
|
4532
4598
|
end
|
4533
4599
|
end
|
4534
4600
|
|
4601
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4602
|
+
def use_name?(*names)
|
4603
|
+
# Recurse on the references.
|
4604
|
+
return @refs.include? { |expr| expr.use_name?(*names) }
|
4605
|
+
end
|
4606
|
+
|
4535
4607
|
# Clones the concatenated references (deeply)
|
4536
4608
|
def clone
|
4537
4609
|
return RefConcat.new(@type, @refs.map { |ref| ref.clone } )
|
@@ -4615,6 +4687,12 @@ module HDLRuby::Low
|
|
4615
4687
|
@ref.each_node_deep(&ruby_block)
|
4616
4688
|
end
|
4617
4689
|
|
4690
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4691
|
+
def use_name?(*names)
|
4692
|
+
# Recurse on the index and the reference.
|
4693
|
+
return @index.use_name?(names) || @ref.use_name?(*names)
|
4694
|
+
end
|
4695
|
+
|
4618
4696
|
# Clones the indexed references (deeply)
|
4619
4697
|
def clone
|
4620
4698
|
return RefIndex.new(@type, @ref.clone, @index.clone)
|
@@ -4710,6 +4788,13 @@ module HDLRuby::Low
|
|
4710
4788
|
@ref.each_node_deep(&ruby_block)
|
4711
4789
|
end
|
4712
4790
|
|
4791
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4792
|
+
def use_name?(*names)
|
4793
|
+
# Recurse on the range and the reference.
|
4794
|
+
return @range.first.use_name?(names) ||
|
4795
|
+
@range.last.use_name?(names) || @ref.use_name?(*names)
|
4796
|
+
end
|
4797
|
+
|
4713
4798
|
# Clones the range references (deeply)
|
4714
4799
|
def clone
|
4715
4800
|
return RefRange.new(@type, @ref.clone,
|
@@ -4797,6 +4882,14 @@ module HDLRuby::Low
|
|
4797
4882
|
@ref.each_node_deep(&ruby_block)
|
4798
4883
|
end
|
4799
4884
|
|
4885
|
+
# Tell if the expression includes a signal whose name is one of +names+.
|
4886
|
+
def use_name?(*names)
|
4887
|
+
# Is the named used here?
|
4888
|
+
return true if names.include?(@name)
|
4889
|
+
# No, recurse the reference.
|
4890
|
+
return @ref.use_name?(*names)
|
4891
|
+
end
|
4892
|
+
|
4800
4893
|
# Clones the name references (deeply)
|
4801
4894
|
def clone
|
4802
4895
|
return RefName.new(@type, @ref.clone, @name)
|
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -1946,7 +1946,9 @@ module HDLRuby::Low
|
|
1946
1946
|
# Generates the C text for reference as left value to a signal.
|
1947
1947
|
# +level+ is the hierarchical level of the object.
|
1948
1948
|
def to_c_signal(level = 0)
|
1949
|
-
return to_c(level,true)
|
1949
|
+
# return to_c(level,true)
|
1950
|
+
return "make_ref_rangeS(#{self.ref.to_c_signal(level)}," +
|
1951
|
+
"value2integer(#{self.range.first.to_c(level)}),value2integer(#{self.range.last.to_c(level)}))"
|
1950
1952
|
end
|
1951
1953
|
end
|
1952
1954
|
|
@@ -156,7 +156,7 @@ module HDLRuby::Low
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
# Deletes
|
159
|
+
# Deletes a type.
|
160
160
|
def delete_type!(type)
|
161
161
|
if @types.key?(type.name) then
|
162
162
|
# The type is present, delete it.
|
@@ -167,7 +167,7 @@ module HDLRuby::Low
|
|
167
167
|
type
|
168
168
|
end
|
169
169
|
|
170
|
-
# Deletes
|
170
|
+
# Deletes a systemT.
|
171
171
|
def delete_systemT!(systemT)
|
172
172
|
if @systemTs.key?(systemT.name) then
|
173
173
|
# The systemT is present, delete it.
|
@@ -230,6 +230,33 @@ module HDLRuby::Low
|
|
230
230
|
behavior.parent = nil
|
231
231
|
end
|
232
232
|
end
|
233
|
+
|
234
|
+
# Deletes the elements related to one of +names+: either they have
|
235
|
+
# one of the names or they use an element with these names.
|
236
|
+
# NOTE: only delete actual instantiated elements, types or
|
237
|
+
# systemTs are left as is.
|
238
|
+
def delete_related!(*names)
|
239
|
+
# Delete the sub scopes whose name are in names.
|
240
|
+
@scopes.delete_if { |scope| names.include?(scope.name) }
|
241
|
+
# Delete the inner signals whose name are in names.
|
242
|
+
@inners.delete_if { |sig| names.include?(sig.name) }
|
243
|
+
# Delete the connections that contain signals whose name are
|
244
|
+
# in names.
|
245
|
+
@connections.delete_if { |connection| connection.use_name?(*names) }
|
246
|
+
# Delete the behaviors whose block name or events' name are in
|
247
|
+
# names.
|
248
|
+
@behaviors.delete_if do |behavior|
|
249
|
+
names.include?(behavior.block.name) or
|
250
|
+
behavior.each_event.include? do |event|
|
251
|
+
event.ref.use_name?(*names)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# Recurse on the sub scopes.
|
256
|
+
@scopes.each { |scope| scope.delete_related!(names) }
|
257
|
+
# Recurse on the behaviors.
|
258
|
+
@behaviors.each { |behavior| behavior.block.delete_related!(names) }
|
259
|
+
end
|
233
260
|
end
|
234
261
|
|
235
262
|
|
@@ -514,6 +541,14 @@ module HDLRuby::Low
|
|
514
541
|
# By default: nothing to do.
|
515
542
|
return {}
|
516
543
|
end
|
544
|
+
|
545
|
+
# Deletes the elements related to one of +names+: either they have
|
546
|
+
# one of the names or they use an element with these names.
|
547
|
+
# NOTE: only delete actual instantiated elements, types or
|
548
|
+
# systemTs are left as is.
|
549
|
+
def delete_related!(*names)
|
550
|
+
# Nothing to do by default.
|
551
|
+
end
|
517
552
|
end
|
518
553
|
|
519
554
|
|
@@ -694,6 +729,21 @@ module HDLRuby::Low
|
|
694
729
|
|
695
730
|
return res
|
696
731
|
end
|
732
|
+
|
733
|
+
# Deletes the elements related to one of +names+: either they have
|
734
|
+
# one of the names or they use an element with these names.
|
735
|
+
# NOTE: only delete actual instantiated elements, types or
|
736
|
+
# systemTs are left as is.
|
737
|
+
def delete_related!(*names)
|
738
|
+
# Delete the noifs if their condition uses one of names.
|
739
|
+
@noifs.delete_if { |noif| noif[0].use_names?(names) }
|
740
|
+
# Recurse on the yes.
|
741
|
+
@yes.delete_related!(*names)
|
742
|
+
# Recurse on the no.
|
743
|
+
@no.delete_related!(*names)
|
744
|
+
# Recruse one the no ifs statements.
|
745
|
+
@noifs.each { |noif| noif[1].delete_related!(*names) }
|
746
|
+
end
|
697
747
|
end
|
698
748
|
|
699
749
|
##
|
@@ -758,6 +808,15 @@ module HDLRuby::Low
|
|
758
808
|
|
759
809
|
return res
|
760
810
|
end
|
811
|
+
|
812
|
+
# Deletes the elements related to one of +names+: either they have
|
813
|
+
# one of the names or they use an element with these names.
|
814
|
+
# NOTE: only delete actual instantiated elements, types or
|
815
|
+
# systemTs are left as is.
|
816
|
+
def delete_related!(*names)
|
817
|
+
# Recurse on the statement.
|
818
|
+
@statement.delete_related!(*names)
|
819
|
+
end
|
761
820
|
end
|
762
821
|
|
763
822
|
|
@@ -833,6 +892,18 @@ module HDLRuby::Low
|
|
833
892
|
|
834
893
|
return res
|
835
894
|
end
|
895
|
+
|
896
|
+
# Deletes the elements related to one of +names+: either they have
|
897
|
+
# one of the names or they use an element with these names.
|
898
|
+
# NOTE: only delete actual instantiated elements, types or
|
899
|
+
# systemTs are left as is.
|
900
|
+
def delete_related!(*names)
|
901
|
+
# Delete the whens whose match contains a signal whoses name is
|
902
|
+
# in names.
|
903
|
+
@whens.delete_if { |w| w.match.use_name?(*names) }
|
904
|
+
# Recurse on the whens.
|
905
|
+
@whens.each { |w| w.delete_related!(*names) }
|
906
|
+
end
|
836
907
|
end
|
837
908
|
|
838
909
|
|
@@ -1091,8 +1162,25 @@ module HDLRuby::Low
|
|
1091
1162
|
end
|
1092
1163
|
end
|
1093
1164
|
end
|
1165
|
+
|
1166
|
+
# Deletes the elements related to one of +names+: either they have
|
1167
|
+
# one of the names or they use an element with these names.
|
1168
|
+
# NOTE: only delete actual instantiated elements, types or
|
1169
|
+
# systemTs are left as is.
|
1170
|
+
def delete_related!(*names)
|
1171
|
+
# Delete the inner signals whose name are in names.
|
1172
|
+
@inners.delete_if { |sig| names.include?(sig.name) }
|
1173
|
+
# Recurse on the statements.
|
1174
|
+
@statements.each do |statement|
|
1175
|
+
statement.delete_related!(*names)
|
1176
|
+
end
|
1177
|
+
# Delete the statements that contain signals whose name are
|
1178
|
+
# in names.
|
1179
|
+
@statements.delete_if { |statement| statement.use_name?(*names) }
|
1180
|
+
end
|
1094
1181
|
end
|
1095
1182
|
|
1183
|
+
|
1096
1184
|
# Describes a timed block.
|
1097
1185
|
#
|
1098
1186
|
# NOTE:
|
@@ -29,6 +29,7 @@ module HDLRuby::Low
|
|
29
29
|
if scope.each_connection.to_a.any? then
|
30
30
|
inputs_blk = Block.new(:par)
|
31
31
|
outputs_blk = Block.new(:par)
|
32
|
+
timed_blk = TimeBlock.new(:seq)
|
32
33
|
scope.each_connection do |connection|
|
33
34
|
# Check the left and right of the connection
|
34
35
|
# for input or output port.
|
@@ -40,6 +41,15 @@ module HDLRuby::Low
|
|
40
41
|
right_r = right.resolve if right.respond_to?(:resolve)
|
41
42
|
# puts "right_r=#{right_r.name}" if right_r
|
42
43
|
# puts "right_r.parent=#{right_r.parent.name}" if right_r && right_r.parent
|
44
|
+
if right.is_a?(Value) then
|
45
|
+
# Right is value, the new transmit is to add
|
46
|
+
# to the timed block.
|
47
|
+
timed_blk.add_statement(
|
48
|
+
Transmit.new(left.clone,right.clone))
|
49
|
+
# No more process for this connection.
|
50
|
+
next
|
51
|
+
end
|
52
|
+
|
43
53
|
# Check if left is an input or an output.
|
44
54
|
left_is_i = left_is_o = false
|
45
55
|
if left_r && left_r.parent.is_a?(SystemT) then
|
@@ -118,6 +128,9 @@ module HDLRuby::Low
|
|
118
128
|
if outputs_blk.each_statement.any? then
|
119
129
|
scope.add_behavior(Behavior.new(outputs_blk))
|
120
130
|
end
|
131
|
+
if timed_blk.each_statement.any? then
|
132
|
+
scope.add_behavior(TimeBehavior.new(timed_blk))
|
133
|
+
end
|
121
134
|
end
|
122
135
|
end
|
123
136
|
end
|
data/lib/HDLRuby/hruby_tools.rb
CHANGED
@@ -13,9 +13,9 @@ module HDLRuby
|
|
13
13
|
@@absoluteCounter = -1 # The absolute name counter.
|
14
14
|
|
15
15
|
# Generates an absolute uniq name.
|
16
|
-
def self.uniq_name
|
16
|
+
def self.uniq_name(base = "")
|
17
17
|
@@absoluteCounter += 1
|
18
|
-
name = ":#{@@absoluteCounter}"
|
18
|
+
name = base.to_s + ":#{@@absoluteCounter}"
|
19
19
|
if Symbol.all_symbols.find {|symbol| symbol.to_s == name } then
|
20
20
|
# The symbol exists, try again.
|
21
21
|
return self.uniq_name
|
data/lib/HDLRuby/sim/hruby_sim.h
CHANGED
@@ -612,14 +612,18 @@ extern Value read_range(Value value, long long first, long long last,
|
|
612
612
|
* @param src the source value
|
613
613
|
* @param first the first index of the range
|
614
614
|
* @param last the last index of the range
|
615
|
+
* @param base the type of the elements
|
615
616
|
* @param dst the destination value
|
616
617
|
* @return dst */
|
617
|
-
extern Value write_range(Value src, long long first, long long last,
|
618
|
+
extern Value write_range(Value src, long long first, long long last,
|
619
|
+
Type base, Value dst);
|
618
620
|
|
619
621
|
/** Writes to a range within a value but without overwrite with Z.
|
620
622
|
* @param src the source value
|
621
623
|
* @param first the first index of the range
|
622
624
|
* @param last the last index of the range
|
625
|
+
* @param base the type of the elements
|
623
626
|
* @param dst the destination value
|
624
627
|
* @return dst */
|
625
|
-
extern Value write_range_no_z(Value src, long long first, long long last,
|
628
|
+
extern Value write_range_no_z(Value src, long long first, long long last,
|
629
|
+
Type base, Value dst);
|
@@ -1354,10 +1354,11 @@ Value read_range_bitstring(Value src, long long first, long long last,
|
|
1354
1354
|
* @param src the source value
|
1355
1355
|
* @param first the first index of the range
|
1356
1356
|
* @param last the last index of the range
|
1357
|
+
* @param base the type of the elements
|
1357
1358
|
* @param dst the destination value
|
1358
1359
|
* @return dst */
|
1359
1360
|
Value write_range_bitstring(Value src, long long first, long long last,
|
1360
|
-
Value dst) {
|
1361
|
+
Type base, Value dst) {
|
1361
1362
|
unsigned long long i;
|
1362
1363
|
/* Ensure first is the smaller. */
|
1363
1364
|
if (first > last) {
|
@@ -1370,7 +1371,8 @@ Value write_range_bitstring(Value src, long long first, long long last,
|
|
1370
1371
|
unsigned long long src_width = type_width(src->type);
|
1371
1372
|
unsigned long long dst_width = type_width(dst->type);
|
1372
1373
|
/* scale the range according to the base type. */
|
1373
|
-
unsigned long long bw = dst->type->base;
|
1374
|
+
// unsigned long long bw = dst->type->base;
|
1375
|
+
unsigned long long bw = type_width(base);
|
1374
1376
|
first *= bw;
|
1375
1377
|
last *= bw;
|
1376
1378
|
last += bw-1;
|
@@ -1391,10 +1393,11 @@ Value write_range_bitstring(Value src, long long first, long long last,
|
|
1391
1393
|
* @param src the source value
|
1392
1394
|
* @param first the first index of the range
|
1393
1395
|
* @param last the last index of the range
|
1396
|
+
* @param base the type of the elements
|
1394
1397
|
* @param dst the destination value
|
1395
1398
|
* @return dst */
|
1396
1399
|
Value write_range_bitstring_no_z(Value src, long long first, long long last,
|
1397
|
-
Value dst) {
|
1400
|
+
Type base, Value dst) {
|
1398
1401
|
unsigned long long i;
|
1399
1402
|
/* Ensure first is the smaller. */
|
1400
1403
|
if (first > last) {
|
@@ -1406,7 +1409,8 @@ Value write_range_bitstring_no_z(Value src, long long first, long long last,
|
|
1406
1409
|
unsigned long long src_width = type_width(src->type);
|
1407
1410
|
unsigned long long dst_width = type_width(dst->type);
|
1408
1411
|
/* scale the range according to the base type. */
|
1409
|
-
unsigned long long bw = dst->type->base;
|
1412
|
+
// unsigned long long bw = dst->type->base;
|
1413
|
+
unsigned long long bw = type_width(base);
|
1410
1414
|
first *= bw;
|
1411
1415
|
last *= bw;
|
1412
1416
|
/* Access the source and destination bitstring data. */
|
@@ -1864,10 +1868,11 @@ Value read_range_numeric(Value value, long long first, long long last,
|
|
1864
1868
|
* @param src the source value
|
1865
1869
|
* @param first the first index of the range
|
1866
1870
|
* @param last the last index of the range
|
1871
|
+
* @param base the type of the elements
|
1867
1872
|
* @param dst the destination value
|
1868
1873
|
* @return dst */
|
1869
1874
|
Value write_range_numeric(Value src, long long first, long long last,
|
1870
|
-
Value dst) {
|
1875
|
+
Type base, Value dst) {
|
1871
1876
|
// printf("write_range_numeric\n");
|
1872
1877
|
/* Ensure first is the smaller. */
|
1873
1878
|
if (first > last) {
|
@@ -1879,7 +1884,8 @@ Value write_range_numeric(Value src, long long first, long long last,
|
|
1879
1884
|
unsigned long long src_width = type_width(src->type);
|
1880
1885
|
unsigned long long dst_width = type_width(dst->type);
|
1881
1886
|
/* scale the range according to the base type of the destination. */
|
1882
|
-
unsigned long long bw = dst->type->base;
|
1887
|
+
// unsigned long long bw = dst->type->base;
|
1888
|
+
unsigned long long bw = type_width(base);
|
1883
1889
|
// printf("src_width=%llu dst_wdith=%llu bw=%llu\n",src_width,dst_width,bw);
|
1884
1890
|
first *= bw;
|
1885
1891
|
last *= bw;
|
@@ -2691,14 +2697,17 @@ Value read_range(Value value, long long first, long long last, Type base,
|
|
2691
2697
|
* @param src the source value
|
2692
2698
|
* @param first the first index of the range
|
2693
2699
|
* @param last the last index of the range
|
2700
|
+
* @param base the type of the elements
|
2694
2701
|
* @param dst the destination value
|
2695
2702
|
* @return dst */
|
2696
|
-
Value write_range(Value src, long long first, long long last,
|
2703
|
+
Value write_range(Value src, long long first, long long last, Type base,
|
2704
|
+
Value dst) {
|
2697
2705
|
// printf("write_range\n");
|
2698
2706
|
/* Is the value numeric? */
|
2699
2707
|
if ((src->numeric) && (dst->numeric)) {
|
2700
2708
|
/* Yes, do a numeric range read. */
|
2701
|
-
return write_range_numeric(src,first,last,dst);
|
2709
|
+
// return write_range_numeric(src,first,last,dst);
|
2710
|
+
return write_range_numeric(src,first,last,base,dst);
|
2702
2711
|
} else {
|
2703
2712
|
/* No, do a bitstring range read. */
|
2704
2713
|
if (dst->numeric) {
|
@@ -2708,7 +2717,8 @@ Value write_range(Value src, long long first, long long last, Value dst) {
|
|
2708
2717
|
/* Need to convert the source to a bitstring. */
|
2709
2718
|
src = set_bitstring_value(src,get_value());
|
2710
2719
|
}
|
2711
|
-
return write_range_bitstring(src,first,last,dst);
|
2720
|
+
// return write_range_bitstring(src,first,last,dst);
|
2721
|
+
return write_range_bitstring(src,first,last,base,dst);
|
2712
2722
|
}
|
2713
2723
|
}
|
2714
2724
|
|
@@ -2717,14 +2727,16 @@ Value write_range(Value src, long long first, long long last, Value dst) {
|
|
2717
2727
|
* @param src the source value
|
2718
2728
|
* @param first the first index of the range
|
2719
2729
|
* @param last the last index of the range
|
2730
|
+
* @param base the type of the elements
|
2720
2731
|
* @param dst the destination value
|
2721
2732
|
* @return dst */
|
2722
|
-
Value write_range_no_z(Value src, long long first, long long last,
|
2733
|
+
Value write_range_no_z(Value src, long long first, long long last, Type base,
|
2734
|
+
Value dst) {
|
2723
2735
|
// printf("write_range_no_z\n");
|
2724
2736
|
/* Is the value numeric? */
|
2725
2737
|
if ((src->numeric) && (dst->numeric)) {
|
2726
2738
|
/* Yes, do a numeric range read. */
|
2727
|
-
return write_range_numeric(src,first,last,dst);
|
2739
|
+
return write_range_numeric(src,first,last,base,dst);
|
2728
2740
|
} else {
|
2729
2741
|
/* No, do a bitstring range read. */
|
2730
2742
|
if (dst->numeric) {
|
@@ -2734,7 +2746,8 @@ Value write_range_no_z(Value src, long long first, long long last, Value dst) {
|
|
2734
2746
|
/* Need to convert the source to a bitstring. */
|
2735
2747
|
src = set_bitstring_value(src,get_value());
|
2736
2748
|
}
|
2737
|
-
return write_range_bitstring_no_z(src,first,last,dst);
|
2749
|
+
// return write_range_bitstring_no_z(src,first,last,dst);
|
2750
|
+
return write_range_bitstring_no_z(src,first,last,base,dst);
|
2738
2751
|
}
|
2739
2752
|
}
|
2740
2753
|
|
@@ -499,12 +499,18 @@ void transmit_to_signal_range(Value value, RefRangeS ref) {
|
|
499
499
|
SignalI signal = ref.signal;
|
500
500
|
unsigned long long first = ref.first;
|
501
501
|
unsigned long long last = ref.last;
|
502
|
+
/* The base type is stored here to avoid allocating a new type each time.
|
503
|
+
* It have an arbitrary base size a single element. */
|
504
|
+
static TypeS baseT = { 1, 1 };
|
505
|
+
baseT.base = signal->f_value->type->base;
|
502
506
|
// printf("Tansmit to signal range: %s(%p) [%lld:%lld]\n",signal->name,signal,first,last);
|
503
507
|
/* Can transmit, copy the content. */
|
504
508
|
if (signal->fading)
|
505
|
-
signal->f_value = write_range(value,first,last,
|
509
|
+
signal->f_value = write_range(value,first,last,&baseT,
|
510
|
+
signal->f_value);
|
506
511
|
else
|
507
|
-
signal->f_value = write_range_no_z(value,first,last,
|
512
|
+
signal->f_value = write_range_no_z(value,first,last,&baseT,
|
513
|
+
signal->f_value);
|
508
514
|
/* And touch the signal. */
|
509
515
|
touch_signal(signal);
|
510
516
|
}
|
@@ -553,9 +559,9 @@ void transmit_to_signal_range_seq(Value value, RefRangeS ref) {
|
|
553
559
|
// printf("Tansmit to signal range: %s(%p)\n",signal->name,signal);
|
554
560
|
/* Can transmit, copy the content. */
|
555
561
|
if (signal->fading)
|
556
|
-
write_range(value,first,last,signal->f_value);
|
562
|
+
write_range(value,first,last,signal->f_value->type,signal->f_value);
|
557
563
|
else
|
558
|
-
write_range_no_z(value,first,last,signal->f_value);
|
564
|
+
write_range_no_z(value,first,last,signal->f_value->type,signal->f_value);
|
559
565
|
/* And touch the signal. */
|
560
566
|
touch_signal_seq(signal);
|
561
567
|
}
|
data/lib/HDLRuby/std/channel.rb
CHANGED
@@ -45,8 +45,10 @@ module HDLRuby::High::Std
|
|
45
45
|
# Generates the channels.
|
46
46
|
channelI = nil
|
47
47
|
args.each do |nameI|
|
48
|
-
|
49
|
-
|
48
|
+
# puts "nameI=#{nameI}"
|
49
|
+
channelI = ChannelI.new(nameI,&@ruby_block)
|
50
|
+
# Already registered!
|
51
|
+
# HDLRuby::High.space_reg(nameI) { channelI }
|
50
52
|
end
|
51
53
|
channelI
|
52
54
|
end
|
@@ -323,6 +325,86 @@ module HDLRuby::High::Std
|
|
323
325
|
end
|
324
326
|
|
325
327
|
|
328
|
+
##
|
329
|
+
# Module giving the methods for accessing a channel instance.
|
330
|
+
module HchannelI
|
331
|
+
## Performs a read on the channel using +args+ and +ruby_block+
|
332
|
+
# as arguments.
|
333
|
+
# NOTE:
|
334
|
+
# * Will generate a port if not present.
|
335
|
+
# * Will generate an error if a read is tempted while the read
|
336
|
+
# port has been declared within another system.
|
337
|
+
def read(*args,&ruby_block)
|
338
|
+
# Is there a port to read?
|
339
|
+
unless self.read_port then
|
340
|
+
# No, generate a new one.
|
341
|
+
# Is it possible to be inout?
|
342
|
+
if self.inout? then
|
343
|
+
# Yes, create an inout port.
|
344
|
+
self.inout(HDLRuby.uniq_name)
|
345
|
+
else
|
346
|
+
# No, create an input port.
|
347
|
+
self.input(HDLRuby.uniq_name)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
# Ensure the read port is within current system.
|
351
|
+
unless self.read_port.scope.system != HDLRuby::High.cur_system then
|
352
|
+
raise "Cannot read from a port external of current system for channel " + self.name
|
353
|
+
end
|
354
|
+
# Performs the read.
|
355
|
+
self.read_port.read(*args,&ruby_block)
|
356
|
+
end
|
357
|
+
|
358
|
+
## Performs a write on the channel using +args+ and +ruby_block+
|
359
|
+
# as arguments.
|
360
|
+
# NOTE:
|
361
|
+
# * Will generate a port if not present.
|
362
|
+
# * Will generate an error if a read is tempted while the read
|
363
|
+
# port has been declared within another system.
|
364
|
+
def write(*args,&ruby_block)
|
365
|
+
# Is there a port to write?
|
366
|
+
unless self.write_port then
|
367
|
+
# No, generate a new one.
|
368
|
+
# Is it possible to be inout?
|
369
|
+
if self.inout? then
|
370
|
+
# Yes, create an inout port.
|
371
|
+
self.inout(HDLRuby.uniq_name)
|
372
|
+
else
|
373
|
+
# No, create an output port.
|
374
|
+
self.output(HDLRuby.uniq_name)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
# Ensure the write port is within current system.
|
378
|
+
unless self.write_port.scope.system != HDLRuby::High.cur_system then
|
379
|
+
raise "Cannot write from a port external of current system for channel " + self.name
|
380
|
+
end
|
381
|
+
# Performs the write.
|
382
|
+
self.write_port.write(*args,&ruby_block)
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
## Performs a reset on the channel using +args+ and +ruby_block+
|
387
|
+
# as arguments.
|
388
|
+
def reset(*args,&ruby_block)
|
389
|
+
# Gain access to the writer as local variable.
|
390
|
+
reseter_proc = @inout_reseter_proc
|
391
|
+
# # The context is the one of the writer.
|
392
|
+
# Execute the code generating the writer in context.
|
393
|
+
HDLRuby::High.space_push(@namespace)
|
394
|
+
HDLRuby::High.cur_block.open do
|
395
|
+
instance_exec(ruby_block,*args,&reseter_proc)
|
396
|
+
end
|
397
|
+
HDLRuby::High.space_pop
|
398
|
+
end
|
399
|
+
|
400
|
+
|
401
|
+
# Wrap with +args+ arguments.
|
402
|
+
def wrap(*args)
|
403
|
+
return ChannelB.new(self,*args)
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
|
326
408
|
|
327
409
|
##
|
328
410
|
# Describes a high-level channel instance.
|
@@ -350,9 +432,11 @@ module HDLRuby::High::Std
|
|
350
432
|
def initialize(name,&ruby_block)
|
351
433
|
# Check and set the name of the channel.
|
352
434
|
@name = name.to_sym
|
435
|
+
# puts "my name is #{self.name}"
|
353
436
|
# Generate a name for the scope containing the signals of
|
354
437
|
# the channel.
|
355
|
-
@scope_name = HDLRuby.uniq_name
|
438
|
+
# @scope_name = HDLRuby.uniq_name
|
439
|
+
@scope_name = HDLRuby.uniq_name(name)
|
356
440
|
|
357
441
|
# # Sets the scope.
|
358
442
|
# @scope = HDLRuby::High.cur_scope
|
@@ -635,6 +719,7 @@ module HDLRuby::High::Std
|
|
635
719
|
# Alternatively, a ready channel instance can be passed as argument
|
636
720
|
# as +channelI+.
|
637
721
|
def brancher(name,channelI = nil,&ruby_block)
|
722
|
+
# puts "self.name=#{self.name} and name=#{name}"
|
638
723
|
# Ensure name is a symbol.
|
639
724
|
name = name.to_s unless name.respond_to?(:to_sym)
|
640
725
|
name = name.to_sym
|
@@ -646,6 +731,7 @@ module HDLRuby::High::Std
|
|
646
731
|
end
|
647
732
|
# Now, create the branch.
|
648
733
|
channelI = HDLRuby::High::Std.channel_instance(name, &ruby_block)
|
734
|
+
# channelI = HDLRuby::High::Std.channel_instance("#{self.name}::#{name}", &ruby_block)
|
649
735
|
@branches[name] = channelI
|
650
736
|
return self
|
651
737
|
end
|
@@ -858,12 +944,12 @@ module HDLRuby::High::Std
|
|
858
944
|
# Ensure the port is not already existing.
|
859
945
|
if @read_port then
|
860
946
|
raise "Read port already declared for channel instance: " +
|
861
|
-
self.name
|
947
|
+
self.name.to_s
|
862
948
|
end
|
863
949
|
|
864
950
|
if @write_port then
|
865
951
|
raise "Write port already declared for channel instance: " +
|
866
|
-
self.name
|
952
|
+
self.name.to_s
|
867
953
|
end
|
868
954
|
|
869
955
|
# Access the ports
|
@@ -1000,76 +1086,238 @@ module HDLRuby::High::Std
|
|
1000
1086
|
# return chp
|
1001
1087
|
# end
|
1002
1088
|
|
1089
|
+
# Standard channel access is given is HchannelI module.
|
1090
|
+
include HchannelI
|
1003
1091
|
|
1004
1092
|
|
1005
|
-
## Performs a read on the channel using +args+ and +ruby_block+
|
1006
|
-
# as arguments.
|
1007
|
-
# NOTE:
|
1008
|
-
# * Will generate a port if not present.
|
1009
|
-
# * Will generate an error if a read is tempted while the read
|
1010
|
-
# port has been declared within another system.
|
1011
|
-
def read(*args,&ruby_block)
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1093
|
+
# ## Performs a read on the channel using +args+ and +ruby_block+
|
1094
|
+
# # as arguments.
|
1095
|
+
# # NOTE:
|
1096
|
+
# # * Will generate a port if not present.
|
1097
|
+
# # * Will generate an error if a read is tempted while the read
|
1098
|
+
# # port has been declared within another system.
|
1099
|
+
# def read(*args,&ruby_block)
|
1100
|
+
# # Is there a port to read?
|
1101
|
+
# unless self.read_port then
|
1102
|
+
# # No, generate a new one.
|
1103
|
+
# # Is it possible to be inout?
|
1104
|
+
# if self.inout? then
|
1105
|
+
# # Yes, create an inout port.
|
1106
|
+
# self.inout(HDLRuby.uniq_name)
|
1107
|
+
# else
|
1108
|
+
# # No, create an input port.
|
1109
|
+
# self.input(HDLRuby.uniq_name)
|
1110
|
+
# end
|
1111
|
+
# end
|
1112
|
+
# # Ensure the read port is within current system.
|
1113
|
+
# unless self.read_port.scope.system != HDLRuby::High.cur_system then
|
1114
|
+
# raise "Cannot read from a port external of current system for channel " + self.name
|
1115
|
+
# end
|
1116
|
+
# # Performs the read.
|
1117
|
+
# self.read_port.read(*args,&ruby_block)
|
1118
|
+
# end
|
1119
|
+
#
|
1120
|
+
# ## Performs a write on the channel using +args+ and +ruby_block+
|
1121
|
+
# # as arguments.
|
1122
|
+
# # NOTE:
|
1123
|
+
# # * Will generate a port if not present.
|
1124
|
+
# # * Will generate an error if a read is tempted while the read
|
1125
|
+
# # port has been declared within another system.
|
1126
|
+
# def write(*args,&ruby_block)
|
1127
|
+
# # Is there a port to write?
|
1128
|
+
# unless self.write_port then
|
1129
|
+
# # No, generate a new one.
|
1130
|
+
# # Is it possible to be inout?
|
1131
|
+
# if self.inout? then
|
1132
|
+
# # Yes, create an inout port.
|
1133
|
+
# self.inout(HDLRuby.uniq_name)
|
1134
|
+
# else
|
1135
|
+
# # No, create an output port.
|
1136
|
+
# self.output(HDLRuby.uniq_name)
|
1137
|
+
# end
|
1138
|
+
# end
|
1139
|
+
# # Ensure the write port is within current system.
|
1140
|
+
# unless self.write_port.scope.system != HDLRuby::High.cur_system then
|
1141
|
+
# raise "Cannot write from a port external of current system for channel " + self.name
|
1142
|
+
# end
|
1143
|
+
# # Performs the write.
|
1144
|
+
# self.write_port.write(*args,&ruby_block)
|
1145
|
+
# end
|
1146
|
+
#
|
1147
|
+
|
1148
|
+
# ## Performs a reset on the channel using +args+ and +ruby_block+
|
1149
|
+
# # as arguments.
|
1150
|
+
# def reset(*args,&ruby_block)
|
1151
|
+
# # Gain access to the writer as local variable.
|
1152
|
+
# reseter_proc = @inout_reseter_proc
|
1153
|
+
# # # The context is the one of the writer.
|
1154
|
+
# # Execute the code generating the writer in context.
|
1155
|
+
# HDLRuby::High.space_push(@namespace)
|
1156
|
+
# HDLRuby::High.cur_block.open do
|
1157
|
+
# instance_exec(ruby_block,*args,&reseter_proc)
|
1158
|
+
# end
|
1159
|
+
# HDLRuby::High.space_pop
|
1160
|
+
# end
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
# Describes channel instance wrapper (Box) for fixing arugments.
|
1164
|
+
class ChannelB
|
1165
|
+
include HDLRuby::High::Hmissing
|
1166
|
+
include HchannelI
|
1167
|
+
|
1168
|
+
# Create a new channel box over +channelI+ channel instance using
|
1169
|
+
# +args+ for fixing the arguments as follows:
|
1170
|
+
# It can also be three lists for seperate read, write and access
|
1171
|
+
# procedures using named arguments as:
|
1172
|
+
# read: <read arguments>, write: <write arguments>,
|
1173
|
+
# access: <access arguments>
|
1174
|
+
def initialize(channelI,*args)
|
1175
|
+
# Ensure port is a channel port.
|
1176
|
+
unless channelI.is_a?(ChannelI) || channel.is_a?(ChannelB)
|
1177
|
+
raise "Invalid class for a channel instance: #{ch.class}"
|
1023
1178
|
end
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1179
|
+
@channelI = channelI
|
1180
|
+
# Process the arguments.
|
1181
|
+
if args.size == 1 && args[0].is_a?(Hash) then
|
1182
|
+
# Read, write and access are separated.
|
1183
|
+
@args_read = args[0][:read]
|
1184
|
+
@args_write = args[0][:write]
|
1185
|
+
@args_access = args[0][:access]
|
1186
|
+
else
|
1187
|
+
@args_read = args
|
1188
|
+
@args_write = args.clone
|
1189
|
+
@args_access = args.clone
|
1027
1190
|
end
|
1028
|
-
# Performs the read.
|
1029
|
-
self.read_port.read(*args,&ruby_block)
|
1030
1191
|
end
|
1192
|
+
|
1193
|
+
# Delegates to the boxed channel instance.
|
1194
|
+
|
1195
|
+
# The name of the channel instance.
|
1196
|
+
def name
|
1197
|
+
return @channelI.name
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
# The scope the channel has been created in.
|
1201
|
+
def scope
|
1202
|
+
return @channelI.scope
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
# The namespace associated with the current execution when
|
1206
|
+
# building a channel.
|
1207
|
+
def namespace
|
1208
|
+
return @channelI.namespace
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
# The read port if any.
|
1212
|
+
def read_port
|
1213
|
+
return @read_port
|
1214
|
+
end
|
1215
|
+
|
1216
|
+
# The write port if any.
|
1217
|
+
def write_port
|
1218
|
+
return @write_port
|
1219
|
+
end
|
1220
|
+
|
1221
|
+
# Methods used on the channel outside its definition.
|
1031
1222
|
|
1032
|
-
|
1033
|
-
#
|
1034
|
-
#
|
1035
|
-
# *
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1223
|
+
# Gets branch channel +name+.
|
1224
|
+
# NOTE:
|
1225
|
+
# * +name+ can be of any type on purpose.
|
1226
|
+
# * The wrapping arguments are not transmitted to the branch.
|
1227
|
+
def branch(name,*args)
|
1228
|
+
return @channelI.branch(name,*args)
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
## Tells if the channel support inout port.
|
1232
|
+
def inout?
|
1233
|
+
return @channelI.inout?
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
|
1237
|
+
# Reader, writer and accesser side.
|
1238
|
+
|
1239
|
+
## Declares the reader port as and assigned them to +name+.
|
1240
|
+
def input(name = nil)
|
1241
|
+
# Ensure name is a symbol.
|
1242
|
+
name = HDLRuby.uniq_name unless name
|
1243
|
+
name = name.to_sym
|
1244
|
+
# Ensure the port is not already existing.
|
1245
|
+
if @read_port then
|
1246
|
+
raise "Read port already declared for channel instance: " +
|
1247
|
+
self.name
|
1050
1248
|
end
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1249
|
+
|
1250
|
+
# Create a read port for the encaspulted channel.
|
1251
|
+
real_port = @channelI.read_port
|
1252
|
+
real_port = @channelI.input unless real_port
|
1253
|
+
|
1254
|
+
# Wrap it to a new port using.
|
1255
|
+
chp = real_port.wrap(read: @args_read)
|
1256
|
+
|
1257
|
+
HDLRuby::High.space_reg(name) { chp }
|
1258
|
+
# Save the port in the channe to avoid conflicting declaration.
|
1259
|
+
@read_port = chp
|
1260
|
+
return chp
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
## Declares the ports for the writer and assigned them to +name+.
|
1264
|
+
def output(name = nil)
|
1265
|
+
# Ensure name is a symbol.
|
1266
|
+
name = HDLRuby.uniq_name unless name
|
1267
|
+
name = name.to_sym
|
1268
|
+
# Ensure the port is not already existing.
|
1269
|
+
if @write_port then
|
1270
|
+
raise "Read port already declared for channel instance: " +
|
1271
|
+
self.name
|
1054
1272
|
end
|
1055
|
-
|
1056
|
-
|
1273
|
+
|
1274
|
+
# Create a write port for the encaspulted channel.
|
1275
|
+
real_port = @channelI.write_port
|
1276
|
+
real_port = @channelI.output unless real_port
|
1277
|
+
|
1278
|
+
# Wrap it to a new port using.
|
1279
|
+
chp = real_port.wrap(write: @args_write)
|
1280
|
+
|
1281
|
+
HDLRuby::High.space_reg(name) { chp }
|
1282
|
+
# Save the port in the channe to avoid conflicting declaration.
|
1283
|
+
@write_port = chp
|
1284
|
+
return chp
|
1057
1285
|
end
|
1058
|
-
|
1059
1286
|
|
1060
|
-
|
1061
|
-
|
1062
|
-
def
|
1063
|
-
#
|
1064
|
-
|
1065
|
-
|
1066
|
-
#
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1287
|
+
|
1288
|
+
## Declares the accesser port and assigned them to +name+.
|
1289
|
+
def inout(name = nil)
|
1290
|
+
# Ensure name is a symbol.
|
1291
|
+
name = HDLRuby.uniq_name unless name
|
1292
|
+
name = name.to_sym
|
1293
|
+
# Ensure the port is not already existing.
|
1294
|
+
if @read_port then
|
1295
|
+
raise "Read port already declared for channel instance: " +
|
1296
|
+
self.name
|
1070
1297
|
end
|
1071
|
-
|
1298
|
+
if @write_port then
|
1299
|
+
raise "Write port already declared for channel instance: " +
|
1300
|
+
self.name
|
1301
|
+
end
|
1302
|
+
|
1303
|
+
# Create a write port for the encaspulted channel.
|
1304
|
+
if @channelI.read_port == @channelI.write_port then
|
1305
|
+
real_port = @channelI.read_port
|
1306
|
+
real_port = @channelI.inout unless real_port
|
1307
|
+
else
|
1308
|
+
raise "Inout port not supported for channel #{@channelI}"
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
# Wrap it to a new port using.
|
1312
|
+
chp = real_port.wrap(read: @args_read, write: @args_write)
|
1313
|
+
|
1314
|
+
HDLRuby::High.space_reg(name) { chp }
|
1315
|
+
# Save the port in the channe to avoid conflicting declaration.
|
1316
|
+
@write_port = chp
|
1317
|
+
@read_port = chp
|
1318
|
+
return chp
|
1072
1319
|
end
|
1320
|
+
|
1073
1321
|
end
|
1074
1322
|
|
1075
1323
|
|
data/lib/HDLRuby/std/linear.rb
CHANGED
@@ -214,6 +214,14 @@ module HDLRuby::High::Std
|
|
214
214
|
par(ev) do
|
215
215
|
ack <= 0
|
216
216
|
run <= 0
|
217
|
+
hif(~run) do
|
218
|
+
rvok <= 0
|
219
|
+
lefts.each_with_index do |left,i|
|
220
|
+
lvoks[i] <= 0
|
221
|
+
# accs[i].write(0)
|
222
|
+
avs[i] <= 0
|
223
|
+
end
|
224
|
+
end
|
217
225
|
hif(req | run) do
|
218
226
|
run <= 1
|
219
227
|
# Computation request.
|
@@ -232,14 +240,14 @@ module HDLRuby::High::Std
|
|
232
240
|
end
|
233
241
|
end
|
234
242
|
end
|
235
|
-
helse do
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
end
|
243
|
+
# helse do
|
244
|
+
# rvok <= 0
|
245
|
+
# lefts.each_with_index do |left,i|
|
246
|
+
# lvoks[i] <= 0
|
247
|
+
# # accs[i].write(0)
|
248
|
+
# avs[i] <= 0
|
249
|
+
# end
|
250
|
+
# end
|
243
251
|
end
|
244
252
|
end
|
245
253
|
|
data/lib/HDLRuby/std/memory.rb
CHANGED
@@ -568,7 +568,7 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
|
|
568
568
|
# using +target+ as target of access result.
|
569
569
|
writer do |blk,target|
|
570
570
|
# On reset the read trigger is 0.
|
571
|
-
rst
|
571
|
+
rst = send(rst_name)
|
572
572
|
top_block.unshift do
|
573
573
|
# Initialize the address so that the next access is at address 0.
|
574
574
|
hif(rst == 1) { abus_w <= -1 }
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|