Class: HDLRuby::High::Block
- Inherits:
-
Low::Block
- Object
- Low::Statement
- Low::Block
- HDLRuby::High::Block
- Includes:
- BlockHierarchy, HBlock, Hinner, RCSimBlock, WithFullname
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb,
lib/HDLRuby/std/sequencer.rb,
lib/HDLRuby/hruby_rsim_vcd.rb,
lib/HDLRuby/std/sequencer_func.rb,
lib/HDLRuby/hruby_high_fullname.rb
Overview
Describes a block.
Constant Summary collapse
- High =
HDLRuby::High
- @@old_make_inners_proc =
Save module method (unbounded) for further call since going to override make_inners. alias_method does not seem to work in such a context, so use this approach.
self.instance_method(:make_inners)
Constants included from Hmissing
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes included from RCSimBlock
Attributes included from HBlock
Attributes inherited from Low::Block
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#execute(mode) ⇒ Object
Executes the statement.
-
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
-
#initialize(mode, name = :"", &ruby_block) ⇒ Block
constructor
Creates a new +mode+ sort of block, with possible +name+ and build it by executing +ruby_block+.
- #make_inners(typ, *names) ⇒ Object
- #old_make_inners ⇒ Object
-
#to_low(low_parent = nil) ⇒ Object
Converts the block to HDLRuby::Low.
Methods included from BlockHierarchy
#get_vars_with_fullname, #get_vars_with_idstr, #show_hierarchy
Methods included from RCSimBlock
Methods included from Hinner
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
Methods included from HScope_missing
Methods included from Hmissing
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, #to_viz, #to_viz_node, #unshift_statement, #var2ref, #var_name2sym, #variable_name?, #variables, #with_var
Methods included from Low::ForceName
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
Methods included from Low::Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Constructor Details
#initialize(mode, name = :"", &ruby_block) ⇒ Block
Creates a new +mode+ sort of block, with possible +name+ and build it by executing +ruby_block+.
4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 |
# File 'lib/HDLRuby/hruby_high.rb', line 4441 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 |
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.
920 921 922 923 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 920 def execute(mode) # puts "execute block of mode=#{self.mode}" self.each_statement { |stmnt| stmnt.execute(self.mode) } end |
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
926 927 928 929 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 926 def fullname @fullname ||= self.parent.fullname + ":" + self.name.to_s return @fullname end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
912 913 914 915 916 917 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 912 def init_sim(systemT) # Recurse on the inner signals. self.each_inner { |sig| sig.init_sim(systemT) } # Recurde on the statements. self.each_statement { |stmnt| stmnt.init_sim(systemT) } end |
#make_inners(typ, *names) ⇒ Object
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/HDLRuby/std/sequencer.rb', line 340 def make_inners(typ,*names) res = nil if SequencerT.current then unames = names.map {|name| HDLRuby.uniq_name(name) } res = HDLRuby::High.cur_scope.make_inners(typ, *unames) names.zip(unames).each do |name,uname| HDLRuby::High.space_reg(name) { send(uname) } end else # self.old_make_inners(typ,*names) # Call the old make_inners. res = @@old_make_inners_proc.bind(self).call(typ,*names) end return res end |
#old_make_inners ⇒ Object
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/HDLRuby/std/sequencer_func.rb', line 494 def make_inners(typ,*names) res = nil if SequencerT.current then unames = names.map {|name| HDLRuby.uniq_name(name) } res = HDLRuby::High.cur_scope.make_inners(typ, *unames) names.zip(unames).each do |name,uname| HDLRuby::High.space_reg(name) { send(uname) } end else # self.old_make_inners(typ,*names) # Call the old make_inners. res = @@old_make_inners_proc.bind(self).call(typ,*names) end return res end |
#to_low(low_parent = nil) ⇒ Object
Converts the block to HDLRuby::Low. def to_low
4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 |
# File 'lib/HDLRuby/hruby_high.rb', line 4460 def to_low(low_parent = nil) # Create the resulting block blockL = HDLRuby::Low::Block.new(self.mode,self.name) # Is there a low parent? if low_parent then # Set it straight away to have correct references. low_parent.block = blockL end # # 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 |