Class: HDLRuby::Low::Program
- Inherits:
-
Object
- Object
- HDLRuby::Low::Program
- Includes:
- Hparent
- Defined in:
- lib/HDLRuby/hruby_low.rb
Overview
Describes a program.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Attributes included from Hparent
Instance Method Summary collapse
-
#add_actport(ev) ⇒ Object
Add a new activation port.
-
#add_arrayport(name, sig) ⇒ Object
Add a new array port.
-
#add_code(code) ⇒ Object
Add a new code file.
-
#add_inport(name, sig) ⇒ Object
Add a new input port.
-
#add_outport(name, sig) ⇒ Object
Add a new output port.
-
#each_actport(&ruby_block) ⇒ Object
Iterates over each activation event.
-
#each_arrayport(&ruby_block) ⇒ Object
Iterate over each array port.
-
#each_code(&ruby_block) ⇒ Object
Iterates over each code file.
-
#each_inport(&ruby_block) ⇒ Object
Iterate over each input port.
-
#each_outport(&ruby_block) ⇒ Object
Iterate over each output port.
-
#initialize(lang, func) ⇒ Program
constructor
Creates a new program in language
langwith start function namedfunc.
Methods included from Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Constructor Details
#initialize(lang, func) ⇒ Program
Creates a new program in language lang with start function
named func.
2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 |
# File 'lib/HDLRuby/hruby_low.rb', line 2952 def initialize(lang,func) # Sets the language. @language = lang.to_sym # Sets the start function. @function = func.to_s # Initializes the contents. @actports = [] # The activation ports. @codes = [] # The code files. @inports = {} # The input ports. @outports = {} # The output ports. @arrayports ={}# The array ports. end |
Instance Attribute Details
#function ⇒ Object (readonly)
Returns the value of attribute function.
2948 2949 2950 |
# File 'lib/HDLRuby/hruby_low.rb', line 2948 def function @function end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
2948 2949 2950 |
# File 'lib/HDLRuby/hruby_low.rb', line 2948 def language @language end |
Instance Method Details
#add_actport(ev) ⇒ Object
Add a new activation port.
2966 2967 2968 2969 2970 2971 |
# File 'lib/HDLRuby/hruby_low.rb', line 2966 def add_actport(ev) unless ev.is_a?(Event) then raise AnyError, "Invalid class for an event: #{ev.class}" end @actports << ev end |
#add_arrayport(name, sig) ⇒ Object
Add a new array port.
3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 |
# File 'lib/HDLRuby/hruby_low.rb', line 3008 def add_arrayport(name, sig) # Ensure name is a symbol. unless name.is_a?(Symbol) then name = name.to_s.to_sym end # Ensure sig is a signal. unless sig.is_a?(SignalI) then raise AnyError, "Invalid class for a signal: #{sig.class}" end # Add the new port. @arrayports[name] = sig end |
#add_code(code) ⇒ Object
Add a new code file.
2974 2975 2976 2977 |
# File 'lib/HDLRuby/hruby_low.rb', line 2974 def add_code(code) # @codes << code.to_s @codes << (code.is_a?(Proc) ? code : code.to_s) end |
#add_inport(name, sig) ⇒ Object
Add a new input port.
2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 |
# File 'lib/HDLRuby/hruby_low.rb', line 2980 def add_inport(name, sig) # Ensure name is a symbol. unless name.is_a?(Symbol) then name = name.to_s.to_sym end # Ensure sig is a signal. unless sig.is_a?(SignalI) then raise AnyError, "Invalid class for a signal: #{sig.class}" end # Add the new port. @inports[name] = sig end |
#add_outport(name, sig) ⇒ Object
Add a new output port.
2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 |
# File 'lib/HDLRuby/hruby_low.rb', line 2994 def add_outport(name, sig) # Ensure name is a symbol. unless name.is_a?(Symbol) then name = name.to_s.to_sym end # Ensure sig is a signal. unless sig.is_a?(SignalI) then raise AnyError, "Invalid class for a signal: #{sig.class}" end # Add the new port. @outports[name] = sig end |
#each_actport(&ruby_block) ⇒ Object
Iterates over each activation event.
Returns an enumerator if no ruby block is given.
3025 3026 3027 3028 3029 3030 |
# File 'lib/HDLRuby/hruby_low.rb', line 3025 def each_actport(&ruby_block) # No block? Return an enumerator. return to_enum(:each_actport) unless ruby_block # A block is given, apply it. @actports.each(&ruby_block) end |
#each_arrayport(&ruby_block) ⇒ Object
Iterate over each array port.
Returns an enumerator if no ruby block is given.
3065 3066 3067 3068 3069 3070 |
# File 'lib/HDLRuby/hruby_low.rb', line 3065 def each_arrayport(&ruby_block) # No block? Return an enumerator. return to_enum(:each_arrayport) unless ruby_block # A block is given, apply it. @arrayports.each(&ruby_block) end |
#each_code(&ruby_block) ⇒ Object
Iterates over each code file.
Returns an enumerator if no ruby block is given.
3035 3036 3037 3038 3039 3040 |
# File 'lib/HDLRuby/hruby_low.rb', line 3035 def each_code(&ruby_block) # No block? Return an enumerator. return to_enum(:each_code) unless ruby_block # A block is given, apply it. @codes.each(&ruby_block) end |
#each_inport(&ruby_block) ⇒ Object
Iterate over each input port.
Returns an enumerator if no ruby block is given.
3045 3046 3047 3048 3049 3050 |
# File 'lib/HDLRuby/hruby_low.rb', line 3045 def each_inport(&ruby_block) # No block? Return an enumerator. return to_enum(:each_inport) unless ruby_block # A block is given, apply it. @inports.each(&ruby_block) end |
#each_outport(&ruby_block) ⇒ Object
Iterate over each output port.
Returns an enumerator if no ruby block is given.
3055 3056 3057 3058 3059 3060 |
# File 'lib/HDLRuby/hruby_low.rb', line 3055 def each_outport(&ruby_block) # No block? Return an enumerator. return to_enum(:each_outport) unless ruby_block # A block is given, apply it. @outports.each(&ruby_block) end |