Class: Array
Overview
Extends the Array class for conversion to a high-level expression.
Direct Known Subclasses
Instance Method Summary collapse
-
#call(obj = nil, &ruby_block) ⇒ Object
Create an array whose number of elements is given by the content of the current array, filled by +obj+ objects.
-
#constant(hsh) ⇒ Object
Declares high-level inner constants named from +hsh+ with names and corresponding values.
-
#hcase(value, &ruby_block) ⇒ Object
Creates a hcase statement executing +ruby_block+ on the element of the array selected by +value+.
-
#inner(*names) ⇒ Object
Declares high-level inner signals named +names+ of the current type.
-
#inout(*names) ⇒ Object
Declares high-level untyped inout signals named +names+ of the current type.
-
#input(*names) ⇒ Object
Declares high-level input signals named +names+ of the current type.
-
#make(name, *args) ⇒ Object
Create an array of instances of system +name+, using +args+ as arguments.
-
#output(*names) ⇒ Object
Declares high-level untyped output signals named +names+ of the current type.
-
#to_expr ⇒ Object
Converts to a new high-level expression.
-
#to_ref ⇒ Object
Converts to a new high-level reference.
-
#to_type ⇒ Object
Converts to a new type.
-
#typedef(name) ⇒ Object
Declares a new type definition with +name+ equivalent to current one.
Instance Method Details
#call(obj = nil, &ruby_block) ⇒ Object
Create an array whose number of elements is given by the content of the current array, filled by +obj+ objects. If +obj+ is nil, +ruby_block+ is used instead for filling the array.
4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 |
# File 'lib/HDLRuby/hruby_high.rb', line 4099 def call(obj = nil, &ruby_block) unless self.size == 1 then raise AnyError, "Invalid array for call opertor." end number = self[0].to_i if obj then return Array.new(number,obj) else return Array.new(number,&ruby_block) end end |
#constant(hsh) ⇒ Object
Declares high-level inner constants named from +hsh+ with names and corresponding values.
4081 4082 4083 |
# File 'lib/HDLRuby/hruby_high.rb', line 4081 def constant(hsh) High.top_user.make_constants(self.to_type,hsh) end |
#hcase(value, &ruby_block) ⇒ Object
Creates a hcase statement executing +ruby_block+ on the element of the array selected by +value+
4087 4088 4089 4090 4091 4092 |
# File 'lib/HDLRuby/hruby_high.rb', line 4087 def hcase(value,&ruby_block) High.cur_block.hcase(value) self.each.with_index do |elem,i| High.cur_block.hwhen(i) { ruby_block.call(elem) } end end |
#inner(*names) ⇒ Object
Declares high-level inner signals named +names+ of the current type.
4075 4076 4077 |
# File 'lib/HDLRuby/hruby_high.rb', line 4075 def inner(*names) High.top_user.make_inners(self.to_type,*names) end |
#inout(*names) ⇒ Object
Declares high-level untyped inout signals named +names+ of the current type.
4069 4070 4071 |
# File 'lib/HDLRuby/hruby_high.rb', line 4069 def inout(*names) High.top_user.make_inouts(self.to_type,*names) end |
#input(*names) ⇒ Object
Declares high-level input signals named +names+ of the current type.
4057 4058 4059 |
# File 'lib/HDLRuby/hruby_high.rb', line 4057 def input(*names) High.top_user.make_inputs(self.to_type,*names) end |
#make(name, *args) ⇒ Object
Create an array of instances of system +name+, using +args+ as arguments.
NOTE: the array must have a single element that is an integer.
4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 |
# File 'lib/HDLRuby/hruby_high.rb', line 4115 def make(name,*args) # Check the array and get the number of elements. size = self[0] unless self.size == 1 and size.is_a?(::Integer) raise AnyError, "Invalid array for declaring a list of instances." end # Get the system to instantiate. systemT = High.space_call(name) # Get the name of the instance from the arguments. nameI = args.shift.to_s # Create the instances. instances = size.times.map do |i| systemT.instantiate((nameI + "[#{i}]").to_sym,*args) end nameI = nameI.to_sym # Add them to the top system High.space_top.user.add_groupI(nameI,*instances) # Register and return the result. High.space_reg(nameI) { High.space_top.user.get_groupI(nameI) } return High.space_top.user.get_groupI(nameI) end |
#output(*names) ⇒ Object
Declares high-level untyped output signals named +names+ of the current type.
4063 4064 4065 |
# File 'lib/HDLRuby/hruby_high.rb', line 4063 def output(*names) High.top_user.make_outputs(self.to_type,*names) end |
#to_expr ⇒ Object
Converts to a new high-level expression.
4018 4019 4020 4021 4022 4023 4024 4025 |
# File 'lib/HDLRuby/hruby_high.rb', line 4018 def to_expr # expr = Concat.new expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem| elem.to_expr.type end)) self.each {|elem| expr.add_expression(elem.to_expr) } expr end |
#to_ref ⇒ Object
Converts to a new high-level reference.
4028 4029 4030 4031 4032 4033 4034 4035 |
# File 'lib/HDLRuby/hruby_high.rb', line 4028 def to_ref # expr = RefConcat.new expr = RefConcat.new(TypeTuple.new(:"",:little,*self.map do |elem| elem.to_ref.type end)) self.each {|elem| expr.add_ref(elem.to_ref) } expr end |
#to_type ⇒ Object
Converts to a new type.
4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 |
# File 'lib/HDLRuby/hruby_high.rb', line 4038 def to_type if self.size == 1 and ( self[0].is_a?(Range) or self[0].respond_to?(:to_i) ) then # Vector type case return bit[*self] else # Tuple type case. return TypeTuple.new(:"",:little,*self) end end |
#typedef(name) ⇒ Object
Declares a new type definition with +name+ equivalent to current one.
4050 4051 4052 |
# File 'lib/HDLRuby/hruby_high.rb', line 4050 def typedef(name) return self.to_type.typedef(name) end |