class HDLRuby::Low::TimeRepeat

Describes a timed loop statement: not synthesizable!

Describes a timed loop statement: not synthesizable!

Extends the TimeRepeat class with generation of C text.

Extends the TimeRepeat class with generation of hdr text.

Add the conversion to high.

Extends the TimeRepeat class with functionality for converting par block to seq.

Extends the TimeRepeat class with generation of HDLRuby::High text.

Extends the TimeRepeat class with functionality for converting booleans in assignments to setlect operators.

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

Extends the TimeRepeat class with fixing of types and constants.

Describes a timed loop statement: not synthesizable!

Extends the When class with functionality for moving the declarations to the upper namespace.

Extends the TimeRepeat class with functionality for converting booleans in assignments to select operators.

Attributes

delay[R]

The delay until the loop is repeated

statement[R]

The statement to execute.

Public Class Methods

new(statement,delay) click to toggle source

Creates a new timed loop statement execute in a loop statement until delay has passed.

Calls superclass method
# File lib/HDLRuby/hruby_low.rb, line 3879
def initialize(statement,delay)
    # Check and set the statement.
    unless statement.is_a?(Statement)
        raise AnyError,
              "Invalid class for a statement: #{statement.class}."
    end
    super()
    @statement = statement
    # And set its parent.
    statement.parent = self

    # 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

Public Instance Methods

blocks2seq!() click to toggle source

Converts the par sub blocks to seq.

# File lib/HDLRuby/hruby_low2seq.rb, line 178
def blocks2seq!
    # Converts the statement.
    self.statement.blocks2seq!
    return self
end
boolean_in_assign2select!() click to toggle source

Converts booleans in assignments to select operators.

# File lib/HDLRuby/hruby_low_bool2select.rb, line 150
def boolean_in_assign2select!
    # Simply recurse on the stamtement.
    self.statement.boolean_in_assign2select!
    return self
end
casts_without_expression!() click to toggle source

Extracts the expressions from the casts.

# File lib/HDLRuby/hruby_low_casts_without_expression.rb, line 147
def casts_without_expression!
    # Simply recurse on the stamtement.
    self.statement.casts_without_expression!
    return self
end
clone() click to toggle source

Clones the TimeRepeat (deeply)

# File lib/HDLRuby/hruby_low.rb, line 3927
def clone
    return TimeRepeat.new(@statement.clone,@delay.clone)
end
each_block(&ruby_block) click to toggle source

Iterates over the sub blocks.

# File lib/HDLRuby/hruby_low.rb, line 3950
def each_block(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block) unless ruby_block
    # A ruby block?
    # Apply it on the statement if it is a block.
    ruby_block.call(@statement) if statement.is_a?(Block)
end
each_block_deep(&ruby_block) click to toggle source

Iterates over all the blocks contained in the current block.

# File lib/HDLRuby/hruby_low.rb, line 3959
def each_block_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block_deep) unless ruby_block
    # A ruby block?
    # Recurse on the statement.
    @statement.each_block_deep(&ruby_block)
end
each_deep(&ruby_block) click to toggle source

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.

# File lib/HDLRuby/hruby_low.rb, line 3902
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 statement.
    self.statement.each_deep(&ruby_block)
    # Then apply on the delay.
    self.delay.each_deep(&ruby_block)
end
each_node(&ruby_block) click to toggle source

Iterates over the expression children if any.

# File lib/HDLRuby/hruby_low.rb, line 3932
def each_node(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node) unless ruby_block
    # A ruby block? Apply it on the child.
    ruby_block.call(@statement)
end
each_node_deep(&ruby_block) click to toggle source

Iterates over the nodes deeply if any.

# File lib/HDLRuby/hruby_low.rb, line 3940
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)
    # And recurse on the child
    @statement.each_node_deep(&ruby_block)
end
each_statement_deep(&ruby_block) click to toggle source

Iterates over all the statements contained in the current block.

# File lib/HDLRuby/hruby_low.rb, line 3968
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)
    # Recurse on the statement.
    @statement.each_statement_deep(&ruby_block)
end
eql?(obj) click to toggle source

Comparison for hash: structural comparison.

# File lib/HDLRuby/hruby_low.rb, line 3914
def eql?(obj)
    return false unless obj.is_a?(TimeRepeat)
    return false unless @delay.eql?(obj.delay)
    return false unless @statement.eql?(obj.statement)
    return true
end
explicit_types!() click to toggle source

Explicit the types conversions in the time repeat.

# File lib/HDLRuby/hruby_low_fix_types.rb, line 166
def explicit_types!
    # Recurse on the statement.
    self.statement.explicit_types!
    return self
end
extract_declares!() click to toggle source

Extract the declares from the scope and returns them into an array.

NOTE: do not recurse into the sub scopes or behaviors!

# File lib/HDLRuby/hruby_low_without_namespace.rb, line 653
def extract_declares!
    # Recurse on the statement.
    return self.statement.extract_declares!
end
extract_selects!() click to toggle source

Extract the Select expressions.

# File lib/HDLRuby/hruby_low_without_select.rb, line 116
def extract_selects!
    # Simply recruse on the statement.
    if self.statement.is_a?(Block) then
        return []
    else
        return self.statement.extract_selects!
    end
end
hash() click to toggle source

Hash function.

# File lib/HDLRuby/hruby_low.rb, line 3922
def hash
    return [@delay,@statement].hash
end
map_nodes!(&ruby_block) click to toggle source

Maps on the child.

# File lib/HDLRuby/hruby_low_mutable.rb, line 1064
def map_nodes!(&ruby_block)
    @statement = ruby_block.call(@statement)
    @statement.parent = self unless @statement.parent
end
mix?(mode = nil) click to toggle source

Tell if there is a mix block. mode is the mode of the upper block.

# File lib/HDLRuby/hruby_low2seq.rb, line 186
def mix?(mode = nil)
    # Check the statement.
    return self.statement.mix?(mode)
end
process_to_vhdl(vars,level = 0) click to toggle source

Generates the text of the equivalent HDLRuby::High code as a new process. vars is the list of the variables and level is the hierachical level of the object.

# File lib/HDLRuby/hruby_low2vhd.rb, line 1058
def process_to_vhdl(vars,level = 0)
    # Generate a separate process for the repeated statement with
    # a wait.
    # The resulting string.
    res = " " * (level*3)
    # Generate the header.
    unless  self.block.name.empty? then
        res << Low2VHDL.vhdl_name(self.block.name) << ": "
    end
    res << "process \n"
    # Generate the content.
    res << " " * (level*3)
    res << "begin\n"
    # Adds the wait.
    res << " " * ((level+1)*3)
    res << "wait for " << self.delay.to_vhdl(level) << ";\n" 
    # Generate the remaining of the body.
    res << self.statement.to_vhdl(vars,level+1)
    # Close the process.
    res << " " * (level*3)
    res << "end process;\n\n"
    # Return the result.
    return res
end
replace_expressions!(node2rep) click to toggle source

Replaces sub expressions using node2rep table indicating the node to replace and the corresponding replacement. Returns the actually replaced nodes and their corresponding replacement.

NOTE: the replacement is duplicated.

# File lib/HDLRuby/hruby_low_mutable.rb, line 1075
def replace_expressions!(node2rep)
    res = {}
    # Recurse on the children.
    self.each_node do |node|
        res.merge!(node.replace_expressions!(node2rep))
    end
    return res
end
replace_names!(former,nname) click to toggle source

Replaces recursively former name by nname until it is redeclared.

# File lib/HDLRuby/hruby_low_without_namespace.rb, line 659
def replace_names!(former,nname)
    # Recurse on the statement.
    self.statement.replace_names!(former,nname)
end
set_delay!(delay) click to toggle source

Sets the delay.

# File lib/HDLRuby/hruby_low_mutable.rb, line 1053
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
set_statement!(statement) click to toggle source

Sets the statement.

# File lib/HDLRuby/hruby_low_mutable.rb, line 1041
def set_statement!(statement)
    # Check and set the statement.
    unless statement.is_a?(Statement)
        raise AnyError,
              "Invalid class for a statement: #{statement.class}."
    end
    @statement = statement
    # And set its parent.
    statement.parent = self
end
to_c(level = 0) click to toggle source

Generates the C text of the equivalent HDLRuby code. level is the hierachical level of the object.

# File lib/HDLRuby/hruby_low2c.rb, line 1349
def to_c(level = 0)
    # The resulting string.
    res = " " * level*3
    # Generate an infinite loop executing the block and waiting.
    res << "for(;;) {\n"
    res << "#{self.to_c(level+1)}\n"
    res = " " * (level+1)*3
    res << Low2C.wait_code(self,level)
    # Return the resulting string.
    return res
end
to_hdr(level = 0) click to toggle source

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

# File lib/HDLRuby/hruby_low2hdr.rb, line 454
def to_hdr(level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the header.
    res << "repeat " << self.delay.to_hdr(level) << " do\n"
    # Generate the statement to repeat.
    res << self.statement.to_hdr(level+1)
    # Close the repeat.
    res << " " * (level*3) << "end\n"
    # Return the resulting string.
    return res
end
to_high() click to toggle source

Creates a new high repreat statement.

# File lib/HDLRuby/hruby_low2high.rb, line 328
def to_high
    return HDLRuby::High::TimeReapeat.new(self.delay.to_high,
                                          self.statement.to_high)
end
to_upper_space!() click to toggle source

Moves the declarations to the upper namespace.

# File lib/HDLRuby/hruby_low_without_namespace.rb, line 645
def to_upper_space!
    # Recurse on the statement.
    self.statement.to_upper_space!
end
to_vhdl(vars,level = 0) click to toggle source

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.

# File lib/HDLRuby/hruby_low2vhd.rb, line 1049
def to_vhdl(vars,level = 0)
    # Nothing to do, see process_to_vhdl
    return ""
end