Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fud2/scripts/synth-verilog-to-report.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn synth_setup(e) {
// Python scripts for parsing reports for visualization and extracting JSON summary
e.rule("parse-rpt", "synthrep viz -t flamegraph -f $in > $out");
e.rule("extract-util-json", "synthrep summary -m utilization > $out");
e.rule("extract-hierarchy-json", "synthrep summary -m hierarchy > $out");
e.rule("extract-hierarchy-json", "aext vivado out/hierarchical_utilization_placed.rpt > $out");
}

fn flamegraph_setup(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

flamegraph-script = /test/calyx/non-existent.script
create-visuals-script = $calyx-base/tools/profiler/create-visuals.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

build main.sv: copy /input.ext
build device.xdc: copy $device_xdc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

build main.sv: copy /input.ext
build device.xdc: copy $device_xdc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

build main.sv: copy /input.ext
build device.xdc: copy $device_xdc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

build main.sv: copy /input.ext
build device.xdc: copy $device_xdc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rule parse-rpt
rule extract-util-json
command = synthrep summary -m utilization > $out
rule extract-hierarchy-json
command = synthrep summary -m hierarchy > $out
command = aext vivado out/hierarchical_utilization_placed.rpt > $out

build main.sv: copy /input.ext
build device.xdc: copy $device_xdc
Expand Down
Binary file added graph.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions tools/AreaExtract/AreaExtract/__init__.py
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.
65 changes: 65 additions & 0 deletions tools/AreaExtract/AreaExtract/bin/extract.py
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.
72 changes: 72 additions & 0 deletions tools/AreaExtract/AreaExtract/lib/cdf/cdf.py
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.
Copy link
Contributor

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 int value is referring to here!

"""


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.
Loading
Loading