Skip to content

Commit

Permalink
Deterministic order for raw -> proto exports. Docs, badges, readme up…
Browse files Browse the repository at this point in the history
…dates
  • Loading branch information
dan-fritchman committed Sep 16, 2021
1 parent bc50822 commit fa49275
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 47 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/rust.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

# Custom Additions
**/resources/
scratch/

# Generated by Cargo
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ members = [
"layout21protos",
"layout21raw",
"layout21tetris",
"layout21meta",
"layout21",
"layout21utils",
]
1 change: 0 additions & 1 deletion gds21/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ use chrono::prelude::*;
use chrono::{Datelike, NaiveDate, NaiveDateTime};
use derive_more::{Add, AddAssign, Sub, SubAssign};
use enum_dispatch::enum_dispatch;
use memmap::Mmap;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use serde::{Deserialize, Serialize};
Expand Down
4 changes: 4 additions & 0 deletions gds21/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
//! # Gds21 Reading & Scanning
//!
// Crates.io
use memmap::Mmap;

// Local imports
use super::*;

/// Size (in bytes) of the read/decode buffer array
Expand Down
4 changes: 2 additions & 2 deletions layout21meta/Cargo.toml → layout21/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
description = "Layout21 Meta-Crate, re-exporting all internally defined crates"
name = "layout21meta"
description = "Layout21 Integrated Circuit Layout. Meta-crate, re-exporting several internally defined crates"
name = "layout21"
# Shared layout21 attributes
authors = ["Dan Fritchman <dan@fritch.mn>"]
edition = "2018"
Expand Down
File renamed without changes.
Binary file added layout21raw/resources/dff1_lib.bin
Binary file not shown.
File renamed without changes.
Empty file added layout21raw/resources/empty
Empty file.
9 changes: 6 additions & 3 deletions layout21raw/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl<'lib> ProtoExporter<'lib> {
// Collect up shapes by layer
// FIXME: should we store them here this way in the first place? Perhaps.
let mut layers: HashMap<(i16, i16), Vec<&Element>> = HashMap::new();
let mut layerorder: Vec<(i16, i16)> = Vec::new();
for elem in &cell.elems {
let selflayers = self.lib.layers.read()?;
let layer = selflayers.get(elem.layer).ok_or("Invalid Layer")?;
Expand All @@ -172,14 +173,16 @@ impl<'lib> ProtoExporter<'lib> {
layers.get_mut(&(number, purpose)).unwrap().push(elem);
} else {
layers.insert((number, purpose), vec![elem]);
layerorder.push((number, purpose));
}
}
// Now turn those into [proto::LayerShape]s
for (layernum, elems) in layers {
for layernums in layerorder {
let elems = layers.get(&layernums).unwrap();
let mut layershape = proto::LayerShapes::default();
layershape.layer = Some(proto::Layer {
number: layernum.0 as i64,
purpose: layernum.1 as i64,
number: layernums.0 as i64,
purpose: layernums.1 as i64,
});
for elem in elems {
// Also sort into the proto-schema's by-shape-type vectors
Expand Down
17 changes: 13 additions & 4 deletions layout21raw/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,28 @@ fn resource(fname: &str) -> String {
#[cfg(all(feature = "gds", feature = "proto"))]
#[test]
fn test_gds_to_proto1() -> LayoutResult<()> {
let samp = resource("sample1.gds");
// let samp = "/Users/dan/dev/ucb/osci/OsciBear/gds/user_analog_project_wrapper.gds";
// Read a GDS file
let samp = resource("dff1_lib.gds");
let gds = gds::gds21::GdsLibrary::load(&samp)?;

// Convert to Layout21::Raw
let lib = gds::GdsImporter::import(&gds, None)?;
assert_eq!(lib.name, "dff1_lib");
assert_eq!(lib.cells.len(), 1);

// Get the first (and only) cell
let cell = lib.cells.first().unwrap().clone();
let cell = cell.read()?;
assert_eq!(cell.name, "dff1");

// Convert to ProtoBuf
let p = proto::ProtoExporter::export(&lib)?;
assert_eq!(p.domain, "dff1_lib");
proto::proto::save(&p, &resource("something.bin")).unwrap();
let p2 = proto::proto::open(&resource("something.bin")).unwrap();
let p2 = proto::ProtoExporter::export(&lib)?;
assert_eq!(p, p2);

// And compare against the golden version
let p2 = proto::proto::open(&resource("dff1_lib.bin")).unwrap();
assert_eq!(p, p2);
Ok(())
}
4 changes: 0 additions & 4 deletions layout21tetris/.gitignore

This file was deleted.

22 changes: 12 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@

Custom integrated circuit layout.

[![test](https://github.com/dan-fritchman/Layout21/actions/workflows/test.yml/badge.svg)](https://github.com/dan-fritchman/Layout21/actions/workflows/test.yml)

* A layered suite of layout-data formats, each expressed in the ProtoBuf schema description language.
* Libraries for compiling from more abstract and terse such expressions into more-detailed.
* Exchange with industry-standard formats such as [GDSII](./gds21) and [LEF](./lef21).

Each of the internally-defined layout21 compilers, parsers and generators are implemented in [Rust](https://www.rust-lang.org/). Cross-language compatibility of the underlying ProtoBuf-based data schema allows for usage in most other popular languages.
Each of the internally-defined `layout21` compilers, parsers and generators are implemented in [Rust](https://www.rust-lang.org/). Cross-language compatibility of the underlying [ProtoBuf](https://developers.google.com/protocol-buffers)-based data schema allows for usage in most other popular languages.

Like most large Rust projects layout21 is a multi-crate workspace. Some internal crates are publicly available through [crates.io](https://crates.io). The "top-level" [layout21meta](./layout21meta) crate includes dependencies on all, and is the easiest entry-point for using all `layout21` functionality. In `layout21meta`'s namespace and in documentation most child-crates are referred to by their suffixes, i.e. `layout21::raw`.
Like most large Rust projects `layout21` is a multi-crate workspace. Some internal crates are publicly available through [crates.io](https://crates.io). The "top-level" [layout21](./layout21) crate includes dependencies on all, and is the easiest entry-point for using all `layout21` functionality. In `layout21`'s namespace and in documentation most child-crates are referred to by their suffixes, i.e. `layout21::raw`.

| Crate | Description | [crates.io](https://crates.io) / [docs.rs](https://docs.rs) |
| ----------- | ----------- | ----------- |
| [gds21](./gds21) | GDSII Parsing, Generation, and Manipulation | ![](https://docs.rs/gds21/badge.svg) |
| [lef21](./lef21) | LEF Parsing, Generation, and Manipulation | |
| [layout21protos](./layout21protos) | Protobuf Schema Definitions | |
| [layout21raw](./layout21raw) | "Raw" geometric layout, analogous to most existing layout systems. | |
| [layout21tetris](./layout21tetris) | Gridded gate-array-style semi-custom layout | |
[layout21meta](./layout21meta) | Meta-crate including all of the above | |
| Crate | Description | [crates.io](https://crates.io) | [docs.rs](https://docs.rs) |
| ----------- | ----------- | ------------------------------ | -------------------------- |
| [gds21](./gds21) | GDSII Parsing, Generation, and Manipulation | [![](https://img.shields.io/crates/v/gds21.svg)](https://crates.io/crates/gds21) | [![](https://docs.rs/gds21/badge.svg)](https://docs.rs/gds21) |
| [lef21](./lef21) | LEF Parsing, Generation, and Manipulation | | |
| [layout21protos](./layout21protos) | Protobuf Schema Definitions | | |
| [layout21raw](./layout21raw) | "Raw" geometric layout. Analogous to most existing layout systems. | | |
| [layout21tetris](./layout21tetris) | Gridded gate-array-style semi-custom layout | | |
| [layout21](./layout21) | Meta-crate including all of the above | | |

0 comments on commit fa49275

Please # to comment.