Class: OrigenSTIL::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_stil/pattern.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  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

#pathObject (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(options = {})
  Processor::PinGroups.new.run(ast, dut, options)
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(options = {})
  options = {
    pin_groups: true
  }.merge(options)
  Processor::Pins.new.run(ast, dut, options)
  add_pin_groups(options) unless options[:pin_groups] = false
end

#astObject

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(options = {})
  options = {
    set_timesets: false,
    add_pins:     true
  }.merge(options)
  @exec_options = options
  @n = 0
  add_pins if options[: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

#frontmatterObject

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(options = {})
  @timesets ||= Processor::Timesets.new.run(ast, options)
end