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, #no_parent!, #scope

Constructor Details

#initialize(delay) ⇒ TimeWait

Creates a new statement waiting +delay+.



3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
# File 'lib/HDLRuby/hruby_low.rb', line 3958

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.



3955
3956
3957
# File 'lib/HDLRuby/hruby_low.rb', line 3955

def delay
  @delay
end

Instance Method Details

#boolean_in_assign2select!Object

Converts booleans in assignments to select operators.



152
153
154
155
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 152

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)



3994
3995
3996
# File 'lib/HDLRuby/hruby_low.rb', line 3994

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

#each_block(&ruby_block) ⇒ Object

Iterates over the sub blocks.



4015
4016
4017
4018
4019
4020
# File 'lib/HDLRuby/hruby_low.rb', line 4015

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.



4023
4024
4025
4026
4027
4028
# File 'lib/HDLRuby/hruby_low.rb', line 4023

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.



3979
3980
3981
3982
3983
3984
3985
3986
# File 'lib/HDLRuby/hruby_low.rb', line 3979

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.



3999
4000
4001
4002
4003
4004
# File 'lib/HDLRuby/hruby_low.rb', line 3999

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.



4007
4008
4009
4010
4011
4012
# File 'lib/HDLRuby/hruby_low.rb', line 4007

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.



4031
4032
4033
4034
4035
4036
4037
# File 'lib/HDLRuby/hruby_low.rb', line 4031

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)


3970
3971
3972
3973
3974
# File 'lib/HDLRuby/hruby_low.rb', line 3970

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.



176
177
178
179
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 176

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.



3989
3990
3991
# File 'lib/HDLRuby/hruby_low.rb', line 3989

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)



1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
# File 'lib/HDLRuby/hruby_low2c.rb', line 1788

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



1796
1797
1798
# File 'lib/HDLRuby/hruby_verilog.rb', line 1796

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.



1046
1047
1048
1049
1050
1051
1052
1053
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1046

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