Skip to content

XDC physical constraints with TCL interpreter. #15

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
wants to merge 20 commits into
base: acom/fpga-interchange-rr-graph+constants
Choose a base branch
from

Conversation

kboronski-ant
Copy link
Member

@kboronski-ant kboronski-ant commented Apr 21, 2022

This PR adds handling of physical constraints expressed via an XDC file.

Supported commands:

  • get_ports
    • by single name
    • by multiple names (multiarg call)
  • set_property
    • PACKAGE_PIN (for single port)
    • IOSTANDARD (for any number of ports)

Description

Adds an embedded TCL interpreter and a C++ abstraction layer over its C interface, which is used to implement XDC constraints reader. The reader creates VprConstraints that reflect the constraints described in XDC and modifies AtomNetlist to change block properties accordingly.

To read an XDC file, use --xdc_file <filename> option.

Related Issue

(will add later)

Motivation and Context

The current constrain system doesn't allow constraining IOs without knowing exactly what blocks are the going to be. It is also specific to VPR, while XDC seems to be a much more universal format.

How Has This Been Tested?

Manually constraining testarch IOs for LUT design from fpga-interchange-tests and checking results in GUI.

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Copy link

@acomodi acomodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I have added some initial comments below.

@@ -976,7 +976,7 @@ struct t_mode {
* input_string: input string verbatim to parse later
* output_string: input string output to parse later
* annotations: Annotations for delay, power, etc
* num_annotations: Total number of annotations
* num_annotations: Total number opb_typef annotations
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a typo

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo still needs fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my typo, will fix in another commit.

@@ -97,6 +99,7 @@ void SetupVPR(const t_options* Options,
FileNameOpts->CmosTechFile = Options->CmosTechFile;
FileNameOpts->out_file_prefix = Options->out_file_prefix;
FileNameOpts->read_vpr_constraints_file = Options->read_vpr_constraints_file;
FileNameOpts->read_xdc_constraints_file = Options->XDCFile;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid having an option that is strictly related to XDC, or any other constraint file type.

I think it may be better to use the already present read_vpr_constraints_file, and maybe rename it to read_constraints_file and, based on the extension of this file, choose the right way to parse it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure about it.
Currently we need BOTH SDC and XDC files, because a separate parser for SDC exists. Ideally both XDC and SDC should use the same backend for reading the files. I mean, we could maybe allow passing both of these files with a single flag, but there would be a hard limit of two files of different format, something I've never seen being done with a CLI interface. Alternatively we can allow reading more XDC files and thus make the flag accept any number of paths. Vivado (and F4PGA) allow reading multiple XDCs, so...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that we'd need to add one option for each kind of different constraint files that we provide. The constraint that we are considering here though is only a placement constraint kind of file. We do not care about the SDC at the moment, as it is parsed differently and does not concern constraining blocks to specific locations.

Just imagine that we'll add support for PCF and other kinds of constraint files. We'd need to invoke VPR with a different option everytime. Having instead a dynamic way of determining what is the type of constraint (for now based on the extension of the constraint file), allows us to avoid having multiple options that in the end are doing the same thing, e.g. telling VPR that there is a constraint file to parse.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I'm leaving it at having separate argument. We don't infer architecture format from file extension, so why should we do that for constraints. Additionally, I made it possible to pass multiple XDC constraint files (the flag is now called --xdc_files).

Comment on lines 197 to 226
/* TODO: this assumes there's only one port, which just happens to be true in case of fpga interchange.
* If we want to handle it better, we should return a list of port ids instead.
*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok assume that there is one and only one port. I'd rather add an assert that verifies that the block_ports returned are actually of size == 1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An assert would be good, but a explaining why it's here and why it's valid should remain imo. The TODO might be a bit misleading tho, because this isn't going to need any work, unless we end up having more ports per block in the future.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sounds good, a brief explanation might be good. The fact is that the get_ports, for our use case at the moment, will only refer to a single PAD.

An improvement to this might be to accept some regex as pin name, which will lead to find more than one port and, for instance, assign the same IOSTANDARD. For now, though, we can keep as a single port only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be done by the user in TCL. We could replace AtomPortId returned by get_ports with a list of AtomPortIds and make it accept a list of strings instead. This way the user could generate that list using a regexp or whatever else in TCL.

Copy link

@acomodi acomodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can proceed by preparing a PR to upstream. I think that these changes do not really require the RR graph PR (which is still pending to be reviewed upstream), therefore we may open a PR with these isolated changes, unless something from the RR graph generation is required.

We can have the discussion about the options to read in the XDC, on whether to have multiple options or one option, with the correct call to be made after analyzing the file extension.

Please, resolve all the conversations you think are solved and fix the remaining ones before opening the PR to upstream.

@github-actions github-actions bot added the infra label Apr 27, 2022
@acomodi acomodi force-pushed the acom/fpga-interchange-rr-graph+constants branch from e686856 to f2ae4e5 Compare May 2, 2022 07:30
@kboronski-ant kboronski-ant force-pushed the kbor/xdc-interchange branch from 07d15e2 to 1cec573 Compare May 2, 2022 11:50
…ations and bind them to selected ports

Signed-off-by: Krzysztof Boronski <[email protected]>
…from XDC command implementation

Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
…perty: handle lists of ports.

Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Signed-off-by: Krzysztof Boronski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants