Class: HDLRuby::High::Connection
- Inherits:
-
Low::Connection
- Object
- Low::Statement
- Low::Transmit
- Low::Connection
- HDLRuby::High::Connection
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb
Overview
Describes a connection.
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#rcbehavior ⇒ Object
readonly
Extends the Connection class for hybrid Ruby-C simulation.
Attributes inherited from Low::Transmit
Attributes included from Low::Hparent
Class Method Summary collapse
-
.add_rcevents(sig, rcevs, rcbehavior) ⇒ Object
Add recursively any event to
rcevsfor activativing the connection from signalsigattached torcbehavior.
Instance Method Summary collapse
-
#at(event) ⇒ Object
Creates a new behavior sensitive to
eventincluding the connection converted to a transmission, and replace the former by the new behavior. -
#execute(mode) ⇒ Object
Executes the statement.
-
#hif(condition) ⇒ Object
Creates a new behavior with an if statement from
conditionenclosing the connection converted to a transmission, and replace the former by the new behavior. -
#init_sim(systemT) ⇒ Object
Initialize the simulation for system
systemT. -
#to_expr ⇒ Object
Converts the connection to a comparison expression.
-
#to_low ⇒ Object
Converts the connection to HDLRuby::Low.
-
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the connection.
Methods inherited from Low::Connection
#array_connection, #break_concat_assigns, #eql?, #fix_scope_refnames!, #hash, #parent_system, #reassign_expressions!, #to_high, #to_verilog, #top_block, #top_scope
Methods inherited from Low::Transmit
#boolean_in_assign2select!, #break_concat_assigns, #casts_without_expression!, #clone, #each_block, #each_block_deep, #each_deep, #each_node, #each_node_deep, #each_statement_deep, #eql?, #explicit_types!, #extract_selects!, #fix_scope_refnames!, #hash, #initialize, #map_nodes!, #replace_expressions!, #set_left!, #set_right!, #signal2subs!, #to_c, #to_hdr, #to_high, #to_verilog, #to_vhdl, #to_viz_node, #use_name?
Methods inherited from Low::Statement
#add_blocks_code, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #clone, #delete_related!, #delete_unless!, #each_deep, #each_statement, #eql?, #explicit_types!, #extract_declares!, #fix_scope_refnames!, #get_signal_splits, #hash, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_c, #to_ch, #to_hdr, #to_high, #to_seq!, #to_upper_space!, #to_vhdl, #top_block, #top_scope, #use_name?, #with_boolean!
Methods included from Low::Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Methods included from Low::Low2Symbol
Constructor Details
This class inherits a constructor from HDLRuby::Low::Transmit
Instance Attribute Details
#rcbehavior ⇒ Object (readonly)
Extends the Connection class for hybrid Ruby-C simulation.
832 833 834 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 832 def rcbehavior @rcbehavior end |
Class Method Details
.add_rcevents(sig, rcevs, rcbehavior) ⇒ Object
Add recursively any event to rcevs for activativing the
connection from signal sig attached to rcbehavior
836 837 838 839 840 841 842 843 844 845 846 847 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 836 def self.add_rcevents(sig,rcevs,rcbehavior) # puts "add_rcevents for sig=#{sig.fullname}" # Recurse on sub signals if any. sig.each_signal do |sub| Connection.add_rcevents(sub,rcevs,rcbehavior) end # Apply on the current node. rcsig = sig.is_a?(SignalI) ? sig.rcsignalI : sig.rcsignalC ev = RCSim.rcsim_make_event(:anyedge,rcsig) RCSim.rcsim_set_owner(ev,rcbehavior) rcevs << ev end |
Instance Method Details
#at(event) ⇒ Object
Creates a new behavior sensitive to event including the connection
converted to a transmission, and replace the former by the new
behavior.
4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 |
# File 'lib/HDLRuby/hruby_high.rb', line 4198 def at(event) # Creates the behavior. left, right = self.left, self.right # Detached left and right from their connection since they will # be put in a new behavior instead. left.parent = right.parent = nil # Create the new behavior replacing the connection. behavior = Behavior.new(:par,event) do left <= right end # Adds the behavior. High.top_user.add_behavior(behavior) # Remove the connection High.top_user.delete_connection!(self) end |
#execute(mode) ⇒ Object
Executes the statement.
1009 1010 1011 1012 1013 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1009 def execute(mode) # puts "connection left=#{left.object.fullname}" # self.left.assign(mode,self.right.execute(mode)) self.left.assign(:seq,self.right.execute(mode)) end |
#hif(condition) ⇒ Object
Creates a new behavior with an if statement from condition
enclosing the connection converted to a transmission, and replace the
former by the new behavior.
NOTE: the else part is defined through the helse method.
4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 |
# File 'lib/HDLRuby/hruby_high.rb', line 4223 def hif(condition) # Handles the metaprogramming. if self.(condition,proc { left <= right }) then High.top_user.delete_connection!(self) return end # Creates the behavior. left, right = self.left, self.right # Detached left and right from their connection since they will # be put in a new behavior instead. left.parent = right.parent = nil # Create the new behavior replacing the connection. behavior = Behavior.new(:par) do hif(condition) do left <= right end end # Adds the behavior. High.top_user.add_behavior(behavior) # Remove the connection High.top_user.delete_connection!(self) end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system systemT.
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 981 def init_sim(systemT) # Add the connection to the list of untimed objets. systemT.add_untimed(self) # Recurse on the left and right. self.left.init_sim(systemT) self.right.init_sim(systemT) # Process the sensitivity list. # Is it a clocked behavior? events = [] # Generate the events list from the right values. # First get the references. refs = self.right.each_node_deep.select do |node| node.is_a?(RefObject) && !node.parent.is_a?(RefObject) end.to_a # Keep only one ref per signal. refs.uniq! { |node| node.fullname } # puts "connection input: #{self.left.fullname}" # puts "connection refs=#{refs.map {|node| node.fullname}}" # # Generate the event. # events = refs.map {|ref| Event.new(:anyedge,ref) } # # Add them to the behavior for further processing. # events.each {|event| self.add_event(event) } # Now process the events: add the connection to the corresponding # activation list of the signals of the events. refs.each {|ref| ref.object.add_anyedge(self) } end |
#to_expr ⇒ Object
Converts the connection to a comparison expression.
NOTE: required because the <= operator is ambigous and by default produces a Transmit or a Connection.
4186 4187 4188 4189 4190 4191 4192 4193 |
# File 'lib/HDLRuby/hruby_high.rb', line 4186 def to_expr # Remove the connection from the system type. High.top_user.delete_connection!(self) self.left.no_parent! self.right.no_parent! # Generate an expression. return Binary.new(self.left.type,:<=,self.left,self.right) end |
#to_low ⇒ Object
Converts the connection to HDLRuby::Low.
4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 |
# File 'lib/HDLRuby/hruby_high.rb', line 4248 def to_low # return HDLRuby::Low::Connection.new(self.left.to_low, # self.right.to_low) connectionL = HDLRuby::Low::Connection.new(self.left.to_low, self.right.to_low) # # For debugging: set the source high object # connectionL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = connectionL return connectionL end |
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the connection.
rcowner is a link to the C description of the owner scope.
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 851 def to_rcsim(rcowner) # puts "make behavior with self.class=#{self.class}" # Create the connection C object, actually it is a behavior. @rcbehavior = RCSim.rcsim_make_behavior(false) # Set the owner. RCSim.rcsim_set_owner(@rcbehavior,rcowner) # Create and add the events. rcevs = [] self.right.each_node_deep do |node| if node.is_a?(RefObject) && !node.parent.is_a?(RefObject) then Connection.add_rcevents(node.object,rcevs,@rcbehavior) # ev = RCSim.rcsim_make_event(:anyedge,node.to_rcsim) # RCSim.rcsim_set_owner(ev,@rcbehavior) # rcevs << ev end end if rcevs.any? then RCSim.rcsim_add_behavior_events(@rcbehavior,rcevs) end # Create and set the block. rcblock = RCSim.rcsim_make_block(:par) RCSim.rcsim_set_owner(rcblock,@rcbehavior) # puts "self.left=#{self.left} self.right=#{self.right}" RCSim.rcsim_add_block_statements(rcblock, [RCSim.rcsim_make_transmit(self.left.to_rcsim, self.right.to_rcsim)]) RCSim.rcsim_set_behavior_block(@rcbehavior,rcblock) return @rcbehavior end |