Module: HDLRuby::High::HBlock
Overview
Module giving the properties of a high-level block.
Constant Summary collapse
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
The namespace.
-
#return_value ⇒ Object
readonly
The return value when building the scope.
Instance Method Summary collapse
-
#add_block(mode = nil, name = :"", &ruby_block) ⇒ Object
Creates and adds a new block executed in +mode+, with possible +name+ and built by executing +ruby_block+.
-
#block ⇒ Object
Get the current mode of the block.
-
#build(&ruby_block) ⇒ Object
(also: #open)
Build the block by executing +ruby_block+.
-
#hcase(value) ⇒ Object
Creates a new case statement with a +value+ used for deciding which block to execute.
-
#helse(mode = nil, &ruby_block) ⇒ Object
Sets the block executed when the condition is not met to the block in +mode+ generated by the execution of +ruby_block+.
-
#helsif(condition, mode = nil, &ruby_block) ⇒ Object
Sets the condition check when the condition is not met to the block, with a +condition+ that when met lead to the execution of the block in +mode+ generated by the +ruby_block+.
-
#hif(condition, mode = nil, &ruby_block) ⇒ Object
Creates a new if statement with a +condition+ that when met lead to the execution of the block in +mode+ generated by the +ruby_block+.
-
#hwhen(match, mode = nil, &ruby_block) ⇒ Object
Sets the block of a case structure executed when the +match+ is met to the block in +mode+ generated by the execution of +ruby_block+.
-
#par(name = :"", &ruby_block) ⇒ Object
Creates a new parallel block with possible +name+ and built from +ruby_block+.
-
#seq(name = :"", &ruby_block) ⇒ Object
Creates a new sequential block with possible +name+ and built from +ruby_block+.
-
#sub(name = :"", &ruby_block) ⇒ Object
Creates a new block with the current mode with possible +name+ and built from +ruby_block+.
-
#to_ref ⇒ Object
Converts to a new reference.
Methods included from Hmux
Methods included from HScope_missing
Methods included from Hmissing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HDLRuby::High::HScope_missing
Instance Attribute Details
#namespace ⇒ Object (readonly)
The namespace
3017 3018 3019 |
# File 'lib/HDLRuby/hruby_high.rb', line 3017 def namespace @namespace end |
#return_value ⇒ Object (readonly)
The return value when building the scope.
3020 3021 3022 |
# File 'lib/HDLRuby/hruby_high.rb', line 3020 def return_value @return_value end |
Instance Method Details
#add_block(mode = nil, name = :"", &ruby_block) ⇒ Object
Creates and adds a new block executed in +mode+, with possible +name+ and built by executing +ruby_block+.
3042 3043 3044 3045 3046 3047 3048 3049 |
# File 'lib/HDLRuby/hruby_high.rb', line 3042 def add_block(mode = nil, name = :"", &ruby_block) # Creates the block. block = High.make_block(mode,name,&ruby_block) # Adds it as a statement. self.add_statement(block) # Use its return value. return block.return_value end |
#block ⇒ Object
Get the current mode of the block.
NOTE: for name coherency purpose only.
3074 3075 3076 |
# File 'lib/HDLRuby/hruby_high.rb', line 3074 def block return self.mode end |
#build(&ruby_block) ⇒ Object Also known as: open
Build the block by executing +ruby_block+.
3023 3024 3025 3026 3027 3028 |
# File 'lib/HDLRuby/hruby_high.rb', line 3023 def build(&ruby_block) High.space_push(@namespace) @return_value = High.top_user.instance_eval(&ruby_block) High.space_pop @return_value end |
#hcase(value) ⇒ Object
Creates a new case statement with a +value+ used for deciding which block to execute.
NOTE: the when part is defined through the hwhen method.
3127 3128 3129 3130 |
# File 'lib/HDLRuby/hruby_high.rb', line 3127 def hcase(value) # Creates the case statement. self.add_statement(Case.new(value)) end |
#helse(mode = nil, &ruby_block) ⇒ Object
Sets the block executed when the condition is not met to the block in +mode+ generated by the execution of +ruby_block+.
Can only be used once.
3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 |
# File 'lib/HDLRuby/hruby_high.rb', line 3095 def helse(mode = nil, &ruby_block) # There is a ruby_block: the helse is assumed to be with # the hif in the same block. # Completes the hif or the hcase statement. statement = @statements.last unless statement.is_a?(If) or statement.is_a?(Case) then raise AnyError, "Error: helse statement without hif nor hcase (#{statement.class})." end statement.helse(mode, &ruby_block) end |
#helsif(condition, mode = nil, &ruby_block) ⇒ Object
Sets the condition check when the condition is not met to the block, with a +condition+ that when met lead to the execution of the block in +mode+ generated by the +ruby_block+.
3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 |
# File 'lib/HDLRuby/hruby_high.rb', line 3109 def helsif(condition, mode = nil, &ruby_block) # There is a ruby_block: the helse is assumed to be with # the hif in the same block. # Completes the hif statement. statement = @statements.last unless statement.is_a?(If) then raise AnyError, "Error: helsif statement without hif (#{statement.class})." end statement.helsif(condition, mode, &ruby_block) end |
#hif(condition, mode = nil, &ruby_block) ⇒ Object
Creates a new if statement with a +condition+ that when met lead to the execution of the block in +mode+ generated by the +ruby_block+.
NOTE: the else part is defined through the helse method.
3086 3087 3088 3089 |
# File 'lib/HDLRuby/hruby_high.rb', line 3086 def hif(condition, mode = nil, &ruby_block) # Creates the if statement. self.add_statement(If.new(condition,mode,&ruby_block)) end |
#hwhen(match, mode = nil, &ruby_block) ⇒ Object
Sets the block of a case structure executed when the +match+ is met to the block in +mode+ generated by the execution of +ruby_block+.
Can only be used once.
3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 |
# File 'lib/HDLRuby/hruby_high.rb', line 3136 def hwhen(match, mode = nil, &ruby_block) # There is a ruby_block: the helse is assumed to be with # the hif in the same block. # Completes the hcase statement. statement = @statements.last unless statement.is_a?(Case) then raise AnyError, "Error: hwhen statement without hcase (#{statement.class})." end statement.hwhen(match, mode, &ruby_block) end |
#par(name = :"", &ruby_block) ⇒ Object
Creates a new parallel block with possible +name+ and built from +ruby_block+.
3053 3054 3055 3056 |
# File 'lib/HDLRuby/hruby_high.rb', line 3053 def par(name = :"", &ruby_block) return :par unless ruby_block self.add_block(:par,name,&ruby_block) end |
#seq(name = :"", &ruby_block) ⇒ Object
Creates a new sequential block with possible +name+ and built from +ruby_block+.
3060 3061 3062 3063 |
# File 'lib/HDLRuby/hruby_high.rb', line 3060 def seq(name = :"", &ruby_block) return :seq unless ruby_block self.add_block(:seq,name,&ruby_block) end |
#sub(name = :"", &ruby_block) ⇒ Object
Creates a new block with the current mode with possible +name+ and built from +ruby_block+.
3067 3068 3069 |
# File 'lib/HDLRuby/hruby_high.rb', line 3067 def sub(name = :"", &ruby_block) self.add_block(self.mode,name,&ruby_block) end |