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_python(l = "") ⇒ Object
Convert to Python 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.
2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2517 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_python(l = "") ⇒ Object
Convert to Python code.
2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2529 def to_python(l = "") res = "#{l}if (#{@condition.to_python}) != 0:\n" + "#{@yes_blk.to_python(l + " ")}\n" @elsifs.each do |(cond,blk)| res << "#{l}elif (#{cond.to_python}) != 0:\n" + "#{blk.to_python(l + " ")}\n" end if @else_blk then res << "#{l}else:\n#{@else_blk.to_python(l + " ")}\n" end return res end |
#to_ruby ⇒ Object
Convert to Ruby code.
2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2505 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 |