Class: RubyHDL::High::Hif
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a hif statement.
Instance Method Summary collapse
-
#to_c ⇒ Object
Convert to C code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
Methods inherited from Sif
#each_statement, #each_statement_deep, #initialize, #selse, #selsif
Methods inherited from Statement
#each_statement, #each_statement_deep
Constructor Details
This class inherits a constructor from RubyHDL::High::Sif
Instance Method Details
#to_c ⇒ Object
Convert to C code.
2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2377 def to_c res = "\nif(#{@condition.to_c}) {\n#{@yes_blk.to_c}\n}" @elsifs.each do |(cond,blk)| res << "\nelse if(#{cond.to_c}) {\n#{blk.to_c}\n}" end if @else_blk then res << "\nelse {\n#{@else_blk.to_c}\n}" end return res end |
#to_ruby ⇒ Object
Convert to Ruby code.
2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2365 def to_ruby res = "\nif((#{@condition.to_ruby}) != 0)\n#{@yes_blk.to_ruby}\n" @elsifs.each do |(cond,blk)| res << "elsif((#{cond.to_ruby}) != 0)\n#{blk.to_ruby}\n" end if @else_blk then res << "else\n#{@else_blk.to_ruby}\n" end return res + "end\n" end |