Skip to content

Commit

Permalink
Merge pull request #50 from nanobowers/lef_rw_and_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-fritchman authored Jul 15, 2024
2 parents dc82242 + a916b38 commit c771aa7
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 132 deletions.
2 changes: 1 addition & 1 deletion gds21/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn empty_lib_roundtrip() -> GdsResult<()> {
#[test]
fn empty_lib_to_json() -> GdsResult<()> {
let lib = empty_lib();
Json.save(&lib, &resource("empty.gds.json"))
Json.save(&lib, &resource("empty1.gds.json"))
.expect("save failed");
Ok(())
}
Expand Down
157 changes: 90 additions & 67 deletions lef21/resources/lef21.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
},
"LefForeign": {
"title": "Lef Foreign Cell Declaration",
"description": "Declares the linkage to another cell, commonly in DEF or GDSII format. Foreign-cell references are stored exacty as in the LEF format: as a string cell-name. The optional `ORIENT` feature is not supported.",
"description": "Declares the linkage to another cell, commonly in DEF or GDSII format. Foreign-cell references are stored exacty as in the LEF format: as a string cell-name.",
"type": "object",
"required": [
"cell_name"
Expand All @@ -423,11 +423,10 @@
"type": "string"
},
"orient": {
"description": "Orientation (Unsupported)",
"writeOnly": true,
"description": "Orientation",
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
"$ref": "#/definitions/LefOrient"
},
{
"type": "null"
Expand Down Expand Up @@ -585,6 +584,7 @@
"description": "The primary block-level construct comprising each [LefLibrary]. Defines a hardware-block's physical abstract, including: * Pin definitions (`pins`) with locations, directions, and associated metadata * Required blockage-obstructions (`obs`) * A variety of other block-level metadata",
"type": "object",
"required": [
"fixed_mask",
"name"
],
"properties": {
Expand Down Expand Up @@ -612,28 +612,15 @@
]
},
"eeq": {
"description": "Electrically-Equivalent Cell (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Electrically-Equivalent Cell",
"type": [
"string",
"null"
]
},
"fixed_mask": {
"description": "Fixed Mask Option (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
]
"type": "boolean"
},
"foreign": {
"description": "Foreign (i.e. GDSII, DEF) Cell",
Expand Down Expand Up @@ -892,6 +879,67 @@
}
]
},
"LefOrient": {
"description": "Specifies orientation for FOREIGN statement",
"oneOf": [
{
"description": "N",
"type": "string",
"enum": [
"N"
]
},
{
"description": "S",
"type": "string",
"enum": [
"S"
]
},
{
"description": "E",
"type": "string",
"enum": [
"E"
]
},
{
"description": "W",
"type": "string",
"enum": [
"W"
]
},
{
"description": "FN",
"type": "string",
"enum": [
"FN"
]
},
{
"description": "FS",
"type": "string",
"enum": [
"FS"
]
},
{
"description": "FE",
"type": "string",
"enum": [
"FE"
]
},
{
"description": "FW",
"type": "string",
"enum": [
"FW"
]
}
]
},
"LefPadClassType": {
"description": "Sub-Types for Macros of Class [LefMacroClass::Pad]",
"oneOf": [
Expand Down Expand Up @@ -978,43 +1026,28 @@
]
},
"ground_sensitivity": {
"description": "Ground Sensitivity (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Ground Sensitivity",
"type": [
"string",
"null"
]
},
"must_join": {
"description": "Must-Join (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Must-Join",
"type": [
"string",
"null"
]
},
"name": {
"description": "Pin Name",
"type": "string"
},
"net_expr": {
"description": "Net Expression (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Net Expression",
"type": [
"string",
"null"
]
},
"ports": {
Expand Down Expand Up @@ -1048,27 +1081,17 @@
]
},
"supply_sensitivity": {
"description": "Supply Sensitivity (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Supply Sensitivity",
"type": [
"string",
"null"
]
},
"taper_rule": {
"description": "Taper Rule (Unsupported)",
"writeOnly": true,
"anyOf": [
{
"$ref": "#/definitions/Unsupported"
},
{
"type": "null"
}
"description": "Taper Rule",
"type": [
"string",
"null"
]
},
"use": {
Expand Down
34 changes: 34 additions & 0 deletions lef21/src/bin/lefrw.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::error::Error;
use std::env;
use std::process;
use lef21::LefLibrary;

struct Config {
inlef: String,
outlef: String
}

impl Config {
fn new(args: &[String]) -> Result<Config, &'static str> {
if args.len() < 3 {
return Err("Not enough arguments, expecting 2.")
}
let inlef = args[1].clone();
let outlef = args[2].clone();
Ok(Config { inlef, outlef} )
}
}

fn run() -> Result<(), Box<dyn Error>> {
let args : Vec<String> = env::args().collect();
let cfg = Config::new(&args)?;
let lib = LefLibrary::open(cfg.inlef)?;
lib.save(cfg.outlef)?;
Ok(())
}
fn main() {
run().unwrap_or_else(|err| {
println!("Problem in lefrw: {}", err);
process::exit(1);
});
}
Loading

0 comments on commit c771aa7

Please sign in to comment.