Class: VhdlDoctest::DUT

Inherits:
Object
  • Object
show all
Defined in:
lib/vhdl_doctest/dut.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vhdl) ⇒ DUT

Returns a new instance of DUT.



8
9
10
# File 'lib/vhdl_doctest/dut.rb', line 8

def initialize(vhdl)
  @vhdl = vhdl
end

Instance Attribute Details

#casesObject

Returns the value of attribute cases.



7
8
9
# File 'lib/vhdl_doctest/dut.rb', line 7

def cases
  @cases
end

#entityObject

Returns the value of attribute entity.



7
8
9
# File 'lib/vhdl_doctest/dut.rb', line 7

def entity
  @entity
end

#portsObject

Returns the value of attribute ports.



7
8
9
# File 'lib/vhdl_doctest/dut.rb', line 7

def ports
  @ports
end

Class Method Details

.parse(path) ⇒ Object



3
4
5
# File 'lib/vhdl_doctest/dut.rb', line 3

def self.parse(path)
  new(File.read(path))
end

Instance Method Details

#dependenciesObject



46
47
48
49
50
51
52
# File 'lib/vhdl_doctest/dut.rb', line 46

def dependencies
  @vhdl.split("\n").
    select { |line| line.include?('DOCTEST DEPENDENCIES') }.
    map { |line| line.split(":")[1].split(",") }.
    flatten.
    map { |file| file.strip }
end

#port_blockObject



30
31
32
# File 'lib/vhdl_doctest/dut.rb', line 30

def port_block
  @vhdl.match(/entity\s*(?<entity_name>[a-zA-Z_0-9]*)\s*is\s+port\s*\((?<ports>.*?)\);\s*end\s+\k<entity_name>\s*;/m)[:ports]
end

#remove_comments(vhdl) ⇒ Object



34
35
36
# File 'lib/vhdl_doctest/dut.rb', line 34

def remove_comments(vhdl)
  vhdl.gsub(/--.*$/, '')
end

#test_fileObject



12
13
14
# File 'lib/vhdl_doctest/dut.rb', line 12

def test_file
  TestFile.new(entity, ports, cases)
end