Class: VHDL_Parser::Entity
- Inherits:
-
Object
- Object
- VHDL_Parser::Entity
- Defined in:
- lib/vhdl_parser/entity.rb
Instance Attribute Summary collapse
-
#generics ⇒ Array<Generic>
readonly
An array of all the Generics.
-
#name ⇒ String
readonly
The name of the Entity.
-
#ports ⇒ Array<Port>
readonly
An array of all the Ports.
Instance Method Summary collapse
-
#initialize(name) ⇒ Entity
constructor
A new instance of Entity.
-
#merge_package(package) ⇒ nil
Applies constants from a package to the entity.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Entity
Returns a new instance of Entity.
16 17 18 19 20 |
# File 'lib/vhdl_parser/entity.rb', line 16 def initialize(name) @name = name @ports = Array.new @generics = Array.new end |
Instance Attribute Details
#generics ⇒ Array<Generic> (readonly)
An array of all the Generics.
10 11 12 |
# File 'lib/vhdl_parser/entity.rb', line 10 def generics @generics end |
#name ⇒ String (readonly)
The name of the Entity.
14 15 16 |
# File 'lib/vhdl_parser/entity.rb', line 14 def name @name end |
#ports ⇒ Array<Port> (readonly)
An array of all the Ports.
6 7 8 |
# File 'lib/vhdl_parser/entity.rb', line 6 def ports @ports end |
Instance Method Details
#merge_package(package) ⇒ nil
Applies constants from a package to the entity. For example, if the Entity has an input whose size is defined with a constant, like “std_logic_vector(MY_SIZE-1 downto 0)”, and “MY_SIZE” is defined in the package, this method will evaluate the size to a real number.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vhdl_parser/entity.rb', line 39 def merge_package(package) # TODO: do some type checking @generics.each do |g| package.constants.each do |k,v| unless g.value.nil? g.value = Utility.sub_constants(g.value, k, v) end unless g.left.nil? g.left = Utility.sub_constants(g.left, k, v) end unless g.right.nil? g.right = Utility.sub_constants(g.right, k, v) end end nil end @ports.each do |p| package.constants.each do |k,v| unless p.left.nil? p.left = Utility.sub_constants(p.left, k, v) end unless p.right.nil? p.right = Utility.sub_constants(p.right, k, v) end end end end |
#to_s ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/vhdl_parser/entity.rb', line 23 def to_s out = name + "\n" @generics.each { |p| out += "\t" + p.to_s} out += "\n\n" @ports.each { |p| out += "\t" + p.to_s} out end |