Skip to content
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

Himbaechel Gowin: HCLK Support #1340

Merged
merged 6 commits into from
Aug 3, 2024
Merged

Conversation

Seyviour
Copy link
Contributor

HCLK Support

This pull request introduces support for the CLKDIV and CLKDIV2 BELs in Gowin FPGAs. The implementation has been successfully tested on the GW2AR-18 and GW1N-9C models and is expected to be compatible with (most) other Gowin devices as well.

This PR implements a custom placer for CLKDIV/CLKDIV2 (place_constrained_hclk_cells) due to the nature of the implicit constraints around placing them. Said placer uses bipartite matching so this PR also adds some code to support that. Every other change is, by my observation, par for the course for adding support for new bels.

Here's a link to the companion PR on Apicula: YosysHQ/apicula#258

@Seyviour Seyviour changed the title HCLK Support Himbaechel Gowin: HCLK Support Jul 10, 2024
@@ -166,6 +194,27 @@ struct GowinCstReader
}
}
} break;
case hclk: {
IdString cell_type = it->second->type;
if (cell_type != IdString(ID_CLKDIV)) {
Copy link
Member

Choose a reason for hiding this comment

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

id_CLKDIV instead of IdString(ID_CLKDIV)

auto ci = cell.second.get();
if (ci->type == id_CLKDIV) {
NetInfo *in = ci->getPort(id_HCLKIN);
CellInfo *this_driver = in->driver.cell;
Copy link
Member

Choose a reason for hiding this comment

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

this should probably have some error handling for the case of HCLKIN being disconnected/undriven, i.e. either in or in->driver.cell being nullptr

if (out->users.entries() > 1) {
// We could do as the IDE does sometimes and replicate the CLKDIV2 cell
// as many times as we need. For now, we keep things simple
log_error("CLKDIV2 that drives CLKDIV should drive no other cells");
Copy link
Member

Choose a reason for hiding this comment

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

log messages always need to end in \n

@gatecat
Copy link
Member

gatecat commented Jul 11, 2024

This all looks reasonable to me - @yrabbit do you have any thoughts?

@yrabbit
Copy link
Contributor

yrabbit commented Jul 11, 2024

This all looks reasonable to me - @yrabbit do you have any thoughts?

I don't see anything criminal. It's unusual for me to see something in the prePlace() function, there is probably some philosophical reason for this :)
So this is a good advancement - we will get a simple DVI encoder.

@Seyviour
Copy link
Contributor Author

Thank you, @gatecat. I've added the null checks and corrected the log statement.

@Seyviour
Copy link
Contributor Author

Seyviour commented Jul 11, 2024

This all looks reasonable to me - @yrabbit do you have any thoughts?

I don't see anything criminal. It's unusual for me to see something in the prePlace() function, there is probably some philosophical reason for this :)
So this is a good advancement - we will get a simple DVI encoder.

prePlace seemed like a fitting home, especially with having to store some info in GowinImpl. The other option was to put it in pack, but that felt off to me 🤔.

Video always feels magical! :)

@gatecat
Copy link
Member

gatecat commented Jul 11, 2024

Should this be merged before or after the apicula PR?

@Seyviour
Copy link
Contributor Author

I think it's best to wait for Apicula. I'll add a comment here when the PR there gets merged.

Thanks for all the work you've put into nextpnr, @gatecat 🙌

inline bool type_is_clkdiv2(IdString cell_type) { return cell_type == id_CLKDIV2; }
inline bool is_clkdiv2(const CellInfo *cell) { return type_is_clkdiv2(cell->type); }

// Return true for HCLK BELs
Copy link
Contributor

Choose a reason for hiding this comment

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

cells

@pepijndevos
Copy link
Member

Should this be merged before or after the apicula PR?

Apicula CI wont pass until this is merged, so I'd prefer to merge this first.

@Seyviour
Copy link
Contributor Author

There's a bug here that I need to address. Please don't merge yet.

@Seyviour
Copy link
Contributor Author

Seyviour commented Aug 1, 2024

There's a bug here that I need to address. Please don't merge yet.

All clear now.

@pepijndevos
Copy link
Member

Seems like there is a merge conflict

@Seyviour
Copy link
Contributor Author

Seyviour commented Aug 3, 2024

Seems like there is a merge conflict

I've now resolved it

@gatecat gatecat merged commit e9e7dce into YosysHQ:master Aug 3, 2024
8 checks passed
@gatecat
Copy link
Member

gatecat commented Aug 3, 2024

Thanks!

@Seyviour
Copy link
Contributor Author

Seyviour commented Aug 3, 2024

It's my pleasure. Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants