class HDLRuby::Low::StringE
Describes a string.
NOTE: This is not synthesizable!
Add the conversion to high.
Extends the StringE
class with generation of HDLRuby::High
text.
Extends the StringE
class with functionality for converting booleans in assignments to select operators.
Extends the StringE
class with functionality for extracting expressions from cast.
Extends the stringE class with fixing of types and constants.
Enhance StringE
with generation of verilog code.
Attributes
Public Class Methods
Creates a new string whose content is str
and is modified using the objects of args
.
HDLRuby::Low::Expression::new
# File lib/HDLRuby/hruby_low.rb, line 5717 def initialize(content,*args) super(StringT) # Checks and set the content. @content = content.to_s # Process the arguments. @args = args.map do |arg| arg.parent = self arg end end
Public Instance Methods
Converts booleans in assignments to select operators.
# File lib/HDLRuby/hruby_low_bool2select.rb, line 339 def boolean_in_assign2select # Apply on the content. # Apply on the arguments. return StringE.new(self.content.clone,*self.each_arg.map do |arg| arg.boolean_in_assign2select end) end
Extracts the expressions from the casts.
# File lib/HDLRuby/hruby_low_casts_without_expression.rb, line 347 def casts_without_expression return StringE.new(self.content, *self.each_arg.map(&:cast_without_expression)) return self end
Clones the string.
# File lib/HDLRuby/hruby_low.rb, line 5772 def clone return StringE.new(@content.clone,*@args.map {|arg| arg.clone}) end
Iterates over each argument.
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_low.rb, line 5747 def each_arg(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_arg) unless ruby_block # A ruby block? First apply it to each argument. @args.each(&ruby_block) end
Iterates over the sub blocks.
# File lib/HDLRuby/hruby_low.rb, line 5796 def each_block(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_block) unless ruby_block # A ruby block? # Recurse on each argument. @args.each do |arg| arg.each_block(&ruby_block) if arg.respond_to?(:each_block) end end
Iterates over all the blocks contained in the current block.
# File lib/HDLRuby/hruby_low.rb, line 5807 def each_block_deep(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_block_deep) unless ruby_block # A ruby block? # Recurse on each argument. @args.each do |arg| if arg.respond_to?(:each_block_deep) then arg.each_block_deep(&ruby_block) end end end
Iterates over each object deeply.
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_low.rb, line 5757 def each_deep(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_deep) unless ruby_block # A ruby block? First apply it to current. ruby_block.call(self) # Then apply on the arguments. self.each_arg(&ruby_block) end
Iterates over the expression children if any.
# File lib/HDLRuby/hruby_low.rb, line 5777 def each_node(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_node) unless ruby_block # A ruby block? # Apply it on each argument. @args.each(&ruby_block) end
Iterates over the nodes deeply if any.
# File lib/HDLRuby/hruby_low.rb, line 5786 def each_node_deep(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_node_deep) unless ruby_block # A ruby block? First apply it to current. ruby_block.call(self) # And apply it on each argument. @args.each(&ruby_block) end
Iterates over all the statements contained in the current block.
# File lib/HDLRuby/hruby_low.rb, line 5820 def each_statement_deep(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_statement_deep) unless ruby_block # A ruby block? # Apply it on self. ruby_block.call(self) # Recurse on each argument. @args.each do |arg| if arg.respond_to?(:each_statement_deep) then arg.each_statement_deep(&ruby_block) end end end
Comparison for hash: structural comparison.
# File lib/HDLRuby/hruby_low.rb, line 5735 def eql?(obj) return false unless obj.is_a?(StringE) return false unless @content.eql?(obj.content) return false if @args.each.zip(obj.each_arg).any? do |a0,a1| !a0.eql?(a1) end return true end
Explicit the types conversions in the concat where type
is the expected type of the condition if any.
# File lib/HDLRuby/hruby_low_fix_types.rb, line 459 def explicit_types(type = nil) return StringE.new(self.content, *self.each_arg.map(&:explicit_types)) end
Hash
function.
# File lib/HDLRuby/hruby_low.rb, line 5767 def hash return @args.hash end
Tells if the expression is immutable (cannot be written.)
# File lib/HDLRuby/hruby_low.rb, line 5729 def immutable? # String objects are always immutable. true end
Creates a new high string expression.
# File lib/HDLRuby/hruby_low2high.rb, line 515 def to_high return HDLRuby::High::StringE.new(self.content, *self.each_arg.map {|arg| arg.to_high }) end
Converts the system to Verilog
code.
# File lib/HDLRuby/hruby_verilog.rb, line 2102 def to_verilog(spc = 3) code = "\"#{Low.v_string(self.content)}" + "#{self.each_arg.map do |arg| to.to_verilog end.join(",")}\"" return code end
Generates the text of the equivalent HDLRuby::High
code. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2vhd.rb, line 1520 def to_vhdl(level = 0, std_logic = false) # Generate a report statement. return "\"#{Low2VHDL.vhdl_string(self.content)}\"" + self.each_arg.map { |arg| arg.to_vhdl }.join(" & ") end