-
Notifications
You must be signed in to change notification settings - Fork 64
AreaExtract — tool to extract and process area data from different sources #2576
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
pedropontesgarcia
wants to merge
26
commits into
main
Choose a base branch
from
area-profiler/AreaExtract
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 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
dfc2a68
WIP area profiler heuristic from Yosys
e9c7687
Better readme with Yosys info
2d79725
Merge remote-tracking branch 'origin/main' into area-profiler/heuristic
014eefe
created AreaExtract
bba6794
README and rhai script
7bd52bb
Updated profiler to parse CDF
e857b99
Merge remote-tracking branch 'origin/main' into area-profiler/AreaExt…
a9274a6
Insta tests for fud2
e477cf3
Formatted code
23603c1
Formatted code
8938475
Removed all previous iterations of area extraction code, and updated …
439d810
Resolved Ayaka's comments
268f636
Merge remote-tracking branch 'origin/main' into area-profiler/AreaExt…
6faad23
oops deleted a little too much!
843541f
updated commands and tests
773f2a8
Reviewed insta
3088ce5
fixed python formatting
2cf0d81
Added test cases
7b2c8ff
Merge remote-tracking branch 'origin/main' into area-profiler/AreaExt…
253597a
Add AreaExtract to Dockerfile?
ayakayorihiro d0b99ed
Delete graph.pdf
pedropontesgarcia 31dd84a
Merge branch 'main' into area-profiler/AreaExtract
ayakayorihiro b28639f
Use older version of type aliasing
ayakayorihiro 2e9b8b1
Fixing format issues
ayakayorihiro e0e814b
modify dockerfile to trigger ci update?
ayakayorihiro f85fa58
Add missing json file for yosys test
ayakayorihiro 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
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
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,4 @@ | ||
| """AreaExtract is a tool to extract area information from synthesis data | ||
| and compile it in a Common Data Format.""" | ||
|
|
||
| __version__ = "0.1.0" |
Empty file.
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,82 @@ | ||
| import argparse | ||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from AreaExtract.lib.parse.vivado import rpt_to_design_with_metadata | ||
| from AreaExtract.lib.parse.yosys import il_to_design_with_metadata | ||
| from AreaExtract.lib.plot.plot import save_plot | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description=( | ||
| "Parse FPGA synthesis reports into a Common Data Format.\n\n" | ||
| "Supported origins:\n" | ||
| " - Vivado: single hierarchical .rpt file\n" | ||
| " - Yosys: .il (intermediate language) and .json (stat) file\n\n" | ||
| "Supported outputs:\n" | ||
| " - CDF: JSON serialization of the Common Data Format.\n" | ||
| " - Visualizations: HTML hierarchical area-only visualizations." | ||
| ), | ||
| formatter_class=argparse.RawTextHelpFormatter, | ||
| ) | ||
| subparsers = parser.add_subparsers(dest="origin", required=True) | ||
| vivado = subparsers.add_parser( | ||
| "vivado", | ||
| help="parse a Vivado utilization .rpt file", | ||
| ) | ||
| vivado.add_argument( | ||
| "rpt", | ||
| type=Path, | ||
| help="path to Vivado utilization report (.rpt)", | ||
| ) | ||
| yosys = subparsers.add_parser( | ||
| "yosys", | ||
| help="parse Yosys IL and stat JSON files", | ||
| ) | ||
| yosys.add_argument( | ||
| "il", | ||
| type=Path, | ||
| help="path to Yosys IL file (.il)", | ||
| ) | ||
| yosys.add_argument( | ||
| "json", | ||
| type=Path, | ||
| help="path to Yosys stat file (.json)", | ||
| ) | ||
| parser.add_argument( | ||
| "-o", | ||
| "--output", | ||
| type=Path, | ||
| help="optional output file for JSON (defaults to stdout)", | ||
| ) | ||
| parser.add_argument( | ||
| "-v", | ||
| "--visual", | ||
| type=Path, | ||
| help="save visualizations to folder (not done by default)", | ||
| ) | ||
| parser.add_argument( | ||
| "-c", | ||
| "--column", | ||
| type=Path, | ||
| help="column to visualize (defaults to 'ff' for Vivado, 'width' for Yosys)", | ||
| ) | ||
| args = parser.parse_args() | ||
| if args.origin == "vivado": | ||
| design = rpt_to_design_with_metadata(args.rpt) | ||
| elif args.origin == "yosys": | ||
| design = il_to_design_with_metadata(args.il, args.json) | ||
| else: | ||
| parser.error("unknown origin") | ||
| json_str = json.dumps(design, default=lambda o: o.__dict__, indent=2) | ||
| if args.visual: | ||
| save_plot(design, args.visual, args.column) | ||
| if args.output: | ||
| args.output.write_text(json_str) | ||
| else: | ||
| print(json_str) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Empty file.
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,75 @@ | ||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass | ||
| class VivadoRsrc: | ||
| """ | ||
| Vivado resources for a cell. | ||
| """ | ||
|
|
||
| lut: int | ||
| llut: int | ||
| lutram: int | ||
| srl: int | ||
| ff: int | ||
| ramb36: int | ||
| ramb18: int | ||
| uram: int | ||
| dsp: int | ||
|
|
||
| def __getitem__(self, item): | ||
| return getattr(self, item) | ||
|
|
||
|
|
||
| type YosysRsrc = dict[str, int] | ||
| """ | ||
| Yosys resources for a cell, mapping resource name (e.g. "width") to integer value. | ||
| """ | ||
|
|
||
|
|
||
| type Rsrc = VivadoRsrc | YosysRsrc | ||
| """ | ||
| Map representing resources used by a cell. | ||
| """ | ||
|
|
||
|
|
||
| @dataclass | ||
| class Cell: | ||
| """ | ||
| Cell with resources. | ||
| """ | ||
|
|
||
| # Unqualified cell name. | ||
| name: str | ||
| # Cell type. | ||
| type: str | ||
| # Whether the cell was generated in synthesis. | ||
| generated: bool | ||
| # Cell resources. | ||
| rsrc: Rsrc | ||
|
|
||
|
|
||
| @dataclass | ||
| class Metadata: | ||
| """ | ||
| Design metadata. | ||
| """ | ||
|
|
||
| # Origin of the design (Vivado, Yosys). | ||
| origin: str | ||
|
|
||
|
|
||
| type Design = dict[str, Cell] | ||
| """ | ||
| Design with qualified cell names and associated cells. | ||
| """ | ||
|
|
||
|
|
||
| @dataclass | ||
| class DesignWithMetadata: | ||
| """ | ||
| Design with metadata. | ||
| """ | ||
|
|
||
| design: Design | ||
| metadata: Metadata |
Empty file.
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.
Uh oh!
There was an error while loading. Please reload this page.