Class: RubyHDL::High::Swhile
- Defined in:
 - lib/HDLRuby/std/sequencer_sw.rb
 
Overview
Describes a SW implementation of a while 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, cond, &ruby_block)  ⇒ Swhile 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Create a new while statement in sequencer +sequencer+ with +cond+ condition and +ruby_block+ for generating the block that is taken while the condition is met.
 - 
  
    
      #to_c  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Convert to C code.
 - 
  
    
      #to_ruby  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Convert to Ruby code.
 
Constructor Details
#initialize(sequencer, cond, &ruby_block) ⇒ Swhile
Create a new while statement in sequencer +sequencer+ with +cond+ condition and +ruby_block+ for generating the block that is taken while the condition is met.
      2376 2377 2378 2379 2380  | 
    
      # File 'lib/HDLRuby/std/sequencer_sw.rb', line 2376 def initialize(sequencer,cond, &ruby_block) @sequencer = sequencer @condition = cond.to_expr @yes_blk = Sblock.new(sequencer,&ruby_block) end  | 
  
Instance Method Details
#each_statement(&ruby_block) ⇒ Object
Iterate on the statements.
      2383 2384 2385 2386 2387  | 
    
      # File 'lib/HDLRuby/std/sequencer_sw.rb', line 2383 def each_statement(&ruby_block) return to_enum(:each_statement) unless ruby_block # Apply ruby_block on the block. ruby_block.call(@yes_blk) end  | 
  
#each_statement_deep(&ruby_block) ⇒ Object
Iterate deeply on the statements.
      2390 2391 2392 2393 2394 2395 2396  | 
    
      # File 'lib/HDLRuby/std/sequencer_sw.rb', line 2390 def each_statement_deep(&ruby_block) return to_enum(:each_statement_deep) unless ruby_block # Recurse on the yes block. @yes_blk.each_statement_deep # And apply ruby_block on self. ruby_block.call(self) end  | 
  
#to_c ⇒ Object
Convert to C code.
      2405 2406 2407  | 
    
      # File 'lib/HDLRuby/std/sequencer_sw.rb', line 2405 def to_c "\nwhile(#{@condition.to_c}) {\n#{@yes_blk.to_c}\n#{@sequencer.clk_up_c}\n}" end  | 
  
#to_ruby ⇒ Object
Convert to Ruby code.
      2399 2400 2401 2402  | 
    
      # File 'lib/HDLRuby/std/sequencer_sw.rb', line 2399 def to_ruby return @sequencer.clk_up + "\nwhile(#{@condition.to_ruby}) do\n#{@yes_blk.to_ruby}\n#{@sequencer.clk_up}\nend" end  |