Class: RubyHDL::High::Sloop

Inherits:
Statement show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes a SW implementation of a loop statement.

Instance Method Summary collapse

Constructor Details

#initialize(sequencer, &ruby_block) ⇒ Sloop

Create a new infinite loop statement in sequencer +sequencer+ with +ruby_block+ for generating the block that is taken.



2393
2394
2395
2396
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2393

def initialize(sequencer, &ruby_block)
  @sequencer = sequencer
  @blk = Sblock.new(sequencer,&ruby_block)
end

Instance Method Details

#each_statement(&ruby_block) ⇒ Object

Iterate on the statements.



2399
2400
2401
2402
2403
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2399

def each_statement(&ruby_block)
  return to_enum(:each_statement) unless ruby_block
  # Apply ruby_block on the block.
  ruby_block.call(@blk)
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterate deeply on the statements.



2406
2407
2408
2409
2410
2411
2412
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2406

def each_statement_deep(&ruby_block)
  return to_enum(:each_statement_deep) unless ruby_block
  # Recurse on the block.
  @blk.each_statement_deep
  # And apply ruby_block on self.
  ruby_block.call(self)
end

#to_cObject

Convert to C code.



2420
2421
2422
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2420

def to_c
  return "for(;;){\n#{@blk.to_ruby}\n#{@sequencer.clk_up_c}\n}"
end

#to_rubyObject

Convert to Ruby code.



2415
2416
2417
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2415

def to_ruby
  return "loop do\n#{@blk.to_ruby}\n#{@sequencer.clk_up}\nend"
end