class HDLRuby::High::Case
Describes a high-level case statement.
Constants
- High
High-level libraries for describing digital hardware.
Public Class Methods
new(value)
click to toggle source
Creates a new case statement with a value
that decides which block to execute.
Calls superclass method
HDLRuby::Low::Case::new
# File lib/HDLRuby/hruby_high.rb, line 2292 def initialize(value) # Create the yes block. super(value.to_expr) end
Public Instance Methods
helse(mode = nil, &ruby_block)
click to toggle source
Sets the block executed in mode
when there were no match to the block generated by the execution of ruby_block
.
Can only be used once.
# File lib/HDLRuby/hruby_high.rb, line 2312 def helse(mode = nil, &ruby_block) # Create the nu block if required default_block = High.make_block(mode,&ruby_block) # Sets the default block. self.default = default_block end
hwhen(match, mode = nil, &ruby_block)
click to toggle source
Sets the block executed in mode
when the value matches match
. The block is generated by the execution of ruby_block
.
Can only be used once for the given match
.
# File lib/HDLRuby/hruby_high.rb, line 2301 def hwhen(match, mode = nil, &ruby_block) # Create the nu block if required when_block = High.make_block(mode,&ruby_block) # Adds the case. self.add_when(When.new(match.to_expr,when_block)) end
to_low()
click to toggle source
Converts the case to HDLRuby::Low
.
# File lib/HDLRuby/hruby_high.rb, line 2320 def to_low # Create the low level case. caseL = HDLRuby::Low::Case.new(@value.to_low) # For debugging: set the source high object caseL.properties[:low2high] = self.hdr_id self.properties[:high2low] = caseL # Add each when case. self.each_when do |w| caseL.add_when(w.to_low) end # Add the default if any. if self.default then caseL.default = self.default.to_low end return caseL end