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 +lang+ with start function named +func+.
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+.
3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 |
# File 'lib/HDLRuby/hruby_low.rb', line 3012 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.
3008 3009 3010 |
# File 'lib/HDLRuby/hruby_low.rb', line 3008 def function @function end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
3008 3009 3010 |
# File 'lib/HDLRuby/hruby_low.rb', line 3008 def language @language end |
Instance Method Details
#add_actport(ev) ⇒ Object
Add a new activation port.
3026 3027 3028 3029 3030 3031 |
# File 'lib/HDLRuby/hruby_low.rb', line 3026 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.
3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 |
# File 'lib/HDLRuby/hruby_low.rb', line 3068 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.
3034 3035 3036 3037 |
# File 'lib/HDLRuby/hruby_low.rb', line 3034 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.
3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 |
# File 'lib/HDLRuby/hruby_low.rb', line 3040 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.
3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 |
# File 'lib/HDLRuby/hruby_low.rb', line 3054 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.
3085 3086 3087 3088 3089 3090 |
# File 'lib/HDLRuby/hruby_low.rb', line 3085 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.
3125 3126 3127 3128 3129 3130 |
# File 'lib/HDLRuby/hruby_low.rb', line 3125 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.
3095 3096 3097 3098 3099 3100 |
# File 'lib/HDLRuby/hruby_low.rb', line 3095 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.
3105 3106 3107 3108 3109 3110 |
# File 'lib/HDLRuby/hruby_low.rb', line 3105 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.
3115 3116 3117 3118 3119 3120 |
# File 'lib/HDLRuby/hruby_low.rb', line 3115 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 |