Skip to content

Commit 6f47200

Browse files
committed
export text to GDS
1 parent 7bd5b88 commit 6f47200

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

core/compiler/src/gds.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use std::{io::BufReader, ops::Deref, path::Path};
22

3-
use anyhow::{Result, anyhow};
3+
use anyhow::{anyhow, Result};
44
use gds21::{
5-
GdsBoundary, GdsElement, GdsLayerSpec, GdsLibrary, GdsPoint, GdsStrans, GdsStruct, GdsStructRef,
5+
GdsBoundary, GdsElement, GdsLayerSpec, GdsLibrary, GdsPoint, GdsStrans, GdsStruct,
6+
GdsStructRef, GdsTextElem,
67
};
78
use indexmap::IndexMap;
89
use regex::Regex;
@@ -141,6 +142,21 @@ impl CompiledData {
141142
}));
142143
}
143144
}
145+
SolvedValue::Text(text) => {
146+
let GdsLayerSpec {
147+
layer,
148+
xtype: texttype,
149+
} = exporter.map[&text.layer];
150+
let x = text.x as i32;
151+
let y = text.y as i32;
152+
ocell.elems.push(GdsElement::GdsTextElem(GdsTextElem {
153+
string: text.text.clone(),
154+
layer,
155+
texttype,
156+
xy: GdsPoint::new(x, y),
157+
..Default::default()
158+
}));
159+
}
144160
SolvedValue::Instance(i) => {
145161
self.cell_to_gds(exporter, i.cell)?;
146162
ocell.elems.push(GdsElement::GdsStructRef(GdsStructRef {

core/compiler/src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod tests {
1919
use approx::assert_relative_eq;
2020
use const_format::concatcp;
2121

22-
use crate::compile::{CellArg, CompileInput, compile};
22+
use crate::compile::{compile, CellArg, CompileInput};
2323
const EPSILON: f64 = 1e-10;
2424

2525
const EXAMPLES_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../examples");
@@ -672,15 +672,24 @@ mod tests {
672672
CompileInput {
673673
cell: &["top"],
674674
args: Vec::new(),
675-
lyp_file: &PathBuf::from(BASIC_LYP),
675+
lyp_file: &PathBuf::from(SKY130_LYP),
676676
},
677677
);
678678
println!("{cells:#?}");
679+
680+
let work_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("build/argon_text");
681+
cells
682+
.to_gds(
683+
GdsMap::from_lyp(SKY130_LYP).expect("failed to create GDS map"),
684+
work_dir.join("layout.gds"),
685+
)
686+
.expect("Failed to write to GDS");
687+
679688
let cells = cells.unwrap_valid();
680689
let cell = &cells.cells[&cells.top];
681-
assert_eq!(cell.objects.len(), 1);
690+
assert_eq!(cell.objects.len(), 2);
682691
let t = cell.objects.iter().find_map(|(_, v)| v.get_text()).unwrap();
683-
assert_eq!(t.layer, "met1");
692+
assert_eq!(t.layer, "met1.label");
684693
assert_eq!(t.text, "mytext");
685694
assert_relative_eq!(t.x, 0., epsilon = EPSILON);
686695
assert_relative_eq!(t.y, 10., epsilon = EPSILON);

examples/text/lib.ar

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cell top() {
2-
text("mytext", "met1", 0., 10.);
2+
rect("met1.drawing", x0=-100., y0=-100., x1=100., y1=100.);
3+
text("mytext", "met1.label", 0., 10.);
34
}

0 commit comments

Comments
 (0)