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