prjxray/utils/mergedb.sh

334 lines
8.4 KiB
Bash
Raw Normal View History

#!/bin/bash
# Copyright (C) 2017-2020 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
# $1: DB type
# $2: filename to merge in
set -ex
test $# = 2
test -e "$2"
tmp1=`mktemp -p .`
tmp2=`mktemp -p .`
LOCKFILE="/tmp/segbits_$1.db.lock"
LOCKTIMEOUT=30 # 30s timeout
LOCKID=222
function finish {
echo "Cleaning up temp files"
rm -f "$tmp1"
rm -f "$tmp2"
}
trap finish EXIT
db=$XRAY_DATABASE_DIR/$XRAY_DATABASE/segbits_$1.db
# if the DB exists acquire a lock
if [ -f $db ]; then
eval "exec $LOCKID>$LOCKFILE"
# the lock is automatically released on script exit
flock --timeout $LOCKTIMEOUT $LOCKID
if [ ! $? -eq 0 ]; then
echo "Timeout while waiting for lock"
finish
exit 1
fi
fi
# Check existing DB
if [ -f $db ] ; then
${XRAY_PARSEDB} --strict "$db"
fi
# Check new DB
${XRAY_PARSEDB} --strict "$2"
# Fuzzers verify L/R data is equivilent
# However, expand back to L/R to make downstream tools not depend on this
# in case we later find exceptions
ismask=false
case "$1" in
clbll_l)
sed < "$2" > "$tmp1" \
-e 's/^CLB\.SLICE_X0\./CLBLL_L.SLICEL_X0./' \
-e 's/^CLB\.SLICE_X1\./CLBLL_L.SLICEL_X1./' ;;
clbll_r)
sed < "$2" > "$tmp1" \
-e 's/^CLB\.SLICE_X0\./CLBLL_R.SLICEL_X0./' \
-e 's/^CLB\.SLICE_X1\./CLBLL_R.SLICEL_X1./' ;;
clblm_l)
sed < "$2" > "$tmp1" \
-e 's/^CLB\.SLICE_X0\./CLBLM_L.SLICEM_X0./' \
-e 's/^CLB\.SLICE_X1\./CLBLM_L.SLICEL_X1./' ;;
clblm_r)
sed < "$2" > "$tmp1" \
-e 's/^CLB\.SLICE_X0\./CLBLM_R.SLICEM_X0./' \
-e 's/^CLB\.SLICE_X1\./CLBLM_R.SLICEL_X1./' ;;
dsp_l)
sed < "$2" > "$tmp1" -e 's/^DSP\./DSP_L./' ;;
dsp_r)
sed < "$2" > "$tmp1" -e 's/^DSP\./DSP_R./' ;;
bram_l)
sed < "$2" > "$tmp1" -e 's/^BRAM\./BRAM_L./' ;;
bram_r)
sed < "$2" > "$tmp1" -e 's/^BRAM\./BRAM_R./' ;;
bram_l.block_ram)
sed < "$2" > "$tmp1" -e 's/^BRAM\./BRAM_L./' ;;
bram_r.block_ram)
sed < "$2" > "$tmp1" -e 's/^BRAM\./BRAM_R./' ;;
int_l)
sed < "$2" > "$tmp1" -e 's/^INT\./INT_L./' ;;
int_r)
sed < "$2" > "$tmp1" -e 's/^INT\./INT_R./' ;;
hclk_l)
sed < "$2" > "$tmp1" -e 's/^HCLK\./HCLK_L./' ;;
hclk_r)
sed < "$2" > "$tmp1" -e 's/^HCLK\./HCLK_R./' ;;
clk_hrow_bot_r)
sed < "$2" > "$tmp1" -e 's/^CLK_HROW\./CLK_HROW_BOT_R./' ;;
clk_hrow_top_r)
sed < "$2" > "$tmp1" -e 's/^CLK_HROW\./CLK_HROW_TOP_R./' ;;
clk_bufg_bot_r)
sed < "$2" > "$tmp1" -e 's/^CLK_BUFG\./CLK_BUFG_BOT_R./' ;;
clk_bufg_top_r)
sed < "$2" > "$tmp1" -e 's/^CLK_BUFG\./CLK_BUFG_TOP_R./' ;;
hclk_cmt)
cp "$2" "$tmp1" ;;
hclk_cmt_l)
sed < "$2" > "$tmp1" -e 's/^HCLK_CMT\./HCLK_CMT_L./' ;;
clk_bufg_rebuf)
cp "$2" "$tmp1" ;;
liob33)
sed < "$2" > "$tmp1" -e 's/^IOB33\./LIOB33./' ;;
riob33)
sed < "$2" > "$tmp1" -e 's/^IOB33\./RIOB33./' ;;
riob18)
sed < "$2" > "$tmp1" -e 's/^IOB18\./RIOB18./' ;;
virtex7: HP-bank glue codified end-to-end + open-flow validation The open-flow (Yosys → nextpnr-xilinx → FASM → bitstream) now produces silicon-functional bits on VC707 xc7vx485tffg1761-2 for: - rst_to_led (IBUF↔OBUF passthrough) - counter_skewfree (button-clocked 8b counter, general routing) - counter_sw_bufr (button → BUFR → 8b counter) - counter_bufr (200 MHz LVDS sysclk → IBUFDS → BUFR → 8b counter) - counter_2bufg (2× BUFGCTRL on the same source) - vc707_telegraph (125 MHz crystal → IBUFDS_GTE2 → BUFG → UART smoke test) - vc707_picosoc (picorv32 + simpleuart + BRAM @ 125 MHz; UART prints 'PicoSoC alive on VC707 @ 125 MHz' on /dev/ttyUSB0) Highlights of this drop: utils/fasm2frames.py (+223 net): - Bank-glue auto-injection for HP-bank IOB18 — IBUF/OBUF (Y0+Y1) + IBUFDS differential pair. Fires off the FASM-level direction heuristic (.IN/.IN_ONLY/IBUFDISABLE for IBUF, .DRIVE. for OBUF, .IN_DIFF for IBUFDS; .SLEW. is unreliable as a marker — gets emitted on default-state IOBs too). - INT_L_X32Y49 DCI cascade / bank-active markers when any LIOB18_X81 Y1 OBUF is present. - PUDC_B emission rewritten for HP-bank IOSTANDARDs (10 features cover Y0 + Y1 default-state; all 9 historic 'PUDC_B glue' bits flow naturally from the existing IOSTANDARD segbits). - HCLK_L per-BUFRCLK-channel 'active' marker — currently codified for BUFRCLK3 (the channel exercised by counter_sw_bufr). - GFAN T-tie root glue — INT_L_X62Y(N+10).GFAN_TIE_ROOT_GLUE when INT_L_X62Y(N).GFAN0.GND_WIRE appears (OBUF.T → GND routing). - PUDC_B tile excluded from the bank-glue walk (its IN features are virtual; injecting OBUF_HP_BANK_GLUE on it produces spurious bits). utils/utils.tcl (+47): - write_pip_txtdata bulk-fetch — replaces per-net foreach pip with bulk get_pips + bulk get_property IS_DIRECTIONAL + cached dst_wire_to_num_pips. ~4× speed-up on xc7vx485t (per-spec time on 041-clk-hrow-pips / 045-hclk-cmt-pips drops from ~1.5 h to ~25 min). utils/mergedb.sh (+15): - LIOI / LIOI_TBYTESRC / LIOI_TBYTETERM / LIOB18 / mask_liob18 sed rewrites for the L-side IOI/IOB18 tiles on HP-only parts (xc7vx485t uses left-side IOB18 too; upstream kintex7 mergedb only knew the right side). 11 fuzzers patched for virtex7 readiness: - 030-iob18 Makefile: split DB target for virtex7 (HP-only); the BUFR HP-bank results come from the actual fuzzer rather than HR-side sed. - 037-iob18-pips: L-side mirror tiles (LIOI / LIOI_TBYTESRC / LIOI_TBYTETERM) added to segdata glob; *_SING tiles excluded; EXCLUDE_RE updated for L-side prefixes. - 039-hclk-config: split virtex7 vs kintex7 (HCLK_IOI vs HCLK_IOI3); XRAY_IOSTANDARD env var; IOB18M/IOB33M alternation. - 047a-hclk-idelayctrl-pips: accepts both HCLK_IOI and HCLK_IOI3. - 041, 045, 034, 034b, 043, 044, 046: removed local write_pip_txtdata override that shadowed the patched utils.tcl bulk-fetch (was re-introducing the slow per-net Tcl path). README.md (+86): - 'Virtex-7 Port Status (virtex7-support branch)' section — achievements, goals, work-in-progress, constraints. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 11:13:53 +02:00
liob18)
sed < "$2" > "$tmp1" -e 's/^IOB18\./LIOB18./' ;;
mask_liob18)
sed < "$2" > "$tmp1" -e 's/^IOB18\./LIOB18./' ;;
lioi3)
sed < "$2" > "$tmp1" -e 's/^IOI3\./LIOI3./' ;;
lioi3_tbytesrc)
sed < "$2" > "$tmp1" -e 's/^IOI3\./LIOI3_TBYTESRC./' ;;
lioi3_tbyteterm)
sed < "$2" > "$tmp1" -e 's/^IOI3\./LIOI3_TBYTETERM./' ;;
rioi3)
sed < "$2" > "$tmp1" -e 's/^IOI3\./RIOI3./' ;;
rioi)
sed < "$2" > "$tmp1" -e 's/^IOI\./RIOI./' ;;
rioi3_tbytesrc)
sed < "$2" > "$tmp1" -e 's/^IOI3\./RIOI3_TBYTESRC./' ;;
rioi_tbytesrc)
sed < "$2" > "$tmp1" -e 's/^IOI\./RIOI_TBYTESRC./' ;;
rioi3_tbyteterm)
sed < "$2" > "$tmp1" -e 's/^IOI3\./RIOI3_TBYTETERM./' ;;
rioi_tbyteterm)
sed < "$2" > "$tmp1" -e 's/^IOI\./RIOI_TBYTETERM./' ;;
virtex7: HP-bank glue codified end-to-end + open-flow validation The open-flow (Yosys → nextpnr-xilinx → FASM → bitstream) now produces silicon-functional bits on VC707 xc7vx485tffg1761-2 for: - rst_to_led (IBUF↔OBUF passthrough) - counter_skewfree (button-clocked 8b counter, general routing) - counter_sw_bufr (button → BUFR → 8b counter) - counter_bufr (200 MHz LVDS sysclk → IBUFDS → BUFR → 8b counter) - counter_2bufg (2× BUFGCTRL on the same source) - vc707_telegraph (125 MHz crystal → IBUFDS_GTE2 → BUFG → UART smoke test) - vc707_picosoc (picorv32 + simpleuart + BRAM @ 125 MHz; UART prints 'PicoSoC alive on VC707 @ 125 MHz' on /dev/ttyUSB0) Highlights of this drop: utils/fasm2frames.py (+223 net): - Bank-glue auto-injection for HP-bank IOB18 — IBUF/OBUF (Y0+Y1) + IBUFDS differential pair. Fires off the FASM-level direction heuristic (.IN/.IN_ONLY/IBUFDISABLE for IBUF, .DRIVE. for OBUF, .IN_DIFF for IBUFDS; .SLEW. is unreliable as a marker — gets emitted on default-state IOBs too). - INT_L_X32Y49 DCI cascade / bank-active markers when any LIOB18_X81 Y1 OBUF is present. - PUDC_B emission rewritten for HP-bank IOSTANDARDs (10 features cover Y0 + Y1 default-state; all 9 historic 'PUDC_B glue' bits flow naturally from the existing IOSTANDARD segbits). - HCLK_L per-BUFRCLK-channel 'active' marker — currently codified for BUFRCLK3 (the channel exercised by counter_sw_bufr). - GFAN T-tie root glue — INT_L_X62Y(N+10).GFAN_TIE_ROOT_GLUE when INT_L_X62Y(N).GFAN0.GND_WIRE appears (OBUF.T → GND routing). - PUDC_B tile excluded from the bank-glue walk (its IN features are virtual; injecting OBUF_HP_BANK_GLUE on it produces spurious bits). utils/utils.tcl (+47): - write_pip_txtdata bulk-fetch — replaces per-net foreach pip with bulk get_pips + bulk get_property IS_DIRECTIONAL + cached dst_wire_to_num_pips. ~4× speed-up on xc7vx485t (per-spec time on 041-clk-hrow-pips / 045-hclk-cmt-pips drops from ~1.5 h to ~25 min). utils/mergedb.sh (+15): - LIOI / LIOI_TBYTESRC / LIOI_TBYTETERM / LIOB18 / mask_liob18 sed rewrites for the L-side IOI/IOB18 tiles on HP-only parts (xc7vx485t uses left-side IOB18 too; upstream kintex7 mergedb only knew the right side). 11 fuzzers patched for virtex7 readiness: - 030-iob18 Makefile: split DB target for virtex7 (HP-only); the BUFR HP-bank results come from the actual fuzzer rather than HR-side sed. - 037-iob18-pips: L-side mirror tiles (LIOI / LIOI_TBYTESRC / LIOI_TBYTETERM) added to segdata glob; *_SING tiles excluded; EXCLUDE_RE updated for L-side prefixes. - 039-hclk-config: split virtex7 vs kintex7 (HCLK_IOI vs HCLK_IOI3); XRAY_IOSTANDARD env var; IOB18M/IOB33M alternation. - 047a-hclk-idelayctrl-pips: accepts both HCLK_IOI and HCLK_IOI3. - 041, 045, 034, 034b, 043, 044, 046: removed local write_pip_txtdata override that shadowed the patched utils.tcl bulk-fetch (was re-introducing the slow per-net Tcl path). README.md (+86): - 'Virtex-7 Port Status (virtex7-support branch)' section — achievements, goals, work-in-progress, constraints. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 11:13:53 +02:00
lioi)
sed < "$2" > "$tmp1" -e 's/^IOI\./LIOI./' ;;
lioi_tbytesrc)
sed < "$2" > "$tmp1" -e 's/^IOI\./LIOI_TBYTESRC./' ;;
lioi_tbyteterm)
sed < "$2" > "$tmp1" -e 's/^IOI\./LIOI_TBYTETERM./' ;;
cmt_top_r_upper_t)
sed < "$2" > "$tmp1" -e 's/^CMT_UPPER_T\./CMT_TOP_R_UPPER_T./' ;;
cmt_top_l_upper_t)
sed < "$2" > "$tmp1" -e 's/^CMT_UPPER_T\./CMT_TOP_L_UPPER_T./' ;;
cmt_top_r_lower_b)
sed < "$2" > "$tmp1" -e 's/^CMT_LOWER_B\./CMT_TOP_R_LOWER_B./' ;;
cmt_top_l_lower_b)
sed < "$2" > "$tmp1" -e 's/^CMT_LOWER_B\./CMT_TOP_L_LOWER_B./' ;;
cfg_center_mid)
cp "$2" "$tmp1" ;;
hclk_ioi3)
cp "$2" "$tmp1" ;;
hclk_ioi)
cp "$2" "$tmp1" ;;
pcie_bot)
cp "$2" "$tmp1" ;;
pcie_int_interface_l)
sed < "$2" > "$tmp1" -e 's/^PCIE_INT_INTERFACE\./PCIE_INT_INTERFACE_L./' ;;
pcie_int_interface_r)
sed < "$2" > "$tmp1" -e 's/^PCIE_INT_INTERFACE\./PCIE_INT_INTERFACE_R./' ;;
gtp_common)
cp "$2" "$tmp1" ;;
gtp_common_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTP_COMMON\./GTP_COMMON_MID_LEFT./' ;;
gtp_common_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTP_COMMON\./GTP_COMMON_MID_RIGHT./' ;;
gtp_channel_0)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_0./' ;;
gtp_channel_1)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_1./' ;;
gtp_channel_2)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_2./' ;;
gtp_channel_3)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_3./' ;;
gtp_channel_0_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_0_MID_LEFT./' ;;
gtp_channel_1_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_1_MID_LEFT./' ;;
gtp_channel_2_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_2_MID_LEFT./' ;;
gtp_channel_3_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_3_MID_LEFT./' ;;
gtp_channel_0_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_0_MID_RIGHT./' ;;
gtp_channel_1_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_1_MID_RIGHT./' ;;
gtp_channel_2_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_2_MID_RIGHT./' ;;
gtp_channel_3_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTP_CHANNEL\./GTP_CHANNEL_3_MID_RIGHT./' ;;
gtp_int_interface_l)
sed < "$2" > "$tmp1" -e 's/^GTP_INT_INTERFACE\.GTPE2_INT/GTP_INT_INTERFACE_L\.GTPE2_INT_LEFT/' ;;
gtp_int_interface_r)
sed < "$2" > "$tmp1" -e 's/^GTP_INT_INTERFACE\.GTPE2_INT/GTP_INT_INTERFACE_R\.GTPE2_INT_R/' ;;
gtp_int_interface)
cp "$2" "$tmp1" ;;
gtx_common)
cp "$2" "$tmp1" ;;
gtx_common_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTX_COMMON\./GTX_COMMON_MID_LEFT./' ;;
gtx_common_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTX_COMMON\./GTX_COMMON_MID_RIGHT./' ;;
gtx_channel_0)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_0./' ;;
gtx_channel_1)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_1./' ;;
gtx_channel_2)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_2./' ;;
gtx_channel_3)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_3./' ;;
gtx_channel_0_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_0_MID_LEFT./' ;;
gtx_channel_1_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_1_MID_LEFT./' ;;
gtx_channel_2_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_2_MID_LEFT./' ;;
gtx_channel_3_mid_left)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_3_MID_LEFT./' ;;
gtx_channel_0_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_0_MID_RIGHT./' ;;
gtx_channel_1_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_1_MID_RIGHT./' ;;
gtx_channel_2_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_2_MID_RIGHT./' ;;
gtx_channel_3_mid_right)
sed < "$2" > "$tmp1" -e 's/^GTX_CHANNEL\./GTX_CHANNEL_3_MID_RIGHT./' ;;
gtx_int_interface_l)
sed < "$2" > "$tmp1" -e 's/^GTX_INT_INTERFACE\.GTXE2_INT/GTX_INT_INTERFACE_L\.GTXE2_INT_LEFT/' ;;
gtx_int_interface_r)
sed < "$2" > "$tmp1" -e 's/^GTX_INT_INTERFACE\.GTXE2_INT/GTX_INT_INTERFACE_R\.GTXE2_INT_R/' ;;
gtx_int_interface)
cp "$2" "$tmp1" ;;
mask_*)
db=$XRAY_DATABASE_DIR/$XRAY_DATABASE/$1.db
ismask=true
cp "$2" "$tmp1" ;;
*)
echo "Invalid mode: $1"
rm -f "$tmp1" "$tmp2"
exit 1
esac
touch "$db"
if $ismask ; then
sort -u "$tmp1" "$db" | grep -v '<.*>' > "$tmp2" || true
else
# tmp1 must be placed second to take precedence over old bad entries
if ! $ismask ; then
db_origin=$XRAY_DATABASE_DIR/$XRAY_DATABASE/segbits_$1.origin_info.db
if [ ! -f $db_origin ] ; then
touch "$db_origin"
fi
python3 ${XRAY_DIR}/utils/mergedb.py --out "$db_origin" "$db_origin" "$tmp1" --track_origin
fi
python3 ${XRAY_DIR}/utils/mergedb.py --out "$tmp2" "$db" "$tmp1"
fi
# Check aggregate db for consistency and make canonical
${XRAY_PARSEDB} --strict "$tmp2" "$db"