cargo fmt
This commit is contained in:
parent
b22c348d8f
commit
0d9abac065
|
@ -1,5 +1,5 @@
|
|||
use crate::frontend::{Callable};
|
||||
use crate::frontend::types::{Type, TypeStruct};
|
||||
use crate::frontend::Callable;
|
||||
use crate::rtlil;
|
||||
use crate::rtlil::SigSpec;
|
||||
|
||||
|
@ -43,14 +43,8 @@ fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ct
|
|||
// FIXME: CRIMES CRIMES CRIMES
|
||||
let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer()));
|
||||
let args = vec![
|
||||
(
|
||||
Some("a".to_owned()),
|
||||
logic_type,
|
||||
),
|
||||
(
|
||||
Some("b".to_owned()),
|
||||
logic_type,
|
||||
),
|
||||
(Some("a".to_owned()), logic_type),
|
||||
(Some("b".to_owned()), logic_type),
|
||||
];
|
||||
Callable {
|
||||
name: name.to_owned(),
|
||||
|
@ -62,10 +56,7 @@ fn make_binop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ct
|
|||
fn make_unnop_callable<'ctx>(name: &str, celltype: &'static str) -> Callable<'ctx> {
|
||||
// FIXME: CRIMES CRIMES CRIMES
|
||||
let logic_type: &'static TypeStruct = Box::leak(Box::new(TypeStruct::logic_infer()));
|
||||
let args = vec![(
|
||||
Some("A".to_owned()),
|
||||
logic_type,
|
||||
)];
|
||||
let args = vec![(Some("A".to_owned()), logic_type)];
|
||||
Callable {
|
||||
name: name.to_owned(),
|
||||
args,
|
||||
|
|
|
@ -38,7 +38,7 @@ enum ElabValueData<'ty> {
|
|||
/// Types that are only valid during Elaboration
|
||||
enum ElabKind {
|
||||
/// general, unsized number type
|
||||
Num
|
||||
Num,
|
||||
}
|
||||
|
||||
/// Helper functions to create primitive types
|
||||
|
@ -48,24 +48,24 @@ impl<'ty> TypeStruct<'ty> {
|
|||
Self {
|
||||
kind: TypeKind::Logic(ElabData {
|
||||
typ: &TypeStruct {
|
||||
kind: TypeKind::ElabType(ElabKind::Num)
|
||||
kind: TypeKind::ElabType(ElabKind::Num),
|
||||
},
|
||||
value: ElabValue::Infer,
|
||||
})
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
/// a logic signal with known width
|
||||
pub fn logic_width(width: u32) -> Self {
|
||||
Self {
|
||||
kind: TypeKind::Logic(ElabData::u32(width))
|
||||
kind: TypeKind::Logic(ElabData::u32(width)),
|
||||
}
|
||||
}
|
||||
|
||||
/// return an elaboration number type
|
||||
pub fn elab_num() -> Self {
|
||||
Self {
|
||||
kind: TypeKind::ElabType(ElabKind::Num)
|
||||
kind: TypeKind::ElabType(ElabKind::Num),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ impl<'ty> ElabData<'ty> {
|
|||
pub fn u32(val: u32) -> Self {
|
||||
Self {
|
||||
typ: &TypeStruct {
|
||||
kind: TypeKind::ElabType(ElabKind::Num)
|
||||
kind: TypeKind::ElabType(ElabKind::Num),
|
||||
},
|
||||
value: ElabValue::Concrete(ElabValueData::U32(val))
|
||||
value: ElabValue::Concrete(ElabValueData::U32(val)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
mod builtin_cells;
|
||||
mod frontend;
|
||||
mod literals;
|
||||
mod package;
|
||||
mod parser;
|
||||
mod rtlil;
|
||||
mod package;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
@ -28,7 +28,11 @@ fn main() {
|
|||
let opt = Opt::from_args();
|
||||
// let mut infile = File::open(opt.input).expect("could not open file");
|
||||
let packages = package::PackageRegistry::new();
|
||||
let mut infile = packages.get("builtins").expect("no package").open().expect("could not open file");
|
||||
let mut infile = packages
|
||||
.get("builtins")
|
||||
.expect("no package")
|
||||
.open()
|
||||
.expect("could not open file");
|
||||
|
||||
let mut input = String::new();
|
||||
infile
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::path::PathBuf;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct Package {
|
||||
name: String,
|
||||
|
@ -15,16 +15,19 @@ impl Package {
|
|||
}
|
||||
|
||||
pub struct PackageRegistry {
|
||||
packages: BTreeMap<String, Package>
|
||||
packages: BTreeMap<String, Package>,
|
||||
}
|
||||
|
||||
impl PackageRegistry {
|
||||
pub fn new() -> Self {
|
||||
let mut packages = BTreeMap::new();
|
||||
packages.insert("builtins".to_string(), Package {
|
||||
packages.insert(
|
||||
"builtins".to_string(),
|
||||
Package {
|
||||
name: "builtins".to_string(),
|
||||
path: "./lib/builtins/".into(),
|
||||
});
|
||||
},
|
||||
);
|
||||
Self { packages }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue