class HDLRuby::High::Block

Describes a high-level block.

Constants

High

High-level libraries for describing digital hardware.

Public Class Methods

new(mode, name=:"", &ruby_block) click to toggle source

Creates a new mode sort of block, with possible name and build it by executing ruby_block.

Calls superclass method HDLRuby::Low::Block::new
# File lib/HDLRuby/hruby_high.rb, line 3748
def initialize(mode, name=:"", &ruby_block)
    # Initialize the block.
    super(mode,name)

    unless name.empty? then
        # Named block, set the hdl-like access to the block.
        obj = self # For using the right self within the proc
        High.space_reg(name) { obj }
    end

    # Creates the namespace.
    @namespace = Namespace.new(self)

    # puts "methods = #{self.methods.sort}"
    build(&ruby_block)
end

Public Instance Methods

to_low() click to toggle source

Converts the block to HDLRuby::Low.

# File lib/HDLRuby/hruby_high.rb, line 3766
def to_low
    # Create the resulting block
    blockL = HDLRuby::Low::Block.new(self.mode)
    # For debugging: set the source high object
    blockL.properties[:low2high] = self.hdr_id
    self.properties[:high2low] = blockL
    # Push the namespace for the low generation.
    High.space_push(@namespace)
    # Pushes on the name stack for converting the internals of
    # the block.
    High.names_push
    # Add the inner signals
    self.each_inner { |inner| blockL.add_inner(inner.to_low) }
    # Add the statements
    self.each_statement do |statement|
        blockL.add_statement(statement.to_low)
    end
    # Restores the name stack.
    High.names_pop
    # Restores the namespace stack.
    High.space_pop
    # Return the resulting block
    return blockL
end