Class: HDLRuby::High::TimeBlock

Inherits:
Low::TimeBlock show all
Includes:
BlockHierarchy, HBlock, RCSimBlock, WithFullname
Defined in:
lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb,
lib/HDLRuby/hruby_rsim_vcd.rb,
lib/HDLRuby/hruby_high_fullname.rb

Overview

Describes a timed block.

NOTE:

  • this is the only kind of block that can include time statements.
  • this kind of block is not synthesizable!

Constant Summary collapse

High =
HDLRuby::High

Constants included from Hmissing

Hmissing::NAMES

Constants included from Low::Low2Symbol

Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable

Instance Attribute Summary

Attributes included from RCSimBlock

#rcstatement

Attributes included from HBlock

#namespace, #return_value

Attributes inherited from Low::Block

#mode, #name

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods included from WithFullname

#fullname

Methods included from BlockHierarchy

#get_vars_with_fullname, #get_vars_with_idstr, #show_hierarchy

Methods included from RCSimBlock

#to_rcsim

Methods included from HBlock

#add_block, #build, #cur_behavior, #cur_block, #cur_scope, #cur_system, #hcase, #helse, #helsif, #hif, #hprint, #hwhen, #par, #seq, #sub, #terminate, #to_ref, #top_block, #unshift

Methods included from Hmux

#mux

Methods included from HScope_missing

#h_missing, #method_missing

Methods included from Hmissing

#method_missing

Methods inherited from Low::TimeBlock

#add_statement, #delete_unless!, #eql?, #hash, #to_hdr, #to_high, #unshift_statement, #with_var

Methods inherited from Low::Block

#add_blocks_code, #add_inner, #add_make_block, #add_statement, #add_variable, #att_sharp, #att_signal, #blocks2seq!, #boolean_in_assign2select!, #break_concat_assigns!, #casts_without_expression!, #change_branch, #clone, #delete_inner!, #delete_related!, #delete_statement!, #delete_unless!, #do_flat, #each_block, #each_block_deep, #each_deep, #each_inner, #each_node_deep, #each_signal_deep, #each_statement, #each_statement_deep, #eql?, #explicit_types!, #extract_declares!, #extract_from_externals!, #fix_scope_refnames!, #flatten, #get_by_name, #get_inner, #get_variable, #hash, #insert_statement!, #last_statement, #map_inners!, #map_statements!, #mix?, #num_statements, #par_in_seq2seq!, #reassign_expressions!, #refs_by_variables!, #replace_expressions!, #replace_names!, #replace_names_subs!, #replace_statement!, #res_name, #reverse_each_statement, #search_refname, #select2case!, #set_mode!, #set_name!, #set_statement!, #signal2subs!, #sym2var_name, #to_c, #to_c_code, #to_ch, #to_conversion, #to_hdr, #to_high, #to_seq!, #to_upper_space!, #to_verilog, #to_vhdl, #unshift_statement, #var2ref, #var_name2sym, #variable_name?, #variables, #with_var

Methods included from Low::ForceName

#extend_name!, #force_name!

Methods inherited from Low::Statement

#add_blocks_code, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #clone, #delete_related!, #delete_unless!, #each_deep, #each_statement, #eql?, #explicit_types!, #extract_declares!, #fix_scope_refnames!, #hash, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_c, #to_ch, #to_hdr, #to_high, #to_seq!, #to_upper_space!, #to_vhdl, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Low::Low2Symbol

#to_sym

Methods included from Low::Hparent

#absolute_ref, #hierarchy, #no_parent!, #scope

Constructor Details

#initialize(type, name = :"", &ruby_block) ⇒ TimeBlock

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



4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
# File 'lib/HDLRuby/hruby_high.rb', line 4429

def initialize(type, name = :"", &ruby_block)
    # Initialize the behavior.
    super(type,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)

    build(&ruby_block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HDLRuby::High::HScope_missing

Instance Method Details

#execute(mode) ⇒ Object

Executes the statement.



965
966
967
968
969
970
971
972
# File 'lib/HDLRuby/hruby_rsim.rb', line 965

def execute(mode)
    # puts "TimeBlock"
    self.each_statement do |stmnt|
        # puts "Going to execute statement: #{stmnt}"
        stmnt.execute(self.mode)
    end
    # puts "End TimeBlock"
end

#init_sim(systemT) ⇒ Object

Initialize the simulation for system +systemT+.



960
961
962
# File 'lib/HDLRuby/hruby_rsim.rb', line 960

def init_sim(systemT)
    self.each_statement { |stmnt| stmnt.init_sim(systemT) }
end

#repeat(number = -1,, mode = nil, &ruby_block) ⇒ Object

Adds a loop until +delay+ statement in the block in +mode+ whose

loop content is built using +ruby_block+.

def repeat(delay, mode = nil, &ruby_block) Adds a +number+ times loop statement in the block in +mode+ whose loop content is built using +ruby_block+. NOTE: if +number+ is negative, the number of iteration is infinite.



4456
4457
4458
4459
4460
4461
4462
4463
4464
# File 'lib/HDLRuby/hruby_high.rb', line 4456

def repeat(number = -1, mode = nil, &ruby_block)
    # Ensure there is a block.
    ruby_block = proc {} unless block_given?
    # Build the content block.
    content = High.make_block(mode,&ruby_block)
    # Create and add the statement.
    # self.add_statement(TimeRepeat.new(content,delay))
    self.add_statement(TimeRepeat.new(number,content))
end

#to_lowObject

Converts the time block to HDLRuby::Low.



4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
# File 'lib/HDLRuby/hruby_high.rb', line 4467

def to_low
    # Create the resulting block
    blockL = HDLRuby::Low::TimeBlock.new(self.mode)
    # # For debugging: set the source high object 
    # blockL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = blockL
    # 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
    # Return the resulting block
    return blockL
end

#wait(delay) ⇒ Object

Adds a wait +delay+ statement in the block.



4446
4447
4448
# File 'lib/HDLRuby/hruby_high.rb', line 4446

def wait(delay)
    self.add_statement(TimeWait.new(delay))
end