-
Notifications
You must be signed in to change notification settings - Fork 6
Beginning of timing aware optimization using comb-depth and node count #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
danielpenas42
wants to merge
8
commits into
cornell-zhang:main
Choose a base branch
from
danielpenas42:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
61df3a5
new integration with Matts corrected code no tests yet
danielpenas42 8a040ba
using generic I type and including insert_delay_paths in same impl block
danielpenas42 7335358
new tests updated will only work with new safety net implementation
danielpenas42 e24be57
adding tests for timing and fixes
danielpenas42 4bf46aa
Merge branch 'main' into main
danielpenas42 a7a100f
new changes to acommodate driven net
danielpenas42 1c4a4fd
new verilog test
danielpenas42 4d062ac
Small refactor
matth2k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /*! | ||
|
|
||
| Timing analysis helpers for timing-aware optimization flows. | ||
|
|
||
| */ | ||
|
|
||
| use safety_net::DrivenNet; | ||
| use safety_net::Instantiable; | ||
| use safety_net::graph::CombDepthInfo; | ||
| use std::collections::HashSet; | ||
|
|
||
| #[derive(Debug)] | ||
| /// A representative critical path ending at a timing endpoint. | ||
| pub struct DelayPath<I: Instantiable> { | ||
| /// The path from endpoint backward through critical fan-in. | ||
| path: Vec<DrivenNet<I>>, | ||
| } | ||
|
|
||
| impl<I: Instantiable> DelayPath<I> { | ||
| /// Returns the depth/length of the delay path. | ||
| pub fn depth(&self) -> usize { | ||
| self.path.len() | ||
| } | ||
|
|
||
| /// The signal being driven by this path | ||
| pub fn endpoint(&self) -> DrivenNet<I> { | ||
| self.path[0].clone() | ||
| } | ||
|
|
||
| /// The nodes along the delay path as a slice | ||
| pub fn path(&self) -> &[DrivenNet<I>] { | ||
| &self.path | ||
| } | ||
| /// Expands and collects the transitive fan-in along the critical path provided by a branch factor of n. | ||
| pub fn expand_n_nodes(&self, n: usize) -> HashSet<DrivenNet<I>> { | ||
| let mut frontier: Vec<DrivenNet<I>> = self.path().to_vec(); | ||
| let mut expanded_nodes: HashSet<DrivenNet<I>> = frontier.iter().cloned().collect(); | ||
|
|
||
| for _ in 0..n { | ||
| let mut next_frontier = Vec::new(); | ||
|
|
||
| for net in frontier { | ||
| let node = net.unwrap(); | ||
|
|
||
| for input in node.inputs() { | ||
| if let Some(driver) = input.get_driver() | ||
| && expanded_nodes.insert(driver.clone()) | ||
| { | ||
| next_frontier.push(driver); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| frontier = next_frontier; | ||
| } | ||
|
|
||
| expanded_nodes | ||
| } | ||
| } | ||
|
|
||
| impl<I: Instantiable> IntoIterator for DelayPath<I> { | ||
| type Item = DrivenNet<I>; | ||
| type IntoIter = std::vec::IntoIter<DrivenNet<I>>; | ||
|
|
||
| fn into_iter(self) -> Self::IntoIter { | ||
| self.path.into_iter() | ||
| } | ||
| } | ||
|
|
||
| fn build_path_from_endpoint<I: Instantiable>( | ||
| analysis: &CombDepthInfo<'_, I>, | ||
| endpoint: DrivenNet<I>, | ||
| ) -> Option<DelayPath<I>> { | ||
| let mut path = Vec::new(); | ||
| let mut current = endpoint; | ||
|
|
||
| while let Some(crit) = analysis.get_crit_input(¤t.clone().unwrap()) { | ||
| path.push(current.clone()); | ||
| if let Some(c) = crit.get_driver() { | ||
| current = c; | ||
| } else { | ||
| return None; | ||
| } | ||
| } | ||
|
|
||
| path.push(current); | ||
| Some(DelayPath { path }) | ||
| } | ||
|
|
||
| /// Build the critical paths along each critical endpoint | ||
| pub fn get_critical_paths<I: Instantiable>( | ||
| analysis: &CombDepthInfo<'_, I>, | ||
| ) -> impl Iterator<Item = DelayPath<I>> { | ||
| analysis | ||
| .get_critical_points() | ||
| .into_iter() | ||
| .flat_map(|p| build_path_from_endpoint(analysis, p)) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a later PR, we could make these arguments to
insert_delay_paths()top-level command line flags. Leave as is for now.