Class: RubyHDL::High::TypeGen
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a high-level generic type definition.
NOTE: this type does not correspond to any low-level type
Instance Method Summary collapse
-
#generate(*args) ⇒ Object
Generates the type with +args+ generic parameters.
-
#initialize(name, &ruby_block) ⇒ TypeGen
constructor
Creates a new generic type definition producing a new type by executing +ruby_block+.
Methods inherited from Type
#[], #base, #base?, #binary, #comp_operator, #constant, #define_operator, #define_operator_with_context, #direction, #each_overload, #each_type_deep, #eql?, #equivalent?, #fixed?, #float?, #hash, #hierarchical?, #htype?, #inner, #leaf?, #left, #max, #min, #name=, #range, #range?, #register, #regular?, #right, #signed?, #struct?, #to_type, #to_vector, #typedef, #types?, #unary, #unsigned?, #vector?, #width
Methods included from HDLRuby::Tprocess
#&, #*, #+, #+@, #-@, #/, #<<, #==, #abs, #lr, #make, #resolve, #slice, #~
Constructor Details
#initialize(name, &ruby_block) ⇒ TypeGen
Creates a new generic type definition producing a new type by executing +ruby_block+.
960 961 962 963 964 965 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 960 def initialize(name,&ruby_block) # Initialize the type structure. super(name) # Sets the block to execute when instantiating the type. @instance_proc = ruby_block end |
Instance Method Details
#generate(*args) ⇒ Object
Generates the type with +args+ generic parameters.
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 968 def generate(*args) # Generate the resulting type. gtype = RubyHDL::High.top_sblock.instance_exec(*args,&@instance_proc) # Ensures a type has been produced. gtype = gtype.to_type if gtype.respond_to?(:to_type) unless gtype.is_a?(Type) then raise AnyError, "Generic type #{self.name} did not produce a valid type: #{gtype.class}" end # Create a new type definition from it. gtype = TypeDef.new(self.name.to_s + "_#{args.join(':')}", gtype) # Adds the possible overloaded operators. self.each_overload do |op,ruby_block| gtype.define_operator_with_context(op,&(RubyHDL::High.curry_with_context(*args,&ruby_block))) end # Returns the resulting type return gtype end |