1#![allow(dead_code)]
2
3use crate::client::bridge::VirtuosoClient;
4use crate::client::layout_ops::LayoutOps;
5use crate::client::schematic_ops::SchematicOps;
6use crate::error::Result;
7use crate::models::VirtuosoResult;
8
9pub struct LayoutEditor<'a> {
10 client: &'a VirtuosoClient,
11 lib: String,
12 cell: String,
13 commands: Vec<String>,
14}
15
16impl<'a> LayoutEditor<'a> {
17 pub fn new(client: &'a VirtuosoClient, lib: &str, cell: &str) -> Self {
18 Self {
19 client,
20 lib: lib.into(),
21 cell: cell.into(),
22 commands: Vec::new(),
23 }
24 }
25
26 pub fn add_rect(&mut self, layer: &str, purpose: &str, bbox: [(i64, i64); 2]) {
27 let ops = LayoutOps;
28 self.commands.push(ops.create_rect(layer, purpose, &bbox));
29 }
30
31 pub fn add_polygon(&mut self, layer: &str, purpose: &str, points: Vec<(i64, i64)>) {
32 let ops = LayoutOps;
33 self.commands
34 .push(ops.create_polygon(layer, purpose, &points));
35 }
36
37 pub fn add_path(&mut self, layer: &str, purpose: &str, width: i64, points: Vec<(i64, i64)>) {
38 let ops = LayoutOps;
39 self.commands
40 .push(ops.create_path(layer, purpose, width, &points));
41 }
42
43 pub fn add_via(&mut self, via_def: &str, origin: (i64, i64)) {
44 let ops = LayoutOps;
45 self.commands.push(ops.create_via(via_def, origin));
46 }
47
48 pub fn add_instance(
49 &mut self,
50 lib: &str,
51 cell: &str,
52 view: &str,
53 origin: (i64, i64),
54 orient: &str,
55 ) {
56 let ops = LayoutOps;
57 self.commands
58 .push(ops.create_instance(lib, cell, view, origin, orient));
59 }
60
61 pub fn execute(self) -> Result<VirtuosoResult> {
62 self.client.execute_operations(&self.commands)
63 }
64}
65
66pub struct SchematicEditor<'a> {
67 client: &'a VirtuosoClient,
68 commands: Vec<String>,
69}
70
71impl<'a> SchematicEditor<'a> {
72 pub fn new(client: &'a VirtuosoClient) -> Self {
73 Self {
74 client,
75 commands: Vec::new(),
76 }
77 }
78
79 pub fn add_instance(
80 &mut self,
81 lib: &str,
82 cell: &str,
83 view: &str,
84 name: &str,
85 origin: (i64, i64),
86 orient: &str,
87 ) {
88 let ops = SchematicOps;
89 self.commands
90 .push(ops.create_instance(lib, cell, view, name, origin, orient));
91 }
92
93 pub fn add_wire(&mut self, points: Vec<(i64, i64)>, layer: &str, net_name: &str) {
94 let ops = SchematicOps;
95 self.commands
96 .push(ops.create_wire(&points, layer, net_name));
97 }
98
99 pub fn add_label(&mut self, net_name: &str, origin: (i64, i64)) {
100 let ops = SchematicOps;
101 self.commands.push(ops.create_wire_label(net_name, origin));
102 }
103
104 pub fn add_pin(&mut self, net_name: &str, pin_type: &str, origin: (i64, i64)) {
105 let ops = SchematicOps;
106 self.commands
107 .push(ops.create_pin(net_name, pin_type, origin));
108 }
109
110 pub fn set_param(&mut self, inst_name: &str, param: &str, value: &str) {
111 let ops = SchematicOps;
112 self.commands
113 .push(ops.set_instance_param(inst_name, param, value));
114 }
115
116 pub fn assign_net(&mut self, inst_name: &str, term_name: &str, net_name: &str) {
117 let ops = SchematicOps;
118 self.commands
119 .push(ops.assign_net(inst_name, term_name, net_name));
120 }
121
122 pub fn execute(self) -> Result<VirtuosoResult> {
123 self.client.execute_operations(&self.commands)
124 }
125}