File size: 1,787 Bytes
784ee2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
70
71
#!/usr/bin/env -S klayout -b -r
#
# Generates a KLayout layer properties (.lyp) file from the Virtuoso SKILL Tech
# File
#
# import_tf needs to be in ~/.klayout/ruby, not ~/.klayout/salt
#
# KLayout doesn't support script-specific command line options, so work around
# it with env vars
#
# Usage: KLayoutLayerPropertiesFileGenerator.rb
#

include RBA
require 'import_tf'

#
# Class to generate KLayout layer properties file from Virtuoso tech file
#
class KLayoutLayerPropertiesFileGenerator
    #
    # Initializer
    #
    # layout_view: layout view to import tech file into
    #
    def initialize()
        @layout_view = LayoutView.new
    end

    #
    # Reads the Virtuoso tech file
    #
    def read_virtuoso_tech_file(file_name)
        TechfileToKLayout.import_techfile(@layout_view, file_name)
    end

    #
    # Writes the layer properties file
    #
    def write_layer_properties_file(file_name)
        @layout_view.save_layer_props(file_name)
    end

    #
    # Standalone main driver
    #
    # Uses env vars to get arguments since KLayout doesn't support
    # script-specific arguments (e.g. it thinks that all arguments are for it)
    #
    def KLayoutLayerPropertiesFileGenerator.main
        input_file = ENV["VIRTUOSO_TECH_FILE"]
        output_file = ENV["KLAYOUT_LAYER_PROPERTIES_FILE"]

        if input_file && output_file
            rep = KLayoutLayerPropertiesFileGenerator.new()
            rep.read_virtuoso_tech_file(input_file)
            rep.write_layer_properties_file(output_file)
        else
            puts "Usage: KLayoutLayerPropertiesFileGenerator.rb"
            exit 1
        end
    end
end

#
# Only call the main driver if we're calling this as a script
#
if __FILE__ == $0
    KLayoutLayerPropertiesFileGenerator.main()
end