#[derive(Clone, Debug)]
pub enum IO {
Input(usize),
Output(usize),
InOut(usize),
}
impl IO {
pub fn width(&self) -> usize {
match self {
IO::Input(width) => *width,
IO::Output(width) => *width,
IO::InOut(width) => *width,
}
}
pub fn flip(&self) -> IO {
match self {
IO::Input(width) => IO::Output(*width),
IO::Output(width) => IO::Input(*width),
IO::InOut(width) => IO::InOut(*width),
}
}
pub fn with_width(&self, width: usize) -> IO {
match self {
IO::Input(_) => IO::Input(width),
IO::Output(_) => IO::Output(width),
IO::InOut(_) => IO::InOut(width),
}
}
pub fn to_def_direction(&self) -> String {
match self {
IO::Input(_) => "INPUT",
IO::Output(_) => "OUTPUT",
IO::InOut(_) => "INOUT",
}
.to_string()
}
pub fn to_lef_direction(&self) -> String {
match self {
IO::Input(_) => "INPUT",
IO::Output(_) => "OUTPUT",
IO::InOut(_) => "INOUT",
}
.to_string()
}
}