Class: HDLRuby::High::Behavior
- Inherits:
-
Low::Behavior
- Object
- Low::Behavior
- HDLRuby::High::Behavior
- Includes:
- RCSimBehavior
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb,
lib/HDLRuby/hruby_high_fullname.rb
Overview
Describes a behavior.
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes included from RCSimBehavior
Attributes inherited from Low::Behavior
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#execute(mode) ⇒ Object
Execute the expression.
-
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
-
#initialize(mode, *events, name: nil, &ruby_block) ⇒ Behavior
constructor
Creates a new behavior executing +block+ activated on a list of +events+, possible name (of main block) +name+ and built by executing +ruby_block+.
-
#to_low ⇒ Object
Converts the time behavior to HDLRuby::Low.
Methods included from RCSimBehavior
Methods inherited from Low::Behavior
#add_event, #blocks2seq!, #break_concat_assigns!, #delete_event!, #each_block, #each_block_deep, #each_deep, #each_event, #each_node_deep, #each_statement, #eql?, #explicit_types!, #extract_declares!, #fix_scope_refnames!, #get_by_name, #has_event?, #hash, #last_statement, #map_events!, #mixblocks2seq!, #on_edge?, #on_event?, #parent_system, #replace_names!, #reverse_each_statement, #set_block!, #signal2subs!, #to_c, #to_ch, #to_hdr, #to_high, #to_upper_space!, #to_vhdl, #top_scope, #with_boolean!, #with_var!
Methods included from Low::Low2Symbol
Methods included from Low::Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Constructor Details
#initialize(mode, *events, name: nil, &ruby_block) ⇒ Behavior
Creates a new behavior executing +block+ activated on a list of +events+, possible name (of main block) +name+ and built by executing +ruby_block+. +mode+ can be either :seq or :par for respectively sequential or parallel. def initialize(mode, *events, &ruby_block)
4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 |
# File 'lib/HDLRuby/hruby_high.rb', line 4613 def initialize(mode, *events, name: nil, &ruby_block) # Initialize the behavior with it. super(nil) # Add the events (they may be hierarchical to flatten) events.flatten.each { |event| self.add_event(event) } # Create and add the block. # self.block = High.make_block(mode,&ruby_block) self.block = High.make_block(mode,*name,&ruby_block) # # Unset the current behavior # @@cur_behavior = nil end |
Instance Method Details
#execute(mode) ⇒ Object
Execute the expression.
398 399 400 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 398 def execute(mode) return self.block.execute(mode) end |
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
460 461 462 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 460 def fullname return self.parent.fullname end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 403 def init_sim(systemT) # Add the behavior to the list of untimed objects. systemT.add_untimed(self) # Process the sensitivity list. # Is it a clocked behavior? events = self.each_event.to_a if 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 # Keep only one ref per signal. refs.uniq! { |node| node.fullname } # puts "refs=#{refs.map {|node| node.fullname}}" # 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 inner signals from the list. self.block.each_inner do |inner| refs.delete_if {|r| r.fullname == inner.fullname } end # 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) } end # Now process the events: add the behavior to the corresponding # activation list of the signals of the events. self.each_event do |event| sig = event.ref.object case event.type when :posedge sig.add_posedge(self) when :negedge sig.add_negedge(self) else sig.add_anyedge(self) end end # Now process the block. self.block.init_sim(systemT) end |
#to_low ⇒ Object
Converts the time behavior to HDLRuby::Low.
4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 |
# File 'lib/HDLRuby/hruby_high.rb', line 4630 def to_low # Create an empty low behavior for the result. behaviorL = HDLRuby::Low::Behavior.new # Then fill it. # Create the low level block. # blockL = self.block.to_low blockL = self.block.to_low(behaviorL) # Create the low level events. eventLs = self.each_event.map { |event| event.to_low } # # Create and return the resulting low level behavior. # behaviorL = HDLRuby::Low::Behavior.new(blockL) # # For debugging: set the source high object # behaviorL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = behaviorL eventLs.each(&behaviorL.method(:add_event)) return behaviorL end |