module HDLRuby::High::Hinner
Module providing declaration of inner signal (assumes inner signals are present.
Public Class Methods
included(klass)
click to toggle source
Only adds the methods if not present.
# File lib/HDLRuby/hruby_high.rb, line 240 def self.included(klass) klass.class_eval do unless instance_methods.include?(:make_inners) then # Creates and adds a set of inners typed +type+ from a # list of +names+. # # NOTE: * a name can also be a signal, is which case it is # duplicated. # * a name can also be a hash containing names # associated with an initial value. def make_inners(type, *names) res = nil names.each do |name| if name.respond_to?(:to_sym) then # Adds the inner signal res = self.add_inner( SignalI.new(name,type,:inner)) elsif name.is_a?(Hash) then # Names associated with values. names.each do |name,value| res = self.add_inner( SignalI.new(name,type,:inner,value)) end else raise AnyError, "Invalid class for a name: #{name.class}" end end return res end end unless instance_methods.include?(:make_constants) then # Creates and adds a set of contants typed +type+ from a # hsh given names and corresponding values. def make_constants(type, hsh) res = nil hsh.each do |name,value| # Adds the Constant signal res = self.add_inner(SignalC.new(name,type,value)) end return res end end unless instance_methods.include?(:inner) then # Declares high-level bit inner signals named +names+. def inner(*names) self.make_inners(bit,*names) end end unless instance_methods.include?(:constant) then # Declares high-level untyped constant signals by name and # value given by +hsh+ of the current type. def constant(hsh) self.make_constants(bit,hsh) end end end end
Public Instance Methods
constant(hsh)
click to toggle source
Declares high-level untyped constant signals by name and value given by hsh
of the current type.
# File lib/HDLRuby/hruby_high.rb, line 295 def constant(hsh) self.make_constants(bit,hsh) end
inner(*names)
click to toggle source
Declares high-level bit inner signals named names
.
# File lib/HDLRuby/hruby_high.rb, line 287 def inner(*names) self.make_inners(bit,*names) end
make_constants(type, hsh)
click to toggle source
Creates and adds a set of contants typed type
from a hsh given names and corresponding values.
# File lib/HDLRuby/hruby_high.rb, line 275 def make_constants(type, hsh) res = nil hsh.each do |name,value| # Adds the Constant signal res = self.add_inner(SignalC.new(name,type,value)) end return res end
make_inners(type, *names)
click to toggle source
Creates and adds a set of inners typed type
from a list of names
.
NOTE: * a name can also be a signal, is which case it is
duplicated. * a name can also be a hash containing names associated with an initial value.
# File lib/HDLRuby/hruby_high.rb, line 250 def make_inners(type, *names) res = nil names.each do |name| if name.respond_to?(:to_sym) then # Adds the inner signal res = self.add_inner( SignalI.new(name,type,:inner)) elsif name.is_a?(Hash) then # Names associated with values. names.each do |name,value| res = self.add_inner( SignalI.new(name,type,:inner,value)) end else raise AnyError, "Invalid class for a name: #{name.class}" end end return res end