Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[registries]
substrate = { index = "https://github.com/substrate-labs/crates-index" }
43 changes: 43 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2
updates:
# Rust dependencies
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
groups:
cargo-updates:
patterns:
- "*"
cargo-security:
applies-to: security-updates
patterns:
- "*"
open-pull-requests-limit: 2
labels:
- "dependencies"
- "rust"
commit-message:
prefix: "chore"
include: "scope"

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
groups:
github-actions-updates:
patterns:
- "*"
open-pull-requests-limit: 2
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "ci"
include: "scope"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
name: Build, lint, and test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install -y ngspice
- name: Clone external dependencies
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: substrate-labs/skywater-pdk
path: skywater-pdk
Expand Down
3 changes: 0 additions & 3 deletions codegen/src/hard_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ struct HardMacroArgs {
name: String,
pdk: String,
path_fn: Ident,
#[darling(default)]
spice_subckt_name: Option<String>,
#[darling(default)]
gds_cell_name: Option<String>,
#[darling(default)]
toml_fn: Option<Ident>,
}

Expand Down
2 changes: 1 addition & 1 deletion libs/gds21/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ byteorder = "1.4.3"
chrono = { version = "0.4.24", features = ["serde"] }
derive_builder = "0.9.0"
derive_more = "0.99.17"
num-derive = "0.3"
num-derive = "0.4"
num-traits = "0.2.15"
serde = { version = "1.0.159", features = ["derive"] }
serde_derive = "1.0.159"
Expand Down
8 changes: 4 additions & 4 deletions libs/gds21/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl GdsFloat64 {
let mantissa: f64 = mantissa as f64 / 2f64.powi(8 * 7);
// Combine everything into our overall value
if neg {
-1.0 * mantissa * 16f64.powi(exp)
-mantissa * 16f64.powi(exp)
} else {
mantissa * 16f64.powi(exp)
}
Expand Down Expand Up @@ -438,7 +438,7 @@ impl GdsPoint {
pts.iter().map(|pt| Self::new(pt.0, pt.1)).collect()
}
/// Convert from a two-element vector
fn parse(from: &Vec<i32>) -> GdsResult<Self> {
fn parse(from: &[i32]) -> GdsResult<Self> {
if from.len() != 2 {
return Err(GdsError::Str(
"GdsPoint coordinate vector: Invalid number of elements".into(),
Expand All @@ -451,7 +451,7 @@ impl GdsPoint {
}
/// Convert an n-element vector if `i32` into an n/2-element vector of [GdsPoint]s.
fn parse_vec(from: &[i32]) -> GdsResult<Vec<GdsPoint>> {
if from.len() % 2 != 0 {
if !from.len().is_multiple_of(2) {
return Err(GdsError::Str(
"GdsPoint coordinate vector: Invalid number of elements".into(),
));
Expand All @@ -470,7 +470,7 @@ impl GdsPoint {
vec![self.x, self.y]
}
/// Convert an n-element vector of [GdsPoint]s to a 2n-element i32 vector.
fn flatten_vec(src: &Vec<GdsPoint>) -> Vec<i32> {
fn flatten_vec(src: &[GdsPoint]) -> Vec<i32> {
let mut rv = Vec::with_capacity(src.len() * 2);
for pt in src.iter() {
rv.push(pt.x);
Expand Down
2 changes: 1 addition & 1 deletion libs/gds21/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait SerdeFile: Serialize + DeserializeOwned {

/// Wrapper over other errors
#[derive(Debug)]
pub struct Error(Box<dyn std::error::Error + Send + Sync>);
pub struct Error(#[allow(dead_code)] Box<dyn std::error::Error + Send + Sync>);
impl std::fmt::Display for Error {
/// Delegate [std::fmt::Display] to the (derived) [std::fmt::Debug] implementation.
/// Maybe more info that wanted in some cases. But certainly enough.
Expand Down
3 changes: 2 additions & 1 deletion libs/gds21/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ trait Encode {
}
self.encode_record(GdsRecord::Layer(box_.layer))?;
self.encode_record(GdsRecord::BoxType(box_.boxtype))?;
self.encode_record(GdsRecord::Xy(GdsPoint::flatten_vec(&box_.xy.to_vec())))?;
self.encode_record(GdsRecord::Xy(GdsPoint::flatten_vec(&box_.xy)))?;
for prop in box_.properties.iter() {
self.encode_record(GdsRecord::PropAttr(prop.attr))?;
self.encode_record(GdsRecord::PropValue(prop.value.clone()))?;
Expand All @@ -482,6 +482,7 @@ trait Encode {
/// # GdsRecordList
/// A largely for-testing implementer of the [Encode] trait,
/// which collects the generated records into a vector.
#[allow(dead_code)]
#[derive(Default, Debug, Deserialize, Serialize)]
pub struct GdsRecordList {
pub records: Vec<GdsRecord>,
Expand Down
14 changes: 7 additions & 7 deletions libs/subgeom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,17 +1192,17 @@ impl Rect {
///
/// The exact behavior depends on the provided [`ExpandMode`]:
/// * [`ExpandMode::All`]: expands the top and bottom edges by `dims.h()`
/// and the left and right edges by `dims.w()`.
/// Note that the total horizontal expansion is `2 * dims.w()` and the
/// total vertical expansion is `2 * dims.h()`.
/// and the left and right edges by `dims.w()`.
/// Note that the total horizontal expansion is `2 * dims.w()` and the
/// total vertical expansion is `2 * dims.h()`.
/// * [`ExpandMode::LowerLeft`]: expands the lower edge by `dims.h()` and
/// the left edge by `dims.w()`.
/// the left edge by `dims.w()`.
/// * [`ExpandMode::LowerRight`]: expands the lower edge by `dims.h()` and
/// the right edge by `dims.w()`.
/// the right edge by `dims.w()`.
/// * [`ExpandMode::UpperLeft`]: expands the upper edge by `dims.h()` and
/// the left edge by `dims.w()`.
/// the left edge by `dims.w()`.
/// * [`ExpandMode::UpperRight`]: expands the upper edge by `dims.h()` and
/// the right edge by `dims.w()`.
/// the right edge by `dims.w()`.
///
/// See [`Dims`] for more information.
pub fn expand_dims(self, dims: Dims, mode: ExpandMode) -> Self {
Expand Down
1 change: 1 addition & 0 deletions libs/subgeom/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Transformation {
/// * (a) Reflect vertically, then
/// * (b) Translate by (1,1)
/// * (c) Place a point at (local coordinate) (1,1)
///
/// Lands said point at (2,-2) in top-level space,
/// whereas reversing the order of (a) and (b) lands it at (2,0).
pub fn cascade(parent: Transformation, child: Transformation) -> Transformation {
Expand Down
4 changes: 2 additions & 2 deletions libs/sublut/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
pub fn get(&self, k1: &K1, k2: &K2) -> Option<&V> {
let i1 = self.k1.partition_point(|k| k < k1);
let i2 = self.k2.partition_point(|k| k < k2);
if k1 < self.k1.get(0)? || k2 < self.k2.get(0)? {
if k1 < self.k1.first()? || k2 < self.k2.first()? {
return None;
}
self.values.get(i1)?.get(i2)
Expand All @@ -67,7 +67,7 @@ impl FloatLut2 {
self.k1
.iter()
.copied()
.zip(interp1.into_iter())
.zip(interp1)
.map(|(k, v)| Key::new(k, v, splines::Interpolation::Linear))
.collect(),
)
Expand Down
2 changes: 1 addition & 1 deletion plugins/spectre/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn dc_conv(parsed_data: PsfDcData) -> DcData {
PsfDcData::Sweep(data) => HashMap::from_iter(
data.signals
.into_iter()
.chain([(data.sweep_var, data.sweep_values)].into_iter())
.chain([(data.sweep_var, data.sweep_values)])
.map(|(k, v)| {
(
k,
Expand Down
8 changes: 4 additions & 4 deletions plugins/spice_rawfile/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn parse_f64(input: &[u8]) -> Result<f64, Err<Error<&[u8]>>> {
Ok(value)
}

fn variable(input: &[u8]) -> IResult<&[u8], Variable> {
fn variable(input: &[u8]) -> IResult<&[u8], Variable<'_>> {
let value = take_till1(is_space_or_line);
// In AC analysis, may have a `grid=X` declaration
let grid = opt(pair(space1, &value));
Expand All @@ -143,7 +143,7 @@ fn variable(input: &[u8]) -> IResult<&[u8], Variable> {
Ok((input, Variable { idx, name, unit }))
}

fn variables(input: &[u8]) -> IResult<&[u8], Vec<Variable>> {
fn variables(input: &[u8]) -> IResult<&[u8], Vec<Variable<'_>>> {
let (input, _) = tuple((tag_no_case("Variables:"), space0, line_ending))(input)?;
let (input, vars) = many0(variable)(input)?;
Ok((input, vars))
Expand Down Expand Up @@ -243,7 +243,7 @@ fn complex_data(input: &[u8], vars: usize, points: usize) -> IResult<&[u8], Data
))(input)
}

fn analysis(input: &[u8]) -> IResult<&[u8], Analysis> {
fn analysis(input: &[u8]) -> IResult<&[u8], Analysis<'_>> {
let (input, title) = header(input, "Title: ")?;
let (input, date) = header(input, "Date: ")?;
let (input, plotname) = header(input, "Plotname: ")?;
Expand Down Expand Up @@ -275,6 +275,6 @@ fn analysis(input: &[u8]) -> IResult<&[u8], Analysis> {
))
}

pub(crate) fn analyses(input: &[u8]) -> IResult<&[u8], Vec<Analysis>> {
pub(crate) fn analyses(input: &[u8]) -> IResult<&[u8], Vec<Analysis<'_>>> {
many0(analysis)(input)
}
6 changes: 3 additions & 3 deletions plugins/subspice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ where

impl<'a> ParsedSpice<'a> {
/// Return an iterator over the lines in the parsed SPICE netlist.
pub fn lines(&self) -> impl Iterator<Item = &SpiceLine> {
pub fn lines(&self) -> impl Iterator<Item = &SpiceLine<'_>> {
self.lines.iter()
}

/// Return an iterator over the subcircuit definitions in the netlist.
pub fn subcircuits(&self) -> impl Iterator<Item = &SubcktLine> {
pub fn subcircuits(&self) -> impl Iterator<Item = &SubcktLine<'_>> {
self.lines.iter().filter_map(|line| line.subckt())
}

Expand All @@ -40,7 +40,7 @@ impl<'a> ParsedSpice<'a> {
/// If you need to query for multiple subcircuits, you may wish to
/// collect the [`subcircuits`](ParsedSpice::subcircuits) into a
/// [`HashMap`](std::collections::HashMap), and query the map instead.
pub fn subcircuit_named(&self, name: impl AsRef<str>) -> Option<&SubcktLine> {
pub fn subcircuit_named(&self, name: impl AsRef<str>) -> Option<&SubcktLine<'_>> {
let name = name.as_ref();
self.subcircuits().find(|ckt| ckt.name == name)
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/subspice/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum SpiceLine<'a> {
}

impl<'a> SpiceLine<'a> {
pub fn subckt(&self) -> Option<&SubcktLine> {
pub fn subckt(&self) -> Option<&SubcktLine<'_>> {
match self {
SpiceLine::Subckt(line) => Some(line),
_ => None,
Expand Down Expand Up @@ -87,28 +87,28 @@ fn subckt_name(input: &str) -> IResult<&str, &str> {
preceded(spice_space1, ident)(input)
}

fn subckt_line(input: &str) -> IResult<&str, SpiceLine> {
fn subckt_line(input: &str) -> IResult<&str, SpiceLine<'_>> {
let (input, (_, name, ports)) =
tuple((tag_no_case(".subckt"), subckt_name, subckt_ports))(input)?;

Ok((input, SpiceLine::Subckt(SubcktLine { name, ports })))
}

fn comment_line(input: &str) -> IResult<&str, SpiceLine> {
fn comment_line(input: &str) -> IResult<&str, SpiceLine<'_>> {
let (input, (_, _, comment, _)) =
tuple((space0, tag_no_case("*"), take_till(is_newline), line_ending))(input)?;
Ok((input, SpiceLine::Comment(comment.trim())))
}

fn other_line(input: &str) -> IResult<&str, SpiceLine> {
fn other_line(input: &str) -> IResult<&str, SpiceLine<'_>> {
let (input, _) = pair(ident, many0(preceded(ident, spice_space1)))(input)?;
Ok((input, SpiceLine::Other))
}

fn spice_line(input: &str) -> IResult<&str, SpiceLine> {
fn spice_line(input: &str) -> IResult<&str, SpiceLine<'_>> {
alt((subckt_line, comment_line, other_line))(input)
}

pub(crate) fn parse_spice(input: &str) -> IResult<&str, Vec<SpiceLine>> {
pub(crate) fn parse_spice(input: &str) -> IResult<&str, Vec<SpiceLine<'_>>> {
many0(delimited(multispace0, spice_line, multispace0))(input)
}
2 changes: 1 addition & 1 deletion substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Rahul Kumar <rahulkumar@berkeley.edu>", "Rohan Kumar <rohankumar@ber
derive_builder = { version = "0.12.0", features = ["clippy"] }
serde = { version = "1", features = ["derive", "rc"] }
slotmap = { version = "1.0.6", features = ["serde"] }
tempdir = "0.3.7"
tempfile = "3.10"
thiserror = "1.0.40"
enum_dispatch = "0.3.11"
arcstr = { version = "1.1.5", features = ["serde"] }
Expand Down
10 changes: 6 additions & 4 deletions substrate/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};

use serde::{Deserialize, Serialize};
use tempdir::TempDir;
use tempfile::TempDir;

use crate::component::{Component, View};
use crate::deps::arcstr::ArcStr;
Expand Down Expand Up @@ -239,16 +239,18 @@ impl SubstrateConfigBuilder {

impl SubstrateCtx {
#[inline]
pub(crate) fn read(&self) -> RwLockReadGuard<SubstrateData> {
pub(crate) fn read(&self) -> RwLockReadGuard<'_, SubstrateData> {
self.inner.read().unwrap()
}

#[inline]
pub(crate) fn write(&self) -> RwLockWriteGuard<SubstrateData> {
pub(crate) fn write(&self) -> RwLockWriteGuard<'_, SubstrateData> {
self.inner.write().unwrap()
}

#[inline]
// `SubstrateData` is not `Send`/`Sync`; `Arc` is kept so the public type doesn't change.
#[allow(clippy::arc_with_non_send_sync)]
pub fn from_config(cfg: SubstrateConfig) -> Result<Self> {
Ok(Self {
inner: Arc::new(RwLock::new(SubstrateData::from_config(cfg)?)),
Expand Down Expand Up @@ -859,7 +861,7 @@ impl SubstrateCtx {
where
T: Testbench,
{
let work_dir = TempDir::new("subsim")?;
let work_dir = TempDir::with_prefix("subsim")?;
let work_dir = work_dir.path();
self.write_simulation::<T>(params, work_dir)
}
Expand Down
3 changes: 2 additions & 1 deletion substrate/src/deps.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub use {arcstr, serde};
pub use arcstr;
pub use serde;
7 changes: 5 additions & 2 deletions substrate/src/digital/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ impl WireDb {
}
}

pub(crate) fn inner(&self) -> RwLockReadGuard<WireDbInner> {
pub(crate) fn inner(&self) -> RwLockReadGuard<'_, WireDbInner> {
self.inner.read().unwrap()
}

pub(crate) fn inner_mut(&self) -> RwLockWriteGuard<WireDbInner> {
pub(crate) fn inner_mut(&self) -> RwLockWriteGuard<'_, WireDbInner> {
self.inner.write().unwrap()
}
}
Expand Down Expand Up @@ -96,11 +96,14 @@ pub(crate) enum WireValue {
BinOp(Op, WireKey, WireKey),
#[allow(unused)]
Cast(HardwareType, WireKey),
#[allow(unused)]
Port(ArcStr),
/// Concatenation of wires in MSB order.
Concat(WireKey, WireKey),
/// Slice of wire.
#[allow(unused)]
Slice(Range<usize>, WireKey),
#[allow(unused)]
Reg(Reg),
/// Output of an instance.
InstanceOutput,
Expand Down
2 changes: 1 addition & 1 deletion substrate/src/fmt/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn get_regex(format: BusFmt) -> Regex {
regex
}

pub fn parse_bus(text: &str, format: BusFmt) -> std::result::Result<ParsedBus, ParseBusError> {
pub fn parse_bus(text: &str, format: BusFmt) -> std::result::Result<ParsedBus<'_>, ParseBusError> {
let re = get_regex(format);
let caps = re
.captures(text.trim())
Expand Down
Loading
Loading