futilehdl/src/frontend/typed_ir.rs

36 lines
721 B
Rust
Raw Normal View History

2022-02-15 20:32:55 +00:00
use super::types::Type;
/// ID of a definition (e.g. variable, block, function)
#[derive(Debug, Clone, Copy)]
pub struct DefId(pub u32);
#[derive(Debug, Clone, Copy)]
pub struct ExprId(pub u32);
2022-01-30 22:54:19 +00:00
2022-02-06 22:19:55 +00:00
/// an abstract element that performs some kind of computation on inputs
2022-02-15 20:32:55 +00:00
#[derive(Debug, Clone)]
pub struct Expr {
pub id: ExprId,
pub kind: ExprKind,
pub typ: Type,
}
#[derive(Debug, Clone)]
pub enum ExprKind {
Literal,
Path(DefId),
Call { called: DefId, args: Vec<Expr> },
2022-01-30 22:54:19 +00:00
}
2022-02-15 20:32:55 +00:00
#[derive(Debug, Clone)]
pub struct Signal {
pub id: DefId,
pub typ: Type,
2022-01-30 22:54:19 +00:00
}
2022-02-06 22:19:55 +00:00
/// A block of HDL code, e.g. comb block
2022-02-15 20:32:55 +00:00
#[derive(Debug, Clone)]
pub struct Block {
pub signals: Vec<Signal>,
pub expr: Expr,
2022-02-06 22:19:55 +00:00
}