forked from patrickschulz/openPCells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
70 lines (58 loc) · 1.76 KB
/
main.lua
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
-- for random shuffle
math.randomseed(os.time())
-- load user configuration
config.get_user_config()
local techlib = _load_module("technology")
local interface = _load_module("interface")
-- parse command line arguments
local argparse = _load_module("argparse")
local args = argparse.parse(arg)
-- prepare cell arguments
local cellargs = {}
for k, v in string.gmatch(table.concat(args.cellargs, " "), "([%w/._]+)%s*=%s*(%S+)") do
cellargs[k] = v
end
if not args.cell then
error("no cell type given")
end
-- output cell parameters
if args.params then
local sep = args.separator or "\n"
local params = pcell.parameters(args.cell)
io.write(table.concat(params, sep) .. sep)
os.exit(0)
end
if not args.notech and not args.technology then
error("no technology given")
end
if not args.interface then
error("no interface given")
end
if not args.notech then
techlib.load(args.technology)
end
interface.load(args.interface)
local cell, msg = pcell.create_layout(args.cell, cellargs, true)
if not cell then
error(string.format("error while creating cell, received: %s", msg))
end
if args.origin then
local dx, dy = string.match(args.origin, "%(%s*([-%d]+)%s*,%s*([-%d]+)%s*%)")
if not dx then
error(string.format("could not parse origin (%s)", args.origin))
end
cell:translate(dx, dy)
end
abstract.realize_shapes()
local techintf = interface.get_techinterface() or args.interface
if not args.notech then
techlib.translate_metals(cell)
techlib.split_vias(cell)
techlib.place_via_conductors(cell, techintf)
techlib.translate(cell, techintf)
techlib.fix_to_grid(cell)
end
local filename = args.filename or "openPCells"
interface.set_options(args.interface_options)
interface.write_cell(filename, cell)
-- vim: ft=lua