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_python(l = "") ⇒ Object
Convert to Python 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.
2547 2548 2549 2550 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2547 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.
2553 2554 2555 2556 2557 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2553 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.
2560 2561 2562 2563 2564 2565 2566 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2560 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.
2574 2575 2576 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2574 def to_c return "for(;;){\n#{@blk.to_ruby}\n#{@sequencer.clk_up_c}\n}" end |
#to_python(l = "") ⇒ Object
Convert to Python code.
2579 2580 2581 2582 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2579 def to_python(l = "") return "#{l}while True:\n#{@blk.to_python(l + " ")}\n" + @sequencer.clk_up_python(l + " ") end |
#to_ruby ⇒ Object
Convert to Ruby code.
2569 2570 2571 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2569 def to_ruby return "loop do\n#{@blk.to_ruby}\n#{@sequencer.clk_up}\nend" end |