2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 * (C) 2019 Eddie Hung <eddie@fpgeh.com>
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include "kernel/register.h"
22 #include "kernel/celltypes.h"
23 #include "kernel/rtlil.h"
24 #include "kernel/log.h"
27 PRIVATE_NAMESPACE_BEGIN
29 struct XilinxFinalisePass
: public Pass
31 XilinxFinalisePass() : Pass("xilinx_finalise", "") { }
33 void help() YS_OVERRIDE
35 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
37 log(" xilinx_finalise [options]\n");
41 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
44 for (argidx
= 1; argidx
< args
.size(); argidx
++)
48 extra_args(args
, argidx
, design
);
50 log_header(design
, "Executing XILINX_FINALISE pass.\n");
52 for (auto module
: design
->selected_modules())
53 for (auto cell
: module
->selected_cells()) {
54 if (cell
->type
!= ID(DSP48E1
))
56 for (auto &conn
: cell
->connections_
) {
57 if (!cell
->output(conn
.first
))
60 for (auto &chunk
: conn
.second
.chunks()) {
61 auto it
= chunk
.wire
->attributes
.find(ID(unused_bits
));
62 if (it
== chunk
.wire
->attributes
.end())
65 std::string unused_bits
= stringf("%d", chunk
.offset
);
66 for (auto i
= 1; i
< chunk
.width
; i
++)
67 unused_bits
+= stringf(" %d", i
+chunk
.offset
);
69 if (it
->second
.decode_string().find(unused_bits
) == std::string::npos
) {
76 log_debug("Purging unused port connection %s %s (.%s(%s))\n", cell
->type
.c_str(), log_id(cell
), log_id(conn
.first
), log_signal(conn
.second
));
77 conn
.second
= SigSpec();