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_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_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+.
3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 |
# File 'lib/HDLRuby/hruby_low.rb', line 3010 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. end |
Instance Attribute Details
#function ⇒ Object (readonly)
Returns the value of attribute function.
3006 3007 3008 |
# File 'lib/HDLRuby/hruby_low.rb', line 3006 def function @function end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
3006 3007 3008 |
# File 'lib/HDLRuby/hruby_low.rb', line 3006 def language @language end |
Instance Method Details
#add_actport(ev) ⇒ Object
Add a new activation port.
3023 3024 3025 3026 3027 3028 |
# File 'lib/HDLRuby/hruby_low.rb', line 3023 def add_actport(ev) unless ev.is_a?(Event) then raise AnyError, "Invalid class for an event: #{ev.class}" end @actports << ev end |
#add_code(code) ⇒ Object
Add a new code file.
3031 3032 3033 |
# File 'lib/HDLRuby/hruby_low.rb', line 3031 def add_code(code) @codes << code.to_s end |
#add_inport(name, sig) ⇒ Object
Add a new input port.
3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 |
# File 'lib/HDLRuby/hruby_low.rb', line 3036 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.
3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 |
# File 'lib/HDLRuby/hruby_low.rb', line 3050 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.
3067 3068 3069 3070 3071 3072 |
# File 'lib/HDLRuby/hruby_low.rb', line 3067 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_code(&ruby_block) ⇒ Object
Iterates over each code file.
Returns an enumerator if no ruby block is given.
3077 3078 3079 3080 3081 3082 |
# File 'lib/HDLRuby/hruby_low.rb', line 3077 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.
3087 3088 3089 3090 3091 3092 |
# File 'lib/HDLRuby/hruby_low.rb', line 3087 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.
3097 3098 3099 3100 3101 3102 |
# File 'lib/HDLRuby/hruby_low.rb', line 3097 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 |