Skip to content

Commit

Permalink
Merge pull request #167 from mabrains/updating_klayout_menues
Browse files Browse the repository at this point in the history
updating klayout dropdown menues
  • Loading branch information
FaragElsayed2 authored Aug 7, 2023
2 parents dbc1440 + f294871 commit 654fb8c
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 412 deletions.
11 changes: 11 additions & 0 deletions rules/klayout/macros/drc_options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
drc_mode: ''
run_mode: "--run_mode=flat"
variant: "--variant=C"
top_cell_name: ''
run_dir: ''
verbose: ''
feol: ''
beol: ''
offgrid: ''
connectivity: ''
52 changes: 51 additions & 1 deletion rules/klayout/macros/gf180mcu_drc.lydrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<doc/>
<autorun>false</autorun>
<autorun-early>false</autorun-early>
<priority>0</priority>
<shortcut/>
<show-in-menu>true</show-in-menu>
<group-name/>
Expand All @@ -29,7 +30,56 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'yaml'


## reading the parent directory of the current file
run_dir = File.expand_path("..", __dir__)

## reading the loaded gds file path
layout_path = Pathname.new(RBA::CellView.active.filename)
layout_dir = layout_path.split()[0]

## read saved options from yaml file
options = YAML.load(File.read(__dir__ + "/drc_options.yml"))

## create options passed to run_drc.py
options_str = "#{options["drc_mode"]} #{options["run_mode"]} #{options["variant"]} #{options["top_cell_name"]} #{options["verbose"]} #{options["feol"]} #{options["beol"]} #{options["offgrid"]} #{options["connectivity"]} #{options["run_dir"]}"

## run_drc command line
cmd = "python3 #{run_dir}/drc/run_drc.py --path=#{layout_path} #{options_str}"

## start running drc
puts "######### running #{cmd}"
drc_res = `#{cmd}`

## read the log of drc run to get output lydb file paths if run_dir option is disables
gds_name = layout_path.split()[1].to_s.split(".")[0]

if options["run_dir"] == ""
File.open(__dir__ + "/drc_res.txt", "w") { |file| file.write(drc_res) }
lydb_path = File.readlines(__dir__ + "/drc_res.txt")[3].split(/ /)[-1]
File.delete(__dir__ + "/drc_res.txt")
lydb_dir = lydb_path.to_s().split("/#{gds_name}")[0]
else
lydb_dir = options["run_dir"].split("=")[1]
end


## choose the displayed database file
if options["drc_mode"] == "--antenna_only"
lydb_file = "#{gds_name}_antenna.lyrdb"

elsif options["drc_mode"] == "--density_only"
lydb_file = "#{gds_name}_density.lyrdb"

else
lydb_file = "#{gds_name}_main.lyrdb"

end

## open a klayout window with database loaded
`klayout #{layout_path} -m #{lydb_dir}/#{lydb_file}`

# %include ../drc/gf180mcu.drc
</text>
</klayout-macro>
52 changes: 51 additions & 1 deletion rules/klayout/macros/gf180mcu_lvs.lylvs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<doc/>
<autorun>false</autorun>
<autorun-early>false</autorun-early>
<priority>0</priority>
<shortcut/>
<show-in-menu>true</show-in-menu>
<group-name/>
Expand All @@ -30,6 +31,55 @@
# limitations under the License.


# %include ../lvs/gf180mcu.lvs
require 'yaml'

## reading the parent directory of the current file
run_dir = File.expand_path("..", __dir__)

## reading the loaded gds file path
layout_path = Pathname.new(RBA::CellView.active.filename)

## read saved options from yaml file
options = YAML.load(File.read(__dir__ + "/lvs_options.yml"))

## reading netlist option to get netlist_path
if options["netlist"] == ""
net_name = layout_path.split()[1].to_s().split(".")[0]

net_dir = "#{layout_path.split()[0]}/#{net_name}.cdl"

else
net_dir = options["netlist"]

end

## create options passed to run_drc.py
options_str = "--lvs_sub=#{options["sub_name"]} #{options["run_mode"]} #{options["variant"]} #{options["top_cell_name"]} #{options["spice_net"]} #{options["spice_comment"]} #{options["verbose"]} #{options["schematic_simple"]} #{options["net_only"]} #{options["top_lvl_pins"]} #{options["combine"]} #{options["purge"]} #{options["purge_nets"]} #{options["run_dir"]}"

## run_drc command line
cmd = "python3 #{run_dir}/lvs/run_lvs.py --layout=#{layout_path} --netlist=#{net_dir} #{options_str}"

## start running drc
puts "######### running #{cmd}"
lvs_res = `#{cmd}`

## read the log of lvs run to get output lydb file paths if run_dir option is disables
gds_name = layout_path.split()[1].to_s.split(".")[0]

if options["run_dir"] == ""
File.open(__dir__ + "/lvs_res.txt", "w") { |file| file.write(lvs_res) }
lydb_path = File.readlines(__dir__ + "/lvs_res.txt")[3].split(/ /)[-1]
File.delete(__dir__ + "/lvs_res.txt")
lydb_dir = lydb_path.to_s().split("/#{gds_name}")[0]
else
lydb_dir = options["run_dir"].split("=")[1]
end

lydb_file = "#{gds_name}.lvsdb"


## open a klayout window with database loaded
`klayout #{layout_path} -mn #{lydb_dir}/#{lydb_file}`

</text>
</klayout-macro>
Loading

0 comments on commit 654fb8c

Please sign in to comment.