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.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 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 |
# 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 |