Class: HDLRuby::High::TimeBehavior
- Inherits:
-
Low::TimeBehavior
- Object
- Low::Behavior
- Low::TimeBehavior
- HDLRuby::High::TimeBehavior
- 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 timed behavior.
NOTE:
- this is the only kind of behavior that can include time statements.
- this kind of behavior is not synthesizable!
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Get the id of the timed behavior.
-
#time ⇒ Object
Get the current time of the behavior.
Attributes included from RCSimBehavior
Attributes inherited from Low::Behavior
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
-
#initialize(mode, &ruby_block) ⇒ TimeBehavior
constructor
Creates a new timed behavior built by executing +ruby_block+.
-
#make_thread ⇒ Object
Create the execution thread.
-
#run ⇒ Object
(Re)start execution of the thread.
-
#to_low ⇒ Object
Converts the time behavior to HDLRuby::Low.
Methods included from RCSimBehavior
Methods inherited from Low::TimeBehavior
#add_event, #eql?, #hash, #set_block!, #to_c, #to_hdr, #to_high
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!, #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
#hierarchy, #no_parent!, #scope
Constructor Details
#initialize(mode, &ruby_block) ⇒ TimeBehavior
Creates a new timed behavior built by executing +ruby_block+. +mode+ can be either :seq or :par for respectively sequential or
4480 4481 4482 4483 4484 4485 |
# File 'lib/HDLRuby/hruby_high.rb', line 4480 def initialize(mode, &ruby_block) # Create a default par block for the behavior. block = High.make_time_block(mode,&ruby_block) # Initialize the behavior with it. super(block) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Get the id of the timed behavior.
476 477 478 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 476 def id @id end |
#time ⇒ Object
Get the current time of the behavior.
474 475 476 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 474 def time @time end |
Instance Method Details
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
54 55 56 |
# File 'lib/HDLRuby/hruby_high_fullname.rb', line 54 def fullname return self.parent.fullname end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
479 480 481 482 483 484 485 486 487 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 479 def init_sim(systemT) @sim = systemT # Add the behavior to the list of timed behavior. @id = systemT.add_timed_behavior(self) # Initialize the time to 0. @time = 0 # Initialize the statements. self.block.init_sim(systemT) end |
#make_thread ⇒ Object
Create the execution thread
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 490 def make_thread systemT = @sim @thread = Thread.new do # puts "In thread." # sleep systemT.run_init do begin # puts "Starting thread" systemT.run_req(@id) # self.block.execute(:par) self.block.execute(:seq) # puts "Ending thread" rescue => e puts "Got exception: #{e.}" end systemT.remove_timed_behavior(self) systemT.run_done(@id) end end end |
#run ⇒ Object
(Re)start execution of the thread.
512 513 514 515 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 512 def run # Run. @thread.run end |
#to_low ⇒ Object
Converts the time behavior to HDLRuby::Low.
4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 |
# File 'lib/HDLRuby/hruby_high.rb', line 4488 def to_low # Create the low level block. blockL = self.block.to_low # Create the low level events. eventLs = self.each_event.map { |event| event.to_low } # Create and return the resulting low level behavior. timeBehaviorL = HDLRuby::Low::TimeBehavior.new(blockL) # # For debugging: set the source high object # timeBehaviorL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = timeBehaviorL eventLs.each(&timeBehaviorL.method(:add_event)) return timeBehaviorL end |