Skip to content

Commit 3fb0f3b

Browse files
authored
Merge pull request #161 from antmicro/xdc-port-numbering-fix
xdc: fix port numbering
2 parents b48dda6 + 9cbe9c1 commit 3fb0f3b

File tree

6 files changed

+71
-2
lines changed

6 files changed

+71
-2
lines changed

xdc-plugin/tests/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
# io_loc_pairs - test for LOC property being set on IOBUFs as the IO_LOC_PAIRS parameter
1414
# minilitex_ddr_arty - litex design with more types of IOBUFS including differential
1515
# package_pins - test for PACKAGE_PIN property being set on IOBUFs as the IO_LOC_PAIRS parameter
16+
# non_zero_port_indexes - testing IO_LOC_PAIRS for design with non-zero indexed ports
1617
TESTS = counter \
1718
counter-dict \
1819
package_pins-dict-space \
1920
port_indexes \
2021
io_loc_pairs \
2122
minilitex_ddr_arty \
22-
package_pins
23+
package_pins \
24+
non_zero_port_indexes
2325

2426
include $(shell pwd)/../../Makefile_test.common
2527

@@ -37,3 +39,4 @@ io_loc_pairs_verify = $(call json_test,io_loc_pairs)
3739
minilitex_ddr_arty_verify = $(call json_test,minilitex_ddr_arty)
3840
package_pins_verify = $(call json_test,package_pins)
3941
package_pins-dict-space_verify = $(call json_test,package_pins-dict-space)
42+
non_zero_port_indexes_verify = $(call json_test,non_zero_port_indexes)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$iopadmap$top.LED": {
3+
"IOSTANDARD": "LVCMOS33",
4+
"IO_LOC_PAIRS": "LED[2]:H5"
5+
},
6+
"$iopadmap$top.LED_1": {
7+
"IOSTANDARD": "LVCMOS33",
8+
"IO_LOC_PAIRS": "LED[3]:J5"
9+
},
10+
"$iopadmap$top.LED_2": {
11+
"IOSTANDARD": "LVCMOS33",
12+
"IO_LOC_PAIRS": "LED[4]:T9"
13+
},
14+
"$iopadmap$top.LED_3": {
15+
"IOSTANDARD": "LVCMOS33",
16+
"IO_LOC_PAIRS": "LED[5]:T10"
17+
}
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
yosys -import
2+
if { [info procs get_ports] == {} } { plugin -i design_introspection }
3+
if { [info procs read_xdc] == {} } { plugin -i xdc }
4+
yosys -import ;# ingest plugin commands
5+
6+
read_verilog $::env(DESIGN_TOP).v
7+
8+
read_verilog -lib -specify +/xilinx/cells_sim.v
9+
read_verilog -lib +/xilinx/cells_xtra.v
10+
11+
hierarchy -check -top top
12+
13+
# -flatten is used to ensure that the output eblif has only one module.
14+
# Some of symbiflow expects eblifs with only one module.
15+
synth_xilinx -flatten -abc9 -nosrl -noclkbuf -nodsp -run prepare:check
16+
17+
#Read the design constraints
18+
read_xdc -part_json [file dirname $::env(DESIGN_TOP)]/../xc7a35tcsg324-1.json $::env(DESIGN_TOP).xdc
19+
20+
# Clean processes before writing JSON.
21+
yosys proc
22+
23+
# Write the design in JSON format.
24+
write_json [test_output_path "non_zero_port_indexes.json"]
25+
write_blif -param [test_output_path "non_zero_port_indexes.eblif"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2020-2021 The SymbiFlow Authors.
2+
//
3+
// Use of this source code is governed by a ISC-style
4+
// license that can be found in the LICENSE file or at
5+
// https://opensource.org/licenses/ISC
6+
//
7+
// SPDX-License-Identifier:ISC
8+
9+
module top(
10+
output [5:2] LED
11+
);
12+
13+
assign LED[5:2] = 4'b1010;
14+
15+
endmodule
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set_property -dict { PACKAGE_PIN H5 IOSTANDARD LVCMOS33 } [get_ports { LED[2] }];
2+
set_property -dict { PACKAGE_PIN J5 IOSTANDARD LVCMOS33 } [get_ports { LED[3] }];
3+
set_property -dict { PACKAGE_PIN T9 IOSTANDARD LVCMOS33 } [get_ports { LED[4] }];
4+
set_property -dict { PACKAGE_PIN T10 IOSTANDARD LVCMOS33 } [get_ports { LED[5] }];

xdc-plugin/xdc.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ struct SetProperty : public Pass {
342342
if (signal.is_chunk()) {
343343
auto chunk = signal.as_chunk();
344344
if (chunk.wire) {
345-
return (chunk.wire->name == RTLIL::IdString(RTLIL::escape_id(port))) && (port_bit == chunk.offset);
345+
// chunk.offset is always indexed from 0. Because of that port_bit must be
346+
// corrected with the chunk.wire->start_offset of the port wire in case it is not 0-indexed.
347+
// Not doing this would cause lack of some properties (e.g. IO_LOC_PAIRS) for
348+
// non-0-indexed ports in final eblif file
349+
return (chunk.wire->name == RTLIL::IdString(RTLIL::escape_id(port))) && ((port_bit - chunk.wire->start_offset) == chunk.offset);
346350
}
347351
}
348352
return false;

0 commit comments

Comments
 (0)