Module: HDLRuby::High::Hinner
Overview
Module providing declaration of inner signal (assumes inner signals are present.
Class Method Summary collapse
-
.included(klass) ⇒ Object
Only adds the methods if not present.
Class Method Details
.included(klass) ⇒ Object
Only adds the methods if not present.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/HDLRuby/hruby_high.rb', line 265 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. name.each do |key,value| res = self.add_inner( SignalI.new(key,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 |