Class: RubyHDL::High::Sloop
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a loop statement.
Instance Method Summary collapse
-
#each_statement(&ruby_block) ⇒ Object
Iterate on the statements.
-
#each_statement_deep(&ruby_block) ⇒ Object
Iterate deeply on the statements.
-
#initialize(sequencer, &ruby_block) ⇒ Sloop
constructor
Create a new infinite loop statement in sequencer +sequencer+ with +ruby_block+ for generating the block that is taken.
-
#to_c ⇒ Object
Convert to C code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
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.
2339 2340 2341 2342 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2339 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.
2345 2346 2347 2348 2349 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2345 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.
2352 2353 2354 2355 2356 2357 2358 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2352 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_c ⇒ Object
Convert to C code.
2366 2367 2368 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2366 def to_c return "for(;;){\n#{@blk.to_ruby}\n#{@sequencer.clk_up_c}\n}" end |
#to_ruby ⇒ Object
Convert to Ruby code.
2361 2362 2363 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2361 def to_ruby return "loop do\n#{@blk.to_ruby}\n#{@sequencer.clk_up}\nend" end |