Class: HDLRuby::Low::TimeWait

Inherits:
Statement
  • 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_verilog.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_fix_types.rb,
lib/HDLRuby/hruby_low_bool2select.rb,
lib/HDLRuby/hruby_low_without_select.rb,
lib/HDLRuby/hruby_low_casts_without_expression.rb

Overview

Extends the TimeWait class with functionality for extracting expressions from cast.

Direct Known Subclasses

High::TimeWait

Constant Summary

Constants included from Low2Symbol

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

Instance Attribute Summary collapse

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Statement

#add_blocks_code, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #delete_related!, #delete_unless!, #each_statement, #extract_declares!, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_ch, #to_seq!, #to_upper_space!, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #scope

Constructor Details

#initialize(delay) ⇒ TimeWait

Creates a new statement waiting +delay+.



3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
# File 'lib/HDLRuby/hruby_low.rb', line 3795

def initialize(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    super()
    @delay = delay
    # And set its parent.
    delay.parent = self
end

Instance Attribute Details

#delayObject (readonly)

The delay to wait.



3792
3793
3794
# File 'lib/HDLRuby/hruby_low.rb', line 3792

def delay
  @delay
end

Instance Method Details

#boolean_in_assign2select!Object

Converts booleans in assignments to select operators.



140
141
142
143
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 140

def boolean_in_assign2select!
    # Nothing to do.
    return self
end

#casts_without_expression!Object

Extracts the expressions from the casts.



137
138
139
140
# File 'lib/HDLRuby/hruby_low_casts_without_expression.rb', line 137

def casts_without_expression!
    # Nothing to do.
    return self
end

#cloneObject

Clones the TimeWait (deeply)



3831
3832
3833
# File 'lib/HDLRuby/hruby_low.rb', line 3831

def clone
    return TimeWait.new(@delay.clone)
end

#each_block(&ruby_block) ⇒ Object

Iterates over the sub blocks.



3852
3853
3854
3855
3856
3857
# File 'lib/HDLRuby/hruby_low.rb', line 3852

def each_block(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_block_deep(&ruby_block) ⇒ Object

Iterates over all the blocks contained in the current block.



3860
3861
3862
3863
3864
3865
# File 'lib/HDLRuby/hruby_low.rb', line 3860

def each_block_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block_deep) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_deep(&ruby_block) ⇒ Object

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.



3816
3817
3818
3819
3820
3821
3822
3823
# File 'lib/HDLRuby/hruby_low.rb', line 3816

def each_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    # Then apply on the delay.
    self.delay.each_deep(&ruby_block)
end

#each_node(&ruby_block) ⇒ Object

Iterates over the expression children if any.



3836
3837
3838
3839
3840
3841
# File 'lib/HDLRuby/hruby_low.rb', line 3836

def each_node(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_node_deep(&ruby_block) ⇒ Object

Iterates over the nodes deeply if any.



3844
3845
3846
3847
3848
3849
# File 'lib/HDLRuby/hruby_low.rb', line 3844

def each_node_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterates over all the statements contained in the current block.



3868
3869
3870
3871
3872
3873
3874
# File 'lib/HDLRuby/hruby_low.rb', line 3868

def each_statement_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_statement_deep) unless ruby_block
    # A ruby block?
    # Apply it on self.
    ruby_block.call(self)
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


3807
3808
3809
3810
3811
# File 'lib/HDLRuby/hruby_low.rb', line 3807

def eql?(obj)
    return false unless obj.is_a?(TimeWait)
    return false unless @delay.eql?(obj.delay)
    return true
end

#explicit_types!Object

Explicit the types conversions in the time wait.



157
158
159
160
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 157

def explicit_types!
    # Nothing to do.
    return self
end

#extract_selects!Object

Extract the Select expressions.



105
106
107
108
# File 'lib/HDLRuby/hruby_low_without_select.rb', line 105

def extract_selects!
    # Nothing to extract.
    return []
end

#hashObject

Hash function.



3826
3827
3828
# File 'lib/HDLRuby/hruby_low.rb', line 3826

def hash
    return [@delay].hash
end

#map_nodes!(&ruby_block) ⇒ Object

Maps on the children (including the condition).



1042
1043
1044
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1042

def map_nodes!(&ruby_block)
    # Nothing to do.
end

#set_delay!(delay) ⇒ Object

Sets the delay.



1031
1032
1033
1034
1035
1036
1037
1038
1039
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1031

def set_delay!(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    @delay = delay
    # And set its parent.
    delay.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)



1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
# File 'lib/HDLRuby/hruby_low2c.rb', line 1690

def to_c(res,level = 0)
    # The resulting string.
    # res = " " * level*3
    res << " " * level*3
    # Generate the wait.
    # res << "hw_wait(#{self.delay.to_c(level+1)}," +
    #     "#{Low2C.behavior_access(self)});\n"
    res << "hw_wait("
    self.delay.to_c(res,level+1)
    res << "," << Low2C.behavior_access(self) << ");\n"
    # Return the resulting string.
    return res
end

#to_hdr(level = 0) ⇒ Object

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



439
440
441
442
443
444
445
446
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 439

def to_hdr(level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait " << self.delay.to_hdr(level) << "\n" 
    # Return the resulting string.
    return res
end

#to_highObject

Creates a new high wait statement.



319
320
321
# File 'lib/HDLRuby/hruby_low2high.rb', line 319

def to_high
    return HDLRuby::High::TimeWait.new(self.delay.to_high)
end

#to_verilog(spc = 3) ⇒ Object



1781
1782
1783
# File 'lib/HDLRuby/hruby_verilog.rb', line 1781

def to_verilog(spc = 3)
    return (" " * spc) + self.delay.to_verilog + "\n"
end

#to_vhdl(vars, level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +vars+ is the list of the variables and +level+ is the hierachical level of the object.



1034
1035
1036
1037
1038
1039
1040
1041
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1034

def to_vhdl(vars,level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait for " << self.delay.to_vhdl(level) << ";\n" 
    # Return the resulting string.
    return res
end