Class: OrigenSTIL::Pattern
- Inherits:
-
Object
- Object
- OrigenSTIL::Pattern
- Defined in:
- lib/origen_stil/pattern.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Path to the STIL file on disk.
Instance Method Summary collapse
- #add_pin_groups(options = {}) ⇒ Object
-
#add_pins(options = {}) ⇒ Object
Add the pins defined in the STIL file to the DUT, unless it has them already.
-
#ast ⇒ Object
Returns frontmatter as an AST, note that this does not contain any vector-level information from Pattern blocks at the end of the file.
- #execute(options = {}) ⇒ Object
-
#frontmatter ⇒ Object
Returns the contents of the file before the first Pattern block as a string.
-
#initialize(path, options = {}) ⇒ Pattern
constructor
A new instance of Pattern.
-
#timesets(options = {}) ⇒ Object
Returns a hash containing all timesets (WaveformTables) defined in the STIL file { 'Waveset1' => { period_in_ns: 1000 } }.
Constructor Details
#initialize(path, options = {}) ⇒ Pattern
Returns a new instance of Pattern.
6 7 8 9 10 11 12 13 |
# File 'lib/origen_stil/pattern.rb', line 6 def initialize(path, = {}) unless File.exist?(path) fail "STIL source file not found: #{path}" end @path = path @loop = Struct.new(:id, :count, :status, :source_line_number, :number_of_lines, :braces, :lines) @n = 0 end |
Instance Attribute Details
#path ⇒ Object (readonly)
Path to the STIL file on disk
4 5 6 |
# File 'lib/origen_stil/pattern.rb', line 4 def path @path end |
Instance Method Details
#add_pin_groups(options = {}) ⇒ Object
70 71 72 |
# File 'lib/origen_stil/pattern.rb', line 70 def add_pin_groups( = {}) Processor::PinGroups.new.run(ast, dut, ) end |
#add_pins(options = {}) ⇒ Object
Add the pins defined in the STIL file to the DUT, unless it has them already. This will also call the add_pin_groups method automatically unless option :pin_group is set to false
62 63 64 65 66 67 68 |
# File 'lib/origen_stil/pattern.rb', line 62 def add_pins( = {}) = { pin_groups: true }.merge() Processor::Pins.new.run(ast, dut, ) add_pin_groups() unless [:pin_groups] = false end |
#ast ⇒ Object
Returns frontmatter as an AST, note that this does not contain any vector-level information from Pattern blocks at the end of the file
42 43 44 |
# File 'lib/origen_stil/pattern.rb', line 42 def ast @ast ||= Syntax::Parser.parse_file(path) end |
#execute(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/origen_stil/pattern.rb', line 15 def execute( = {}) = { set_timesets: false, add_pins: true }.merge() = @n = 0 add_pins if [:add_pins] Processor::Pattern.new.run(ast) do |pattern_name| i = 0 open = false File.foreach(path) do |line| if open # Stop at next pattern or EOF break if line =~ /^\s*Pattern/ consume_line(line, i) else open = true if line =~ /^\s*Pattern "?'?#{pattern_name}"?'?\s*{/ end i += 1 end end end |
#frontmatter ⇒ Object
Returns the contents of the file before the first Pattern block as a string
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/origen_stil/pattern.rb', line 48 def frontmatter @frontmatter ||= begin fm = '' File.foreach(path) do |line| break if line =~ /^\s*Pattern / fm << line end fm end end |
#timesets(options = {}) ⇒ Object
Returns a hash containing all timesets (WaveformTables) defined in the STIL file { 'Waveset1' => { period_in_ns: 1000 } }
76 77 78 |
# File 'lib/origen_stil/pattern.rb', line 76 def timesets( = {}) @timesets ||= Processor::Timesets.new.run(ast, ) end |