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+.
-
#build(&ruby_block) ⇒ Object
(also: #open)
Build the block by executing +ruby_block+.
-
#cur_behavior ⇒ Object
Gets the current behavior.
-
#cur_block ⇒ Object
Gets the current block.
-
#cur_scope ⇒ Object
Gets the current scope.
-
#cur_system ⇒ Object
Gets the current system.
-
#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.
-
#top_block ⇒ Object
Gets the top block of the current behavior.
-
#unshift(&ruby_block) ⇒ Object
Adds statements at the top of the block.
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
3230 3231 3232 |
# File 'lib/HDLRuby/hruby_high.rb', line 3230 def namespace @namespace end |
#return_value ⇒ Object (readonly)
The return value when building the scope.
3233 3234 3235 |
# File 'lib/HDLRuby/hruby_high.rb', line 3233 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+.
3255 3256 3257 3258 3259 3260 3261 3262 |
# File 'lib/HDLRuby/hruby_high.rb', line 3255 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 |
#build(&ruby_block) ⇒ Object Also known as: open
Build the block by executing +ruby_block+.
3236 3237 3238 3239 3240 3241 |
# File 'lib/HDLRuby/hruby_high.rb', line 3236 def build(&ruby_block) High.space_push(@namespace) @return_value = High.top_user.instance_eval(&ruby_block) High.space_pop @return_value end |
#cur_behavior ⇒ Object
Gets the current behavior.
3312 3313 3314 |
# File 'lib/HDLRuby/hruby_high.rb', line 3312 def cur_behavior return HDLRuby::High.cur_behavior end |
#cur_block ⇒ Object
Gets the current block.
3302 3303 3304 |
# File 'lib/HDLRuby/hruby_high.rb', line 3302 def cur_block return HDLRuby::High.cur_block end |
#cur_scope ⇒ Object
Gets the current scope.
3317 3318 3319 |
# File 'lib/HDLRuby/hruby_high.rb', line 3317 def cur_scope return HDLRuby::High.cur_scope end |
#cur_system ⇒ Object
Gets the current system.
3322 3323 3324 |
# File 'lib/HDLRuby/hruby_high.rb', line 3322 def cur_system return HDLRuby::High.cur_system 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.
3377 3378 3379 3380 |
# File 'lib/HDLRuby/hruby_high.rb', line 3377 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.
3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 |
# File 'lib/HDLRuby/hruby_high.rb', line 3345 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+.
3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 |
# File 'lib/HDLRuby/hruby_high.rb', line 3359 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.
3336 3337 3338 3339 |
# File 'lib/HDLRuby/hruby_high.rb', line 3336 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.
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 |
# File 'lib/HDLRuby/hruby_high.rb', line 3386 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+.
3266 3267 3268 3269 |
# File 'lib/HDLRuby/hruby_high.rb', line 3266 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+.
3273 3274 3275 3276 |
# File 'lib/HDLRuby/hruby_high.rb', line 3273 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+.
3280 3281 3282 |
# File 'lib/HDLRuby/hruby_high.rb', line 3280 def sub(name = :"", &ruby_block) self.add_block(self.mode,name,&ruby_block) end |
#to_ref ⇒ Object
Converts to a new reference.
3247 3248 3249 |
# File 'lib/HDLRuby/hruby_high.rb', line 3247 def to_ref return RefObject.new(this,self) end |
#top_block ⇒ Object
Gets the top block of the current behavior.
3307 3308 3309 |
# File 'lib/HDLRuby/hruby_high.rb', line 3307 def top_block return HDLRuby::High.top_block end |
#unshift(&ruby_block) ⇒ Object
Adds statements at the top of the block.
3285 3286 3287 3288 3289 3290 3291 3292 |
# File 'lib/HDLRuby/hruby_high.rb', line 3285 def unshift(&ruby_block) # Create a sub block for the statements. block = High.make_block(self.mode,:"",&ruby_block) # Unshifts it. self.unshift_statement(block) # Use its return value. return block.return_value end |