Class: HDLRuby::High::Case
- Inherits:
-
Low::Case
- Object
- Base::Statement
- Low::Statement
- Low::Case
- HDLRuby::High::Case
- Includes:
- HStatement
- Defined in:
- lib/HDLRuby/hruby_high.rb
Overview
Describes a high-level case statement.
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes inherited from Low::Case
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#helse(mode = nil, &ruby_block) ⇒ Object
Sets the block executed in +mode+ when there were no match to the block generated by the execution of +ruby_block+.
-
#hwhen(match, mode = nil, &ruby_block) ⇒ Object
Sets the block executed in +mode+ when the value matches +match+.
-
#initialize(value) ⇒ Case
constructor
Creates a new case statement with a +value+ that decides which block to execute.
-
#to_low ⇒ Object
Converts the case to HDLRuby::Low.
Methods included from HStatement
Methods inherited from Low::Case
#add_when, #blocks2seq!, #boolean_in_assign2select!, #clone, #delete_related!, #delete_unless!, #delete_when!, #each_block, #each_block_deep, #each_node, #each_node_deep, #each_statement_deep, #each_when, #eql?, #explicit_types!, #extract_declares!, #extract_selects!, #hash, #map_nodes!, #map_whens!, #mix?, #replace_expressions!, #replace_names!, #set_default!, #set_value!, #to_c, #to_high, #to_upper_space!, #to_verilog, #to_vhdl, #use_name?, #with_var
Methods inherited from Low::Statement
#add_blocks_code, #behavior, #block, #blocks2seq!, #break_types!, #clone, #delete_related!, #delete_unless!, #eql?, #explicit_types!, #extract_declares!, #hash, #mix?, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_c, #to_high, #to_upper_space!, #to_vhdl, #top_block, #top_scope, #use_name?, #with_boolean!
Methods included from Low::Low2Symbol
Methods included from Low::Hparent
Constructor Details
#initialize(value) ⇒ Case
Creates a new case statement with a +value+ that decides which block to execute.
2172 2173 2174 2175 |
# File 'lib/HDLRuby/hruby_high.rb', line 2172 def initialize(value) # Create the yes block. super(value.to_expr) end |
Instance Method Details
#helse(mode = nil, &ruby_block) ⇒ Object
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.
2192 2193 2194 2195 2196 2197 |
# File 'lib/HDLRuby/hruby_high.rb', line 2192 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) ⇒ Object
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+.
2181 2182 2183 2184 2185 2186 |
# File 'lib/HDLRuby/hruby_high.rb', line 2181 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 ⇒ Object
Converts the case to HDLRuby::Low.
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 |
# File 'lib/HDLRuby/hruby_high.rb', line 2200 def to_low # Create the low level case. caseL = HDLRuby::Low::Case.new(@value.to_low) # 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 |