Skip to main content

nl_compiler/
error.rs

1/*!
2
3  Error types
4
5*/
6
7use crate::aig::U;
8use std::num::ParseIntError;
9use sv_parser::Locate;
10use thiserror::Error;
11
12/// Errors for Verilog Compilation.
13#[derive(Error, Debug)]
14pub enum VerilogError {
15    /// Errors in parsing ints.
16    #[error("Parsing int error {0} `{1:?}`")]
17    ParseIntError(ParseIntError, Locate),
18    /// Errors in parsing string.
19    #[error("Parsing string error {0:?}")]
20    ParseStrError(Locate),
21    /// A RefNode that was not expected to be compiled.
22    #[error("Unexpected RefNode {0:?} `{1}`")]
23    UnexpectedRefNode(Locate, String),
24    /// A RefNode that is missing.
25    #[error("Missing RefNode `{0}`")]
26    MissingRefNode(String),
27    /// An error originating from `safety-net`.
28    #[error(" `{1}` : {0:?}")]
29    SafetyNetError(Option<Locate>, safety_net::Error),
30    /// An error originating from `sv-parser`.
31    #[error("{0:?}")]
32    ParserError(#[from] sv_parser::Error),
33    /// Any other compilation error
34    #[error(" `{1}` : {0:?}")]
35    Other(Option<Locate>, String),
36}
37
38/// Errors for AIG Compilation.
39#[derive(Error, Debug)]
40pub enum AigError {
41    /// Contains bad state properties.
42    #[error("Contains bad state properties `{0:?}`")]
43    ContainsBadStates(Vec<U>),
44    /// Contains latches.
45    #[error("Contains latches `{0:?}`")]
46    ContainsLatches(Vec<U>),
47    /// Attempted aig contains cycles.
48    #[error("Attempted aig contains cycles")]
49    ContainsCycle,
50    /// Attempted aig contains gates besides AND and INV.
51    #[error("Attempted aig contains gates besides AND and INV")]
52    ContainsOtherGates,
53    /// Attempted aig has disconnected gates.
54    #[error("Attempted aig has disconnected gates.")]
55    DisconnectedGates,
56    /// An error originating from `safety-net`.
57    #[error("Safety net error `{0}`")]
58    SafetyNetError(#[from] safety_net::Error),
59    /// An error originating from `flussab`.
60    #[error("flussab error `{0}`")]
61    FlussabError(#[from] flussab_aiger::aig::AigStructureError<crate::aig::U>),
62    /// An error originating from `io`.
63    #[error("IO error `{0}`")]
64    IoError(#[from] std::io::Error),
65}