Module: HDLRuby::High::RCSimBehavior
- Included in:
- Behavior, TimeBehavior
- Defined in:
- lib/HDLRuby/hruby_rcsim.rb
Overview
Module for extending the behavior classes for hybrid Ruby-C simulation.
Instance Attribute Summary collapse
-
#rcbehavior ⇒ Object
readonly
Returns the value of attribute rcbehavior.
Instance Method Summary collapse
-
#add_sub_events(type, sig) ⇒ Object
Add sub leaf events from +sig+ of +type+.
-
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the behavior comming from object whose C description is +rcowner+.
Instance Attribute Details
#rcbehavior ⇒ Object (readonly)
Returns the value of attribute rcbehavior.
300 301 302 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 300 def rcbehavior @rcbehavior end |
Instance Method Details
#add_sub_events(type, sig) ⇒ Object
Add sub leaf events from +sig+ of +type+.
303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 303 def add_sub_events(type,sig) if sig.each_signal.any? then # The event is hierarchical, recurse. sig.each_signal do |sub| self.add_sub_events(type,sub) end else # Te event is not hierarchical, add it. ref = RefObject.new(this,sig) self.add_event(Event.new(type,ref)) end end |
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the behavior comming from object whose C description is +rcowner+
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 318 def to_rcsim(rcowner) # puts "to_rcsim for behavior=#{self}" # Process the sensitivity list. # Is it a clocked behavior? events = self.each_event.to_a # puts "events=#{events.map {|ev| ev.ref.object.name }}" if !self.is_a?(TimeBehavior) && events.empty? then # No events, this is not a clock behavior. # And it is not a time behavior neigther. # Generate the events list from the right values. # First get the references. refs = self.block.each_node_deep.select do |node| node.is_a?(RefObject) && !node.leftvalue? && !node.parent.is_a?(RefObject) end.to_a # puts "refs=#{refs}" # Keep only one ref per signal. refs.uniq! { |node| node.fullname } # Remove the inner signals from the list. self.block.each_inner do |inner| refs.delete_if {|r| r.name == inner.name } end # The get the left references: the will be removed from the # events. left_refs = self.block.each_node_deep.select do |node| node.is_a?(RefObject) && node.leftvalue? && !node.parent.is_a?(RefObject) end.to_a # Keep only one left ref per signal. left_refs.uniq! { |node| node.fullname } # Remove the left refs. left_refs.each do |l| refs.delete_if {|r| r.fullname == l.fullname } end # Generate the event. events = refs.map {|ref| Event.new(:anyedge,ref.clone) } # Add them to the behavior for further processing. events.each {|event| self.add_event(event) } else # Maybe there are event on hierachical signals. events.each do |event| if event.ref.object.each_signal.any? then # This is a hierarchical event, remove it. self.delete_event!(event) # And replace it by event of the subs of the signal. self.add_sub_events(event.type,event.ref) end end end # Create the behavior C object. # puts "make behavior with self.class=#{self.class}" @rcbehavior = RCSim.rcsim_make_behavior(self.is_a?(TimeBehavior)) # Set the owner. RCSim.rcsim_set_owner(@rcbehavior,rcowner) # Create and add the events. if self.each_event.any? then RCSim.rcsim_add_behavior_events(@rcbehavior, self.each_event.map do |ev| ev.to_rcsim(@rcbehavior) end) end # Create and add the block. RCSim.rcsim_set_behavior_block(@rcbehavior,self.block.to_rcsim) return @rcbehavior end |