class HDLRuby::Low::Statement

Describes a statement.

NOTE: this is an abstract class which is not to be used directly.

Describes a statement.

NOTE: this is an abstract class which is not to be used directly.

Extends the Statement class with generation of C text.

Extends the Statement class with generation of hdr text.

Add the conversion to high.

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

Extends the Statement class with conversion to symbol.

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

Extends the Statement class with functionality for breaking assingments to concats.

Extends the Statement class with fixing of types and constants.

Describes a statement.

NOTE: this is an abstract class which is not to be used directly.

Extends the Statement class for converting types of comparison and operations on it to boolean type.

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

Extends the Statement class with functionality for breaking assingments to concats.

Public Instance Methods

add_blocks_code(res,level) click to toggle source

Adds the c code of the blocks to res at level

# File lib/HDLRuby/hruby_low2c.rb, line 1069
def add_blocks_code(res,level)
    if self.respond_to?(:each_node) then
        self.each_node do |node|
            if node.respond_to?(:add_blocks_code) then
                node.add_blocks_code(res,level)
            end
        end
    end
end
add_make_block(res,level) click to toggle source

Adds the creation of the blocks to res at level.

# File lib/HDLRuby/hruby_low2c.rb, line 1080
def add_make_block(res,level)
    if self.respond_to?(:each_node) then
        self.each_node do |node|
            if node.respond_to?(:add_blocks_code) then
                node.add_make_block(res,level)
            end
        end
    end
end
behavior() click to toggle source

Gets the behavior the statement is in.

# File lib/HDLRuby/hruby_low.rb, line 2874
def behavior
    if self.parent.is_a?(Behavior) then
        return self.parent
    else
        return self.parent.behavior
    end
end
block() click to toggle source

Get the block of the statement.

# File lib/HDLRuby/hruby_low.rb, line 2851
def block
    if self.is_a?(Block)
        return self
    elsif self.parent.is_a?(Scope)
        # No block
        return nil
    else
        return self.parent.block
    end
end
blocks2seq!() click to toggle source

Converts the par sub blocks to seq.

# File lib/HDLRuby/hruby_low2seq.rb, line 84
def blocks2seq!
    # By default, nothing to do.
    return self
end
break_types!(types) click to toggle source

Breaks the hierarchical types into sequences of type definitions. Assumes to_upper_space! has been called before. types include the resulting types.

# File lib/HDLRuby/hruby_low_without_namespace.rb, line 480
def break_types!(types)
    self.each_node do |node|
        node.break_types!(types)
    end
end
clone() click to toggle source

Clones (deeply)

# File lib/HDLRuby/hruby_low.rb, line 2816
def clone
    raise AnyError,
          "Internal error: clone is not defined for class: #{self.class}"
end
delete_unless!(keep) click to toggle source

Removes the signals and corresponding assignments whose name is not in keep.

# File lib/HDLRuby/hruby_low_cleanup.rb, line 116
def delete_unless!(keep)
    # By default nothing to do.
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 2824
def each_deep(&ruby_block)
    raise AnyError,
        "Internal error: each_deep is not defined for class: #{self.class}"
end
each_statement(&ruby_block) click to toggle source

Iterates over each sub statement if any.

Returns an enumerator if no ruby block is given.

# File lib/HDLRuby/hruby_low.rb, line 2844
def each_statement(&ruby_block)
    # No ruby statement? Return an enumerator.
    return to_enum(:each_statement) unless ruby_block
    # By default: nothing to do.
end
eql?(obj) click to toggle source

Comparison for hash: structural comparison.

# File lib/HDLRuby/hruby_low.rb, line 2830
def eql?(obj)
    raise AnyError,
        "Internal error: eql? is not defined for class: #{self.class}"
end
explicit_types!() click to toggle source

Explicit the types conversions in the statement.

# File lib/HDLRuby/hruby_low_fix_types.rb, line 73
def explicit_types!
    raise "Should implement explicit_types for class #{self.class}."
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 462
def extract_declares!
    # By default, nothing to do.
    return []
end
hash() click to toggle source

Hash function.

# File lib/HDLRuby/hruby_low.rb, line 2836
def hash
    raise AnyError,
        "Internal error: hash is not defined for class: #{self.class}"
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 91
def mix?(mode = nil)
    # By default, no mix block.
    return false
end
par_in_seq2seq!() click to toggle source

Converts par blocks within seq blocks to seq blocks.

# File lib/HDLRuby/hruby_low_without_parinseq.rb, line 45
def par_in_seq2seq!
    # By default nothing to do.
    return self
end
parent_system() click to toggle source

Gets the parent system, i.e., the parent of the top scope.

# File lib/HDLRuby/hruby_low.rb, line 2893
def parent_system
    return self.top_scope.parent
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 540
def replace_expressions!(node2rep)
    # By default: nothing to do.
    return {}
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 468
def replace_names!(former,nname)
    # By default: try to replace the name recursively.
    self.each_node_deep do |node|
        if node.respond_to?(:name) && node.name == former then
            node.set_name!(nname)
        end
    end
end
scope() click to toggle source

Get the scope of the statement.

# File lib/HDLRuby/hruby_low.rb, line 2863
def scope
    if self.parent.is_a?(Scope) then
        return self.parent
    elsif self.parent.is_a?(Behavior) then
        return self.parent.parent
    else
        return self.parent.scope
    end
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 1057
def to_c(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_c should be implemented in class :#{self.class}"
end
to_ch() click to toggle source

Generates the content of the h file.

# File lib/HDLRuby/hruby_low2c.rb, line 1063
def to_ch
    # By default nothing to generate.
    return ""
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 327
def to_hdr(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_high should be implemented in class :#{self.class}"
end
to_high() click to toggle source

Creates a new high statement.

# File lib/HDLRuby/hruby_low2high.rb, line 232
def to_high
    raise AnyError,
          "Internal error: to_high is not defined for class: #{self.class}"
end
to_seq!() click to toggle source

Convert the block to seq.

# File lib/HDLRuby/hruby_low_without_parinseq.rb, line 51
def to_seq!
    # By default nothing to do.
    return self
end
to_upper_space!() click to toggle source

Moves the declarations to the upper namespace.

# File lib/HDLRuby/hruby_low_without_namespace.rb, line 455
def to_upper_space!
    # By default, nothing to do.
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 891
def to_vhdl(vars, level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}"
end
top_block() click to toggle source

Gets the top block, i.e. the first block of the current behavior.

# File lib/HDLRuby/hruby_low.rb, line 2883
def top_block
    return self.parent.is_a?(Behavior) ? self : self.parent.top_block
end
top_scope() click to toggle source

Gets the top scope, i.e. the first scope of the current system.

# File lib/HDLRuby/hruby_low.rb, line 2888
def top_scope
    return self.scope.top_scope
end
use_name?(*names) click to toggle source

Tell if the statement includes a signal whose name is one of names.

# File lib/HDLRuby/hruby_low.rb, line 2898
def use_name?(*names)
    # By default, nothing to do.
end
with_boolean!() click to toggle source

Converts to a variable-compatible system.

NOTE: the result is the same Behaviour.

# File lib/HDLRuby/hruby_low_with_bool.rb, line 85
def with_boolean!
    self.each_node do |node| 
        if node.is_a?(Expression) && node.boolean? then
            node.set_type!(HDLRuby::Low::Boolean)
        end
    end
end