Class: HDLRuby::High::Select
- Inherits:
-
Low::Select
- Object
- Low::Expression
- Low::Operation
- Low::Select
- HDLRuby::High::Select
- Includes:
- HExpression
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb
Overview
Describes a selection operation (generalization of the ternary operator).
NOTE: choice is using the value of +select+ as an index.
Constant Summary
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes included from HExpression
Attributes inherited from Low::Select
Attributes inherited from Low::Operation
Attributes inherited from Low::Expression
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#execute(mode) ⇒ Object
Execute the expression.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
-
#to_expr ⇒ Object
Converts to a new expression.
-
#to_low ⇒ Object
Converts the selection expression to HDLRuby::Low.
-
#to_rcsim ⇒ Object
Generate the C description of the select operation.
Methods included from HExpression
#<=>, #[], #as, #coerce, #constant?, #inout, #input, #ljust, #lr, #ls, #match_type, #mux, orig_operator, #orig_operator, #output, #rjust, #rr, #rs, #sdownto, #seach, #sext, #stimes, #supto, #to_bit, #to_signed, #to_unsigned, #to_value, #to_value?, #zext
Methods inherited from Low::Select
#add_choice, #boolean?, #boolean_in_assign2select, #casts_without_expression!, #clone, #delete_choice!, #each_choice, #each_deep, #each_node, #each_node_deep, #each_ref_deep, #eql?, #explicit_types, #get_choice, #hash, #immutable?, #initialize, #map_choices!, #map_nodes!, #replace_expressions!, #set_select!, #to_c, #to_hdr, #to_high, #to_verilog, #to_vhdl, #use_name?
Methods inherited from Low::Operation
#eql?, #explicit_types, #hash, #initialize, #set_operator!, #to_c, #to_hdr, #to_vhdl, #to_viz_node
Methods inherited from Low::Expression
#boolean?, #break_types!, #clone, #each_node, #each_node_deep, #each_ref_deep, #eql?, #explicit_types, #extract_selects_to!, #fix_scope_refnames!, #hash, #immutable?, #initialize, #leftvalue?, #map_nodes!, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #signal2subs!, #statement, #to_c, #to_c_expr, #to_hdr, #to_high, #to_vhdl, #to_viz_names, #use_name?
Methods included from Low::Low2Symbol
Methods included from Low::Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Constructor Details
This class inherits a constructor from HDLRuby::Low::Select
Instance Method Details
#execute(mode) ⇒ Object
Execute the expression.
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1147 def execute(mode) unless @mask then # Need to initialize the execution of the select. width = (@choices.size-1).width width = 1 if width == 0 @mask = 2**width - 1 @choices.concat([@choices[-1]] * (2**width-@choices.size)) end # Recurse on the select. tmps = self.select.execute(mode).to_i & @mask # puts "select tmps=#{tmps}, @choices.size=#{@choices.size}" # Recurse on the selection result. return @choices[tmps].execute(mode) end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
1140 1141 1142 1143 1144 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1140 def init_sim(systemT) # Recurse on the children. self.select.init_sim(systemT) self.each_choice { |choice| choice.init_sim(systemT) } end |
#to_expr ⇒ Object
Converts to a new expression.
3348 3349 3350 3351 3352 3353 |
# File 'lib/HDLRuby/hruby_high.rb', line 3348 def to_expr return Select.new(self.type,"?",self.select.to_expr, *self.each_choice.map do |choice| choice.to_expr end) end |
#to_low ⇒ Object
Converts the selection expression to HDLRuby::Low.
3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 |
# File 'lib/HDLRuby/hruby_high.rb', line 3356 def to_low # return HDLRuby::Low::Select.new(self.type.to_low,"?", # self.select.to_low, # *self.each_choice.map do |choice| # choice.to_low # end) selectL = HDLRuby::Low::Select.new(self.type.to_low,"?", self.select.to_low, *self.each_choice.map do |choice| choice.to_low end) # # For debugging: set the source high object # selectL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = selectL return selectL end |
#to_rcsim ⇒ Object
Generate the C description of the select operation.
984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 984 def to_rcsim # Create the select C object. rcexpression = RCSim.rcsim_make_select(self.type.to_rcsim, self.select.to_rcsim) # Add the choice expressions. */ if self.each_choice.any? then RCSim.rcsim_add_select_choices(rcexpression, self.each_choice.map(&:to_rcsim)) end return rcexpression end |