Class: RubyHDL::High::Sif
- Inherits:
-
Object
- Object
- RubyHDL::High::Sif
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a if statement.
Instance Method Summary collapse
-
#initialize(sequencer, cond, &ruby_block) ⇒ Sif
constructor
Create a new if statement in sequencer +sequencer+ with +cond+ condition and +ruby_block+ for generating the block that is taken if the condition is met.
-
#selse(&ruby_block) ⇒ Object
Sets the else block.
-
#selsif(cond, &ruby_block) ⇒ Object
Add a selsif case.
-
#to_ruby ⇒ Object
Convert to ruby code.
Constructor Details
#initialize(sequencer, cond, &ruby_block) ⇒ Sif
Create a new if statement in sequencer +sequencer+ with +cond+ condition and +ruby_block+ for generating the block that is taken if the condition is met.
1983 1984 1985 1986 1987 1988 1989 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1983 def initialize(sequencer,cond, &ruby_block) @sequencer = sequencer @condition = cond.to_expr @yes_blk = Sblock.new(@sequencer,&ruby_block) @elsifs = [] @else_blk = nil end |
Instance Method Details
#selse(&ruby_block) ⇒ Object
Sets the else block.
1997 1998 1999 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1997 def selse(&ruby_block) @else_blk = Sblock.new(@sequencer,&ruby_block) end |
#selsif(cond, &ruby_block) ⇒ Object
Add a selsif case.
1992 1993 1994 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1992 def selsif(cond,&ruby_block) @elsifs << [cond,Sblock.new(@sequencer,&ruby_block)] end |
#to_ruby ⇒ Object
Convert to ruby code.
2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2002 def to_ruby res = @sequencer.clk_up + "\nif(#{@cond.to_ruby})\n#{@yes.to_ruby}\n" @elsifs.each do |(cond,blk)| res << "elsif(#{cond.to_ruby})\n#{blk.to_ruby}\n" end if @else_blk then res << "else\n#{@else_blk.to_ruby}\n" end return res + @sequencer.clk_up end |