Module: HDLRuby::High::HBlock
Overview
Module giving the properties of a high-level block.
Constant Summary collapse
Constants included from Hmissing
HDLRuby::High::Hmissing::NAMES
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+.
-
#hprint(*args) ⇒ Object
Prints.
-
#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+.
-
#terminate ⇒ Object
Terminate the simulation.
-
#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
3953 3954 3955 |
# File 'lib/HDLRuby/hruby_high.rb', line 3953 def namespace @namespace end |
#return_value ⇒ Object (readonly)
The return value when building the scope.
3956 3957 3958 |
# File 'lib/HDLRuby/hruby_high.rb', line 3956 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+.
3987 3988 3989 3990 3991 3992 3993 3994 |
# File 'lib/HDLRuby/hruby_high.rb', line 3987 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+.
3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 |
# File 'lib/HDLRuby/hruby_high.rb', line 3959 def build(&ruby_block) High.space_push(@namespace) @return_value = High.top_user.instance_eval(&ruby_block) High.space_pop # if @return_value.is_a?(HExpression) then # res = @return_value # High.space_push(@namespace) # @return_value = res.type.inner(HDLRuby.uniq_name) # puts "@return_value name=#{@return_value.name}" # @return_value <= res # High.space_pop # @return_value = RefObject.new(self,@return_value) # end @return_value end |
#cur_behavior ⇒ Object
Gets the current behavior.
4041 4042 4043 |
# File 'lib/HDLRuby/hruby_high.rb', line 4041 def cur_behavior return HDLRuby::High.cur_behavior end |
#cur_block ⇒ Object
Gets the current block.
4031 4032 4033 |
# File 'lib/HDLRuby/hruby_high.rb', line 4031 def cur_block return HDLRuby::High.cur_block end |
#cur_scope ⇒ Object
Gets the current scope.
4046 4047 4048 |
# File 'lib/HDLRuby/hruby_high.rb', line 4046 def cur_scope return HDLRuby::High.cur_scope end |
#cur_system ⇒ Object
Gets the current system.
4051 4052 4053 |
# File 'lib/HDLRuby/hruby_high.rb', line 4051 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.
4112 4113 4114 4115 |
# File 'lib/HDLRuby/hruby_high.rb', line 4112 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.
4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 |
# File 'lib/HDLRuby/hruby_high.rb', line 4076 def helse(mode = nil, &ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? # 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+.
4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 |
# File 'lib/HDLRuby/hruby_high.rb', line 4092 def helsif(condition, mode = nil, &ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? # 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.
4065 4066 4067 4068 4069 4070 |
# File 'lib/HDLRuby/hruby_high.rb', line 4065 def hif(condition, mode = nil, &ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? # Creates the if statement. self.add_statement(If.new(condition,mode,&ruby_block)) end |
#hprint(*args) ⇒ Object
Prints.
4137 4138 4139 |
# File 'lib/HDLRuby/hruby_high.rb', line 4137 def hprint(*args) self.add_statement(Print.new(*args)) 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.
4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 |
# File 'lib/HDLRuby/hruby_high.rb', line 4121 def hwhen(match, mode = nil, &ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? # 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+.
3998 3999 4000 4001 |
# File 'lib/HDLRuby/hruby_high.rb', line 3998 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+.
4005 4006 4007 4008 |
# File 'lib/HDLRuby/hruby_high.rb', line 4005 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+.
4012 4013 4014 4015 4016 |
# File 'lib/HDLRuby/hruby_high.rb', line 4012 def sub(name = :"", &ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? self.add_block(self.mode,name,&ruby_block) end |
#terminate ⇒ Object
Terminate the simulation.
4142 4143 4144 |
# File 'lib/HDLRuby/hruby_high.rb', line 4142 def terminate self.add_statement(TimeTerminate.new) end |
#to_ref ⇒ Object
Converts to a new reference.
3979 3980 3981 |
# File 'lib/HDLRuby/hruby_high.rb', line 3979 def to_ref return RefObject.new(this,self) end |
#top_block ⇒ Object
Gets the top block of the current behavior.
4036 4037 4038 |
# File 'lib/HDLRuby/hruby_high.rb', line 4036 def top_block return HDLRuby::High.top_block end |
#unshift(&ruby_block) ⇒ Object
Adds statements at the top of the block.
4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 |
# File 'lib/HDLRuby/hruby_high.rb', line 4019 def unshift(&ruby_block) # Ensure there is a block. ruby_block = proc {} unless block_given? # 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 |