HDLRuby 2.2.13 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -8
- data/lib/HDLRuby/hdr_samples/linear_test.rb +235 -0
- data/lib/HDLRuby/hdr_samples/memory_test.rb +272 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +2 -2
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +96 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +3 -2
- data/lib/HDLRuby/hdr_samples/with_linear.rb +166 -0
- data/lib/HDLRuby/hdr_samples/with_loop.rb +69 -0
- data/lib/HDLRuby/hdr_samples/with_memory.rb +13 -3
- data/lib/HDLRuby/hdrcc.rb +1 -1
- data/lib/HDLRuby/hruby_high.rb +12 -4
- data/lib/HDLRuby/hruby_low.rb +25 -28
- data/lib/HDLRuby/hruby_low2c.rb +10 -5
- data/lib/HDLRuby/hruby_low2high.rb +1 -1
- data/lib/HDLRuby/hruby_low2vhd.rb +63 -48
- data/lib/HDLRuby/hruby_low_fix_types.rb +4 -2
- data/lib/HDLRuby/hruby_low_mutable.rb +2 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +7 -4
- data/lib/HDLRuby/hruby_low_without_concat.rb +8 -4
- data/lib/HDLRuby/hruby_types.rb +82 -72
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +21 -0
- data/lib/HDLRuby/sim/hruby_sim_calc.c +254 -18
- data/lib/HDLRuby/std/channel.rb +140 -40
- data/lib/HDLRuby/std/fixpoint.rb +15 -6
- data/lib/HDLRuby/std/linear.rb +317 -0
- data/lib/HDLRuby/std/loop.rb +101 -0
- data/lib/HDLRuby/std/memory.rb +1159 -45
- data/lib/HDLRuby/std/task.rb +850 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +10 -2
data/lib/HDLRuby/hruby_low2c.rb
CHANGED
@@ -546,9 +546,10 @@ module HDLRuby::Low
|
|
546
546
|
#
|
547
547
|
# NOTE: type tuples are converted to bit vector of their contents.
|
548
548
|
def to_c(level = 0)
|
549
|
-
return "get_type_tuple(#{self.each.join(",") do |type|
|
550
|
-
|
551
|
-
end})"
|
549
|
+
# return "get_type_tuple(#{self.each.to_a.join(",") do |type|
|
550
|
+
# type.to_c(level+1)
|
551
|
+
# end})"
|
552
|
+
return self.to_vector.to_c(level)
|
552
553
|
end
|
553
554
|
end
|
554
555
|
|
@@ -1872,7 +1873,8 @@ module HDLRuby::Low
|
|
1872
1873
|
res << "idx = value2integer(#{self.index.to_c(level+2)});\n"
|
1873
1874
|
# Make the access.
|
1874
1875
|
res << (" " * ((level+1)*3))
|
1875
|
-
res << "dst = read_range(ref,idx,idx,#{self.ref.type.base.to_c(level)},dst);\n"
|
1876
|
+
# res << "dst = read_range(ref,idx,idx,#{self.ref.type.base.to_c(level)},dst);\n"
|
1877
|
+
res << "dst = read_range(ref,idx,idx,#{self.type.to_c(level)},dst);\n"
|
1876
1878
|
# Restore the state of the value pool.
|
1877
1879
|
res << (" " * ((level+1)*3))
|
1878
1880
|
res << "set_value_pos(pool_state);\n"
|
@@ -1930,7 +1932,9 @@ module HDLRuby::Low
|
|
1930
1932
|
res << "last = value2integer(#{self.range.last.to_c(level+2)});\n"
|
1931
1933
|
# Make the access.
|
1932
1934
|
res << (" " * ((level+1)*3))
|
1933
|
-
res << "dst = #{command}_range(ref,first,last,#{self.ref.type.base.to_c(level)},dst);\n"
|
1935
|
+
# res << "dst = #{command}_range(ref,first,last,#{self.ref.type.base.to_c(level)},dst);\n"
|
1936
|
+
# puts "will read_range for #{self.ref.name} with width=#{self.ref.type.width} with base width=#{self.ref.type.base.width} with range=#{self.ref.type.range} with range=#{self.range.first.content}..#{self.range.last.content}"
|
1937
|
+
res << "dst = #{command}_range(ref,first,last,#{self.type.base.to_c(level)},dst);\n"
|
1934
1938
|
# Restore the state of the value pool.
|
1935
1939
|
res << (" " * ((level+1)*3))
|
1936
1940
|
res << "set_value_pos(pool_state);\n"
|
@@ -1961,6 +1965,7 @@ module HDLRuby::Low
|
|
1961
1965
|
# Generates the C text for reference as left value to a signal.
|
1962
1966
|
# +level+ is the hierarchical level of the object.
|
1963
1967
|
def to_c_signal(level = 0)
|
1968
|
+
# puts "to_c_signal with self=#{self.name}, resolve=#{self.resolve}"
|
1964
1969
|
return "#{self.resolve.to_c_signal(level+1)}"
|
1965
1970
|
end
|
1966
1971
|
end
|
@@ -345,31 +345,34 @@ module HDLRuby::Low
|
|
345
345
|
res << " " * (level*3)
|
346
346
|
res << "entity #{Low2VHDL.entity_name(self.name)} is\n"
|
347
347
|
# The ports
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
348
|
+
if self.each_input.any? || self.each_output.any? ||
|
349
|
+
self.each_inout.any? then
|
350
|
+
res << " " * ((level+1)*3)
|
351
|
+
res << "port (\n"
|
352
|
+
# Inputs
|
353
|
+
self.each_input do |input|
|
354
|
+
res << " " * ((level+2)*3)
|
355
|
+
res << Low2VHDL.vhdl_name(input.name) << ": in "
|
356
|
+
res << input.type.to_vhdl << ";\n"
|
357
|
+
end
|
358
|
+
# Outputs
|
359
|
+
self.each_output do |output|
|
360
|
+
res << " " * ((level+2)*3)
|
361
|
+
res << Low2VHDL.vhdl_name(output.name) << ": out "
|
362
|
+
res << output.type.to_vhdl << ";\n"
|
363
|
+
end
|
364
|
+
# Inouts
|
365
|
+
self.each_inout do |inout|
|
366
|
+
res << " " * ((level+2)*3)
|
367
|
+
res << Low2VHDL.vhdl_name(inout.name) << ": inout "
|
368
|
+
res << inout.type.to_vhdl << ";\n"
|
369
|
+
end
|
370
|
+
# Remove the last ";" for conforming with VHDL syntax.
|
371
|
+
res[-2..-1] = "\n" if res[-2] == ";"
|
372
|
+
res << " " * ((level+1)*3)
|
373
|
+
# Close the port declaration.
|
374
|
+
res << ");\n"
|
367
375
|
end
|
368
|
-
# Remove the last ";" for conforming with VHDL syntax.
|
369
|
-
res[-2..-1] = "\n" if res[-2] == ";"
|
370
|
-
res << " " * ((level+1)*3)
|
371
|
-
# Close the port declaration.
|
372
|
-
res << ");\n"
|
373
376
|
# Close the entity
|
374
377
|
res << " " * (level*3)
|
375
378
|
res << "end #{Low2VHDL.entity_name(self.name)};\n\n"
|
@@ -617,7 +620,17 @@ module HDLRuby::Low
|
|
617
620
|
# # Simply generates the redefined type.
|
618
621
|
# return self.def.to_vhdl(level)
|
619
622
|
# Simply use the name of the type.
|
620
|
-
|
623
|
+
# Is it a composite type?
|
624
|
+
if (self.def.is_a?(TypeStruct) ||
|
625
|
+
(self.def.is_a?(TypeVector) &&
|
626
|
+
(self.def.base.is_a?(TypeVector) ||
|
627
|
+
self.def.base.is_a?(TypeStruct))))
|
628
|
+
# Yes, generate a VHDL type definition.
|
629
|
+
return Low2VHDL.vhdl_name(self.name)
|
630
|
+
else
|
631
|
+
# No, generates the defined type.
|
632
|
+
return self.def.to_vhdl(level)
|
633
|
+
end
|
621
634
|
end
|
622
635
|
end
|
623
636
|
|
@@ -745,29 +758,31 @@ module HDLRuby::Low
|
|
745
758
|
res << Low2VHDL.vhdl_name(self.block.name) << ": "
|
746
759
|
end
|
747
760
|
res << "process "
|
748
|
-
# Generate the senitivity list.
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
761
|
+
# Generate the senitivity list if not a timed block.
|
762
|
+
unless self.block.is_a?(TimeBlock) then
|
763
|
+
if self.each_event.any? then
|
764
|
+
# If there is a clock.
|
765
|
+
res << "("
|
766
|
+
res << self.each_event.map do |event|
|
767
|
+
event.ref.to_vhdl(level)
|
768
|
+
end.join(", ")
|
769
|
+
res << ")"
|
770
|
+
else
|
771
|
+
# If no clock, generate the sensitivity list from the right
|
772
|
+
# values.
|
773
|
+
list = self.block.each_node_deep.select do |node|
|
774
|
+
node.is_a?(RefName) && !node.leftvalue? &&
|
775
|
+
!node.parent.is_a?(RefName) &&
|
776
|
+
# Also skip the variables
|
777
|
+
!vars.find {|var| var.name == node.name }
|
778
|
+
end.to_a
|
779
|
+
# Keep only one ref per signal.
|
780
|
+
list.uniq! { |node| node.name }
|
781
|
+
# Generate the sensitivity list from it.
|
782
|
+
res << "("
|
783
|
+
res << list.map {|node| node.to_vhdl(level) }.join(", ")
|
784
|
+
res << ")"
|
785
|
+
end
|
771
786
|
end
|
772
787
|
res << "\n"
|
773
788
|
# Generate the variables.
|
@@ -302,14 +302,16 @@ module HDLRuby::Low
|
|
302
302
|
end)
|
303
303
|
else
|
304
304
|
# No, it should be a tuple.
|
305
|
-
return Concat.new(type,
|
305
|
+
return Concat.new(type,
|
306
|
+
self.each_expression.map.with_index do
|
306
307
|
|expr,i|
|
307
308
|
expr.explicit_types(type.get_type(i))
|
308
309
|
end)
|
309
310
|
end
|
310
311
|
else
|
311
312
|
# No, recurse on the sub expressions.
|
312
|
-
return Concat.new(self.type,
|
313
|
+
return Concat.new(self.type,
|
314
|
+
self.each_expression.map do |expr|
|
313
315
|
expr.explicit_types
|
314
316
|
end)
|
315
317
|
end
|
@@ -1069,7 +1069,8 @@ module HDLRuby::Low
|
|
1069
1069
|
node2rep = node2reassign.map {|n,r| [n,r[0]] }.to_h
|
1070
1070
|
|
1071
1071
|
# First recurse on the sub blocks.
|
1072
|
-
self.each_block { |block| block.reassign_expressions!(node2rep) }
|
1072
|
+
# self.each_block { |block| block.reassign_expressions!(node2rep) }
|
1073
|
+
self.each_block { |block| block.reassign_expressions!(node2reassign) }
|
1073
1074
|
|
1074
1075
|
# Now work on the block.
|
1075
1076
|
# Replace on the statements.
|
@@ -39,6 +39,7 @@ module HDLRuby::Low
|
|
39
39
|
## Find an inner object by +name+.
|
40
40
|
# NOTE: return nil if not found.
|
41
41
|
def get_by_name(name)
|
42
|
+
# puts "getbyname for name=#{name} with self=#{self}"
|
42
43
|
# Ensure the name is a symbol.
|
43
44
|
name = name.to_sym
|
44
45
|
# Look in the signals.
|
@@ -90,7 +91,7 @@ module HDLRuby::Low
|
|
90
91
|
|
91
92
|
## Tells if it is a reference to a systemI signal.
|
92
93
|
def from_systemI?
|
93
|
-
return self.ref.from_systemI
|
94
|
+
return self.ref.from_systemI?
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
@@ -102,7 +103,7 @@ module HDLRuby::Low
|
|
102
103
|
|
103
104
|
## Tells if it is a reference to a systemI signal.
|
104
105
|
def from_systemI?
|
105
|
-
return self.ref.from_systemI
|
106
|
+
return self.ref.from_systemI?
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
@@ -114,16 +115,17 @@ module HDLRuby::Low
|
|
114
115
|
|
115
116
|
## Tells if it is a reference to a systemI signal.
|
116
117
|
def from_systemI?
|
117
|
-
# puts "from_systemI? for #{self.name}"
|
118
118
|
# Look for the owner from the name hierarchy.
|
119
119
|
if self.ref.is_a?(RefName) then
|
120
120
|
# Look in the parent hierachy for the sub reference name.
|
121
121
|
parent = self.parent
|
122
|
+
# puts "self.ref.name=#{self.ref.name}"
|
122
123
|
while parent
|
124
|
+
# puts "parent=#{parent}"
|
123
125
|
if parent.respond_to?(:get_by_name) then
|
124
126
|
found = parent.get_by_name(self.ref.name)
|
125
127
|
# puts "found is a :#{found.class}"
|
126
|
-
return found.is_a?(SystemI)
|
128
|
+
return found.is_a?(SystemI) if found
|
127
129
|
end
|
128
130
|
parent = parent.parent
|
129
131
|
end
|
@@ -151,6 +153,7 @@ module HDLRuby::Low
|
|
151
153
|
parent = self.parent
|
152
154
|
# puts "parent=#{parent}"
|
153
155
|
while parent
|
156
|
+
# puts "parent=#{parent}"
|
154
157
|
if parent.respond_to?(:get_by_name) then
|
155
158
|
found = parent.get_by_name(self.name)
|
156
159
|
return found if found
|
@@ -187,11 +187,13 @@ module HDLRuby::Low
|
|
187
187
|
# Generate the assignment.
|
188
188
|
block.add_statement(
|
189
189
|
Transmit.new(ref.clone,
|
190
|
-
RefIndex.new(aux.type.base, aux.clone, idx)))
|
190
|
+
# RefIndex.new(aux.type.base, aux.clone, idx)))
|
191
|
+
RefIndex.new(bit, aux.clone, idx)))
|
191
192
|
else
|
192
193
|
# Multi-bits.
|
193
194
|
# Compute the type of the right value.
|
194
|
-
rtype = TypeVector.new(:"",aux.type.base,range)
|
195
|
+
# rtype = TypeVector.new(:"",aux.type.base,range)
|
196
|
+
rtype = TypeVector.new(:"",bit,range)
|
195
197
|
# Generate the range.
|
196
198
|
range = Value.new(Integer,range.first) ..
|
197
199
|
Value.new(Integer,range.last)
|
@@ -272,11 +274,13 @@ module HDLRuby::Low
|
|
272
274
|
# Generate the assignment.
|
273
275
|
block.add_statement(
|
274
276
|
Transmit.new(ref.clone,
|
275
|
-
RefIndex.new(aux.type.base, aux.clone, idx)))
|
277
|
+
# RefIndex.new(aux.type.base, aux.clone, idx)))
|
278
|
+
RefIndex.new(bit, aux.clone, idx)))
|
276
279
|
else
|
277
280
|
# Multi-bits.
|
278
281
|
# Compute the type of the right value.
|
279
|
-
rtype = TypeVector.new(:"",aux.type.base,range)
|
282
|
+
# rtype = TypeVector.new(:"",aux.type.base,range)
|
283
|
+
rtype = TypeVector.new(:"",bit,range)
|
280
284
|
# Generate the range.
|
281
285
|
range = Value.new(Integer,range.first) ..
|
282
286
|
Value.new(Integer,range.last)
|
data/lib/HDLRuby/hruby_types.rb
CHANGED
@@ -76,19 +76,21 @@ module HDLRuby
|
|
76
76
|
|
77
77
|
# Addition.
|
78
78
|
def +(type)
|
79
|
-
# Resolve the type class.
|
80
|
-
resolved = self.resolve(type)
|
81
|
-
# New type range: largest range + 1
|
82
|
-
bounds = [ self.range.first.to_i, type.range.first.to_i,
|
83
|
-
|
84
|
-
res_lsb = bounds.min
|
85
|
-
res_msb = bounds.max + 1
|
86
|
-
# Create and return the new type: its endianess is the one of self
|
87
|
-
if self.range.first.to_i > self.range.last.to_i then
|
88
|
-
|
89
|
-
else
|
90
|
-
|
91
|
-
end
|
79
|
+
# # Resolve the type class.
|
80
|
+
# resolved = self.resolve(type)
|
81
|
+
# # New type range: largest range + 1
|
82
|
+
# bounds = [ self.range.first.to_i, type.range.first.to_i,
|
83
|
+
# self.range.last.to_i, type.range.last.to_i ]
|
84
|
+
# res_lsb = bounds.min
|
85
|
+
# res_msb = bounds.max + 1
|
86
|
+
# # Create and return the new type: its endianess is the one of self
|
87
|
+
# if self.range.first.to_i > self.range.last.to_i then
|
88
|
+
# return resolved.make(:"",resolved.base,res_msb..res_lsb)
|
89
|
+
# else
|
90
|
+
# return resolved.make(:"",resolved.base,res_lsb..res_msb)
|
91
|
+
# end
|
92
|
+
# The result is the resolve result now!
|
93
|
+
return self.resolve(type)
|
92
94
|
end
|
93
95
|
|
94
96
|
# Subtraction
|
@@ -96,36 +98,40 @@ module HDLRuby
|
|
96
98
|
|
97
99
|
# Multiplication
|
98
100
|
def *(type)
|
99
|
-
# Resolve the type class.
|
100
|
-
resolved = self.resolve(type)
|
101
|
-
# New type range: largest range * 2
|
102
|
-
bounds = [ self.range.first.to_i, type.range.first.to_i,
|
103
|
-
|
104
|
-
res_lsb = bounds.min
|
105
|
-
res_msb = bounds.max * 2
|
106
|
-
# Create and return the new type: its endianess is the one of self
|
107
|
-
if self.range.first.to_i > self.range.last.to_i then
|
108
|
-
|
109
|
-
else
|
110
|
-
|
111
|
-
end
|
101
|
+
# # Resolve the type class.
|
102
|
+
# resolved = self.resolve(type)
|
103
|
+
# # New type range: largest range * 2
|
104
|
+
# bounds = [ self.range.first.to_i, type.range.first.to_i,
|
105
|
+
# self.range.last.to_i, type.range.last.to_i ]
|
106
|
+
# res_lsb = bounds.min
|
107
|
+
# res_msb = bounds.max * 2
|
108
|
+
# # Create and return the new type: its endianess is the one of self
|
109
|
+
# if self.range.first.to_i > self.range.last.to_i then
|
110
|
+
# return resolved.make(:"",resolved.base,res_msb..res_lsb)
|
111
|
+
# else
|
112
|
+
# return resolved.make(:"",resolved.base,res_lsb..res_msb)
|
113
|
+
# end
|
114
|
+
# The result is the resolve result now!
|
115
|
+
return self.resolve(type)
|
112
116
|
end
|
113
117
|
|
114
118
|
# Division
|
115
119
|
def /(type)
|
116
|
-
# Resolve the type class.
|
117
|
-
resolved = self.resolve(type)
|
118
|
-
# New type range: largest range
|
119
|
-
bounds = [ self.range.first.to_i, type.range.first.to_i,
|
120
|
-
|
121
|
-
res_lsb = bounds.min
|
122
|
-
res_msb = bounds.max
|
123
|
-
# Create and return the new type: its endianess is the one of self
|
124
|
-
if self.range.first.to_i > self.range.last.to_i then
|
125
|
-
|
126
|
-
else
|
127
|
-
|
128
|
-
end
|
120
|
+
# # Resolve the type class.
|
121
|
+
# resolved = self.resolve(type)
|
122
|
+
# # New type range: largest range
|
123
|
+
# bounds = [ self.range.first.to_i, type.range.first.to_i,
|
124
|
+
# self.range.last.to_i, type.range.last.to_i ]
|
125
|
+
# res_lsb = bounds.min
|
126
|
+
# res_msb = bounds.max
|
127
|
+
# # Create and return the new type: its endianess is the one of self
|
128
|
+
# if self.range.first.to_i > self.range.last.to_i then
|
129
|
+
# return resolved.make(:"",resolved.base,res_msb..res_lsb)
|
130
|
+
# else
|
131
|
+
# return resolved.make(:"",resolved.base,res_lsb..res_msb)
|
132
|
+
# end
|
133
|
+
# The result is the resolve result now!
|
134
|
+
return self.resolve(type)
|
129
135
|
end
|
130
136
|
|
131
137
|
# Modulo
|
@@ -151,26 +157,28 @@ module HDLRuby
|
|
151
157
|
|
152
158
|
# And
|
153
159
|
def &(type)
|
154
|
-
# puts "compute types with=#{self} and #{type}"
|
155
|
-
# Resolve the type class.
|
156
|
-
resolved = self.resolve(type)
|
157
|
-
|
158
|
-
# Logical operation on non-vector types are kept as is.
|
159
|
-
return resolved unless resolved.is_a?(TypeVector)
|
160
|
-
|
161
|
-
# Otherwise the range is computed.
|
162
|
-
# New type range: largest range
|
163
|
-
bounds = [ self.range.first.to_i, type.range.first.to_i,
|
164
|
-
|
165
|
-
# puts "bounds=#{bounds}"
|
166
|
-
res_lsb = bounds.min
|
167
|
-
res_msb = bounds.max
|
168
|
-
# Create and return the new type: its endianess is the one of self
|
169
|
-
if self.range.first.to_i > self.range.last.to_i then
|
170
|
-
|
171
|
-
else
|
172
|
-
|
173
|
-
end
|
160
|
+
# # puts "compute types with=#{self} and #{type}"
|
161
|
+
# # Resolve the type class.
|
162
|
+
# resolved = self.resolve(type)
|
163
|
+
#
|
164
|
+
# # Logical operation on non-vector types are kept as is.
|
165
|
+
# return resolved unless resolved.is_a?(TypeVector)
|
166
|
+
|
167
|
+
# # Otherwise the range is computed.
|
168
|
+
# # New type range: largest range
|
169
|
+
# bounds = [ self.range.first.to_i, type.range.first.to_i,
|
170
|
+
# self.range.last.to_i, type.range.last.to_i ]
|
171
|
+
# # puts "bounds=#{bounds}"
|
172
|
+
# res_lsb = bounds.min
|
173
|
+
# res_msb = bounds.max
|
174
|
+
# # Create and return the new type: its endianess is the one of self
|
175
|
+
# if self.range.first.to_i > self.range.last.to_i then
|
176
|
+
# return resolved.make(:"",resolved.base,res_msb..res_lsb)
|
177
|
+
# else
|
178
|
+
# return resolved.make(:"",resolved.base,res_lsb..res_msb)
|
179
|
+
# end
|
180
|
+
# The result is the resolve result now!
|
181
|
+
return self.resolve(type)
|
174
182
|
end
|
175
183
|
|
176
184
|
# Or
|
@@ -211,19 +219,21 @@ module HDLRuby
|
|
211
219
|
|
212
220
|
# Shift left
|
213
221
|
def <<(type)
|
214
|
-
# The result type is the type of left.
|
215
|
-
resolved = self
|
216
|
-
# New type range: 2**(type width) times self range
|
217
|
-
bounds = [ self.range.first.to_i, self.range.last.to_i ]
|
218
|
-
res_lsb = bounds.min
|
219
|
-
res_msb = bounds.max +
|
220
|
-
|
221
|
-
# Create and return the new type: its endianess is the one of self
|
222
|
-
if self.range.first.to_i > self.range.last.to_i then
|
223
|
-
|
224
|
-
else
|
225
|
-
|
226
|
-
end
|
222
|
+
# # The result type is the type of left.
|
223
|
+
# resolved = self
|
224
|
+
# # New type range: 2**(type width) times self range
|
225
|
+
# bounds = [ self.range.first.to_i, self.range.last.to_i ]
|
226
|
+
# res_lsb = bounds.min
|
227
|
+
# res_msb = bounds.max +
|
228
|
+
# (2 ** ((type.range.last-type.range.first).abs))
|
229
|
+
# # Create and return the new type: its endianess is the one of self
|
230
|
+
# if self.range.first.to_i > self.range.last.to_i then
|
231
|
+
# return resolved.make(:"",resolved.base,res_msb..res_lsb)
|
232
|
+
# else
|
233
|
+
# return resolved.make(:"",resolved.base,res_lsb..res_msb)
|
234
|
+
# end
|
235
|
+
# The result is the resolve result now!
|
236
|
+
return self.resolve(type)
|
227
237
|
end
|
228
238
|
|
229
239
|
alias_method :ls, :<<
|