module HDLRuby::High::HBlock

Module giving the properties of a high-level block.

Constants

High

High-level libraries for describing digital hardware.

Attributes

namespace[R]

The namespace

return_value[R]

The return value when building the scope.

Public Instance Methods

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

Creates and adds a new block executed in mode, with possible name and built by executing ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3594
def add_block(mode = nil, name = :"", &ruby_block)
    # Creates the block.
    block = High.make_block(mode,name,&ruby_block)
    # Adds it as a statement.
    self.add_statement(block)
    # Use its return value.
    return block.return_value
end
build(&ruby_block) click to toggle source

Build the block by executing ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3575
def build(&ruby_block)
    High.space_push(@namespace)
    @return_value = High.top_user.instance_eval(&ruby_block)
    High.space_pop
    @return_value
end
Also aliased as: open
cur_behavior() click to toggle source

Gets the current behavior.

# File lib/HDLRuby/hruby_high.rb, line 3644
def cur_behavior
    return HDLRuby::High.cur_behavior
end
cur_block() click to toggle source

Gets the current block.

# File lib/HDLRuby/hruby_high.rb, line 3634
def cur_block
    return HDLRuby::High.cur_block
end
cur_scope() click to toggle source

Gets the current scope.

# File lib/HDLRuby/hruby_high.rb, line 3649
def cur_scope
    return HDLRuby::High.cur_scope
end
cur_system() click to toggle source

Gets the current system.

# File lib/HDLRuby/hruby_high.rb, line 3654
def cur_system
    return HDLRuby::High.cur_system
end
hcase(value) click to toggle source

Creates a new case statement with a value used for deciding which block to execute.

NOTE: the when part is defined through the hwhen method.

# File lib/HDLRuby/hruby_high.rb, line 3709
def hcase(value)
    # Creates the case statement.
    self.add_statement(Case.new(value))
end
helse(mode = nil, &ruby_block) click to toggle source

Sets the block executed when the condition is not met to the block in mode generated by the execution of ruby_block.

Can only be used once.

# File lib/HDLRuby/hruby_high.rb, line 3677
def helse(mode = nil, &ruby_block)
    # There is a ruby_block: the helse is assumed to be with
    # the hif in the same block.
    # Completes the hif or the hcase statement.
    statement = @statements.last
    unless statement.is_a?(If) or statement.is_a?(Case) then
        raise AnyError, "Error: helse statement without hif nor hcase (#{statement.class})."
    end
    statement.helse(mode, &ruby_block)
end
helsif(condition, mode = nil, &ruby_block) click to toggle source

Sets the condition check when the condition is not met to the block, with a condition that when met lead to the execution of the block in mode generated by the ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3691
def helsif(condition, mode = nil, &ruby_block)
    # There is a ruby_block: the helse is assumed to be with
    # the hif in the same block.
    # Completes the hif statement.
    statement = @statements.last
    unless statement.is_a?(If) then
        raise AnyError,
             "Error: helsif statement without hif (#{statement.class})."
    end
    statement.helsif(condition, mode, &ruby_block)
end
hif(condition, mode = nil, &ruby_block) click to toggle source

Creates a new if statement with a condition that when met lead to the execution of the block in mode generated by the ruby_block.

NOTE: the else part is defined through the helse method.

# File lib/HDLRuby/hruby_high.rb, line 3668
def hif(condition, mode = nil, &ruby_block)
    # Creates the if statement.
    self.add_statement(If.new(condition,mode,&ruby_block))
end
hprint(*args) click to toggle source

Prints.

# File lib/HDLRuby/hruby_high.rb, line 3732
def hprint(*args)
    self.add_statement(Print.new(*args))
end
hwhen(match, mode = nil, &ruby_block) click to toggle source

Sets the block of a case structure executed when the match is met to the block in mode generated by the execution of ruby_block.

Can only be used once.

# File lib/HDLRuby/hruby_high.rb, line 3718
def hwhen(match, mode = nil, &ruby_block)
    # There is a ruby_block: the helse is assumed to be with
    # the hif in the same block.
    # Completes the hcase statement.
    statement = @statements.last
    unless statement.is_a?(Case) then
        raise AnyError,
            "Error: hwhen statement without hcase (#{statement.class})."
    end
    statement.hwhen(match, mode, &ruby_block)
end
open(&ruby_block)

Opens the block.

Alias for: build
par(name = :"", &ruby_block) click to toggle source

Creates a new parallel block with possible name and built from ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3605
def par(name = :"", &ruby_block)
    return :par unless ruby_block
    self.add_block(:par,name,&ruby_block)
end
seq(name = :"", &ruby_block) click to toggle source

Creates a new sequential block with possible name and built from ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3612
def seq(name = :"", &ruby_block)
    return :seq unless ruby_block
    self.add_block(:seq,name,&ruby_block)
end
sub(name = :"", &ruby_block) click to toggle source

Creates a new block with the current mode with possible name and built from ruby_block.

# File lib/HDLRuby/hruby_high.rb, line 3619
def sub(name = :"", &ruby_block)
    self.add_block(self.mode,name,&ruby_block)
end
to_ref() click to toggle source

Converts to a new reference.

# File lib/HDLRuby/hruby_high.rb, line 3586
def to_ref
    return RefObject.new(this,self)
end
top_block() click to toggle source

Gets the top block of the current behavior.

# File lib/HDLRuby/hruby_high.rb, line 3639
def top_block
    return HDLRuby::High.top_block
end
unshift(&ruby_block) click to toggle source

Adds statements at the top of the block.

# File lib/HDLRuby/hruby_high.rb, line 3624
def unshift(&ruby_block)
    # Create a sub block for the statements.
    block = High.make_block(self.mode,:"",&ruby_block)
    # Unshifts it.
    self.unshift_statement(block)
    # Use its return value.
    return block.return_value
end