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.
2354 2355 2356 2357 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2354 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.
2360 2361 2362 2363 2364 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2360 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.
2367 2368 2369 2370 2371 2372 2373 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2367 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.
2381 2382 2383 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2381 def to_c return "for(;;){\n#{@blk.to_ruby}\n#{@sequencer.clk_up_c}\n}" end |
#to_ruby ⇒ Object
Convert to Ruby code.
2376 2377 2378 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2376 def to_ruby return "loop do\n#{@blk.to_ruby}\n#{@sequencer.clk_up}\nend" end |