-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* checkpoint * clean up * remove the unnecessary bundle struct since a vec will do just fine * add note about how the current termination trick is a little dubious
- Loading branch information
1 parent
b1f7d44
commit e8041bd
Showing
3 changed files
with
110 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,31 @@ | ||
use crate::flatten::{ | ||
flat_ir::prelude::{Assignment, AssignmentIdx, GlobalCellIdx}, | ||
structures::context::Context, | ||
}; | ||
use crate::flatten::flat_ir::prelude::{GlobalCellIdx, LocalPortOffset}; | ||
|
||
use super::env::AssignmentRange; | ||
|
||
/// A collection of assignments represented using a series of half-open ranges | ||
/// via [AssignmentRange] | ||
#[derive(Debug)] | ||
pub(crate) struct AssignmentBundle { | ||
assigns: Vec<(GlobalCellIdx, AssignmentRange)>, | ||
pub struct GroupInterfacePorts { | ||
pub go: LocalPortOffset, | ||
pub done: LocalPortOffset, | ||
} | ||
|
||
// TODO griffin: remove the dead stuff later | ||
#[allow(dead_code)] | ||
impl AssignmentBundle { | ||
pub fn new() -> Self { | ||
Self { | ||
assigns: Vec::new(), | ||
} | ||
} | ||
|
||
pub fn with_capacity(size: usize) -> Self { | ||
Self { | ||
assigns: Vec::with_capacity(size), | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn push(&mut self, value: (GlobalCellIdx, AssignmentRange)) { | ||
self.assigns.push(value) | ||
} | ||
|
||
pub fn iter( | ||
&self, | ||
) -> impl Iterator<Item = &(GlobalCellIdx, AssignmentRange)> { | ||
self.assigns.iter() | ||
} | ||
|
||
pub fn iter_over_indices( | ||
&self, | ||
) -> impl Iterator<Item = (GlobalCellIdx, AssignmentIdx)> + '_ { | ||
self.assigns | ||
.iter() | ||
.flat_map(|(c, x)| x.iter().map(|y| (*c, y))) | ||
} | ||
|
||
pub fn iter_over_assignments<'a>( | ||
&'a self, | ||
ctx: &'a Context, | ||
) -> impl Iterator<Item = (GlobalCellIdx, &'a Assignment)> { | ||
self.iter_over_indices() | ||
.map(|(c, idx)| (c, &ctx.primary[idx])) | ||
} | ||
|
||
/// The total number of assignments. Not the total number of index ranges! | ||
pub fn len(&self) -> usize { | ||
self.assigns | ||
.iter() | ||
.fold(0, |acc, (_, range)| acc + range.size()) | ||
} | ||
/// A group of assignments that is scheduled to be evaluated | ||
#[derive(Debug)] | ||
pub struct ScheduledAssignments { | ||
pub active_cell: GlobalCellIdx, | ||
pub assignments: AssignmentRange, | ||
pub interface_ports: Option<GroupInterfacePorts>, | ||
} | ||
|
||
impl FromIterator<(GlobalCellIdx, AssignmentRange)> for AssignmentBundle { | ||
fn from_iter<T: IntoIterator<Item = (GlobalCellIdx, AssignmentRange)>>( | ||
iter: T, | ||
impl ScheduledAssignments { | ||
pub fn new( | ||
active_cell: GlobalCellIdx, | ||
assignments: AssignmentRange, | ||
interface_ports: Option<GroupInterfacePorts>, | ||
) -> Self { | ||
Self { | ||
assigns: iter.into_iter().collect(), | ||
active_cell, | ||
assignments, | ||
interface_ports, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters