Class: HDLRuby::Low::TimeBehavior

Inherits:
Behavior
  • Object
show all
Defined in:
lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_skeleton.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!

Direct Known Subclasses

High::TimeBehavior

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary

Attributes inherited from Behavior

#block

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Behavior

#blocks2seq!, #delete_event!, #each_block, #each_block_deep, #each_deep, #each_event, #each_node_deep, #each_statement, #explicit_types!, #extract_declares!, #get_by_name, #has_event?, #last_statement, #map_events!, #mixblocks2seq!, #on_edge?, #on_event?, #parent_system, #replace_names!, #reverse_each_statement, #to_ch, #to_upper_space!, #to_vhdl, #top_scope, #with_boolean!, #with_var!

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

#initialize(block) ⇒ TimeBehavior

Creates a new time behavior executing +block+.



2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
# File 'lib/HDLRuby/hruby_low.rb', line 2378

def initialize(block)
    # Initialize the sensitivity list.
    @events = []
    # Check and set the block.
    unless block.is_a?(Block)
        raise AnyError, "Invalid class for a block: #{block.class}."
    end
    # Time blocks are supported here.
    @block = block
    block.parent = self
end

Instance Method Details

#add_event(event) ⇒ Object

Time behavior do not have other event than time, so deactivate the relevant methods.

Raises:



2405
2406
2407
# File 'lib/HDLRuby/hruby_low.rb', line 2405

def add_event(event)
    raise AnyError, "Time behaviors do not have any sensitivity list."
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


2391
2392
2393
2394
2395
2396
# File 'lib/HDLRuby/hruby_low.rb', line 2391

def eql?(obj)
    # Specific comparison.
    return false unless obj.is_a?(TimeBehavior)
    # General comparison.
    return super(obj)
end

#hashObject

Hash function.



2399
2400
2401
# File 'lib/HDLRuby/hruby_low.rb', line 2399

def hash
    super
end

#set_block!(block) ⇒ Object

Sets the block.



421
422
423
424
425
426
427
428
429
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 421

def set_block!(block)
    # Check and set the block.
    unless block.is_a?(Block)
        raise AnyError, "Invalid class for a block: #{block.class}."
    end
    # Time blocks are supported here.
    @block = block
    block.parent = self
end

#to_c(res, level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object. def to_c(level = 0)



816
817
818
819
# File 'lib/HDLRuby/hruby_low2c.rb', line 816

def to_c(res,level = 0)
    # super(level,true)
    super(res,level,true)
end

#to_hdr(level = 0) ⇒ Object

Generates the text of the equivalent hdr text. +level+ is the hierachical level of the object.



282
283
284
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 282

def to_hdr(level = 0)
    super(level,true)
end

#to_highObject

Creates a new high time behavior.



143
144
145
146
147
148
149
# File 'lib/HDLRuby/hruby_low2high.rb', line 143

def to_high
    # Create the resulting behavior.
    res = HDLRuby::High::TimeBehavior.new(self.block.to_high)
    # Adds the events.
    self.each_event { |ev| res.add_event(ev.to_high) }
    return res
end