Class: OrigenVerilog::Verilog::Node
- Defined in:
- lib/origen_verilog/verilog/node.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#evaluate ⇒ Object
Evaluates all functions and turns numbers into Ruby literals.
-
#module(name) ⇒ Object
Returns the AST node for the module with the given name.
-
#module_names ⇒ Object
Returns an array containing the names of all top-level modules in the AST.
-
#modules ⇒ Object
Returns an array containing the AST node for all modules in the AST.
-
#pins ⇒ Object
Returns an array containing all input, output and inout AST nodes.
- #process(file = nil, env = {}) ⇒ Object
-
#to_top_level ⇒ Object
Converts a module node to an Origen top-level model.
Methods inherited from Node
#directory, #find, #find_all, #line_number, #text_value, #value
Instance Method Details
#evaluate ⇒ Object
Evaluates all functions and turns numbers into Ruby literals
36 37 38 |
# File 'lib/origen_verilog/verilog/node.rb', line 36 def evaluate Evaluator.new.run(self) end |
#module(name) ⇒ Object
Returns the AST node for the module with the given name
26 27 28 |
# File 'lib/origen_verilog/verilog/node.rb', line 26 def module(name) find_all(:module_declaration).find { |n| n.to_a[0].to_s == name.to_s } end |
#module_names ⇒ Object
Returns an array containing the names of all top-level modules in the AST
16 17 18 |
# File 'lib/origen_verilog/verilog/node.rb', line 16 def module_names find_all(:module_declaration).map { |n| n.to_a[0] } end |
#modules ⇒ Object
Returns an array containing the AST node for all modules in the AST
21 22 23 |
# File 'lib/origen_verilog/verilog/node.rb', line 21 def modules find_all(:module_declaration) end |
#pins ⇒ Object
Returns an array containing all input, output and inout AST nodes
31 32 33 |
# File 'lib/origen_verilog/verilog/node.rb', line 31 def pins find_all(:input_declaration, :output_declaration, :inout_declaration) end |
#process(file = nil, env = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/origen_verilog/verilog/node.rb', line 4 def process(file = nil, env = {}) file, env = nil, file if file.is_a?(Hash) ast = Processor.new.run(self, env) if file Writer.new.run(file, ast) else ast end end |
#to_top_level ⇒ Object
Converts a module node to an Origen top-level model.
This will re-load the Origen target with the resultant model instantiated as the global dut object.
44 45 46 47 48 49 50 |
# File 'lib/origen_verilog/verilog/node.rb', line 44 def to_top_level unless type == :module_declaration fail 'Currently only modules support the to_model method' end Origen.target.temporary = -> { TopLevel.new(ast: evaluate) } Origen.load_target end |