-
Notifications
You must be signed in to change notification settings - Fork 60
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
10
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 all commits
Commits
Show all changes
10 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
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
Binary file not shown.
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,65 @@ | ||
| 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 | ||
|
|
||
|
|
||
| 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" | ||
| "Output is a JSON serialization of the Common Data Format." | ||
| ), | ||
| 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)", | ||
| ) | ||
| 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.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,72 @@ | ||
| 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 | ||
|
|
||
|
|
||
| type YosysRsrc = dict[str, int] | ||
| """ | ||
| Yosys resources for a cell. | ||
| """ | ||
|
|
||
|
|
||
| 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.
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.
Might be worth describing what the
intvalue is referring to here!