Skip to content

Commit 0c01cb9

Browse files
authored
Gowin. Fix non-DCS networks. (#1467)
Prohibits the use of Dynamic Clock Selection PIPs for networks where no DCS is present. Signed-off-by: YRabbit <[email protected]>
1 parent 06992bd commit 0c01cb9

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

himbaechel/uarch/gowin/cst.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ struct GowinCstReader
240240
}
241241
};
242242

243-
244-
static void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extra) {
245-
for(auto cst : extra->cst) {
243+
static void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extra)
244+
{
245+
for (auto cst : extra->cst) {
246246
auto it = ctx->cells.find(IdString(cst.net));
247247
if (it == ctx->cells.end()) {
248248
log_info("Cell %s not found\n", IdString(cst.net).c_str(ctx));
@@ -255,7 +255,7 @@ static void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extr
255255
}
256256
it->second->setAttr(IdString(ID_BEL), std::string(ctx->nameOfBel(bel)));
257257

258-
if(cst.iostd > 0) {
258+
if (cst.iostd > 0) {
259259
std::string attr = "&IO_TYPE=";
260260
attr += IdString(cst.iostd).c_str(ctx);
261261
boost::algorithm::to_upper(attr);
@@ -267,8 +267,9 @@ static void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extr
267267
bool gowin_apply_constraints(Context *ctx, std::istream &in)
268268
{
269269
// implicit constraints from SiP pins
270-
if(!ctx->package_info->extra_data.is_null()) {
271-
const Extra_package_data_POD *extra = reinterpret_cast<const Extra_package_data_POD *>(ctx->package_info->extra_data.get());
270+
if (!ctx->package_info->extra_data.is_null()) {
271+
const Extra_package_data_POD *extra =
272+
reinterpret_cast<const Extra_package_data_POD *>(ctx->package_info->extra_data.get());
272273
add_sip_constraints(ctx, extra);
273274
}
274275

himbaechel/uarch/gowin/globals.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ struct GowinGlobalRouter
4444

4545
bool segment_wire_filter(PipId pip) const { return !gwu.is_segment_pip(pip); }
4646

47+
bool dcs_input_filter(PipId pip) const
48+
{
49+
return !ctx->getWireName(ctx->getPipSrcWire(pip))[1].in(
50+
id_P16A, id_P16B, id_P16C, id_P16D, id_P17A, id_P17B, id_P17C, id_P17D, id_P26A, id_P26B, id_P26C,
51+
id_P26D, id_P27A, id_P27B, id_P27C, id_P27D, id_P36A, id_P36B, id_P36C, id_P36D, id_P37A, id_P37B,
52+
id_P37C, id_P37D, id_P46A, id_P46B, id_P46C, id_P46D, id_P47A, id_P47B, id_P47C, id_P47D);
53+
}
54+
4755
// allow io->global, global->global and global->tile clock
4856
bool global_pip_filter(PipId pip, WireId src_wire) const
4957
{
@@ -372,7 +380,7 @@ struct GowinGlobalRouter
372380
RouteResult route_result = route_direct_net(
373381
net,
374382
[&](PipId pip, WireId src_wire) {
375-
return global_DQCE_pip_filter(pip, src) && segment_wire_filter(pip);
383+
return global_DQCE_pip_filter(pip, src) && segment_wire_filter(pip) && dcs_input_filter(pip);
376384
},
377385
src);
378386
if (route_result == NOT_ROUTED) {
@@ -582,11 +590,14 @@ struct GowinGlobalRouter
582590
RouteResult route_result;
583591
if (driver_is_mipi(driver)) {
584592
route_result = route_direct_net(
585-
net, [&](PipId pip, WireId src_wire) { return segment_wire_filter(pip); }, src, &path);
593+
net, [&](PipId pip, WireId src_wire) { return segment_wire_filter(pip) && dcs_input_filter(pip); },
594+
src, &path);
586595
} else {
587596
route_result = route_direct_net(
588597
net,
589-
[&](PipId pip, WireId src_wire) { return global_pip_filter(pip, src) && segment_wire_filter(pip); },
598+
[&](PipId pip, WireId src_wire) {
599+
return global_pip_filter(pip, src) && segment_wire_filter(pip) && dcs_input_filter(pip);
600+
},
590601
src, &path);
591602
}
592603

@@ -659,7 +670,7 @@ struct GowinGlobalRouter
659670
RouteResult route_result = route_direct_net(
660671
net,
661672
[&](PipId pip, WireId src_wire) {
662-
return global_pip_filter(pip, src_wire) && segment_wire_filter(pip);
673+
return global_pip_filter(pip, src_wire) && segment_wire_filter(pip) && dcs_input_filter(pip);
663674
},
664675
src);
665676
if (route_result == NOT_ROUTED || route_result == ROUTED_PARTIALLY) {
@@ -671,8 +682,9 @@ struct GowinGlobalRouter
671682
CellInfo *true_src_ci = net_before_buf->driver.cell;
672683
src = ctx->getBelPinWire(true_src_ci->bel, net_before_buf->driver.port);
673684
ctx->bindWire(src, net, STRENGTH_LOCKED);
674-
backwards_bfs_route(net, src, dst, 1000000, false,
675-
[&](PipId pip, WireId src_wire) { return segment_wire_filter(pip); });
685+
backwards_bfs_route(net, src, dst, 1000000, false, [&](PipId pip, WireId src_wire) {
686+
return segment_wire_filter(pip) && dcs_input_filter(pip);
687+
});
676688
// remove net
677689
buf_ci->movePortTo(id_O, true_src_ci, net_before_buf->driver.port);
678690
net_before_buf->driver.cell = nullptr;
@@ -683,7 +695,7 @@ struct GowinGlobalRouter
683695
void route_clk_net(NetInfo *net)
684696
{
685697
RouteResult route_result = route_direct_net(net, [&](PipId pip, WireId src_wire) {
686-
return global_pip_filter(pip, src_wire) && segment_wire_filter(pip);
698+
return global_pip_filter(pip, src_wire) && segment_wire_filter(pip) && dcs_input_filter(pip);
687699
});
688700
if (route_result != NOT_ROUTED) {
689701
log_info(" '%s' net was routed using global resources %s.\n", ctx->nameOf(net),
@@ -788,7 +800,8 @@ struct GowinGlobalRouter
788800
log_info(" %s\n", ctx->nameOfWire(gatewire));
789801
}
790802
routed = backwards_bfs_route(
791-
ni, src_wire, gatewire, 1000000, false, [&](PipId pip, WireId src) { return true; }, &bound_pips);
803+
ni, src_wire, gatewire, 1000000, false,
804+
[&](PipId pip, WireId src) { return dcs_input_filter(pip); }, &bound_pips);
792805
if (routed) {
793806
// bind src
794807
if (ctx->checkWireAvail(src_wire)) {

0 commit comments

Comments
 (0)