# SPDX-License-Identifier: GPL-2.0-or-later

# xilinx virtex 4
# https://docs.xilinx.com/v/u/en-US/ug071

if { [info exists CHIPNAME] } {
	set _CHIPNAME $CHIPNAME
} else {
	set _CHIPNAME xc4v
}

# the 4 top bits (28:31) are the die stepping. ignore it.
jtag newtap $_CHIPNAME tap -irlen 10 -ignore-version \
	-expected-id 0x01658093 \
	-expected-id 0x01E58093 \
	-expected-id 0x0167C093 \
	-expected-id 0x02068093 \
	-expected-id 0x01E64093 \
	-expected-id 0x016A4093 \
	-expected-id 0x02088093 \
	-expected-id 0x016B4093 \
	-expected-id 0x020B0093 \
	-expected-id 0x016D8093 \
	-expected-id 0x01700093 \
	-expected-id 0x01718093 \
	-expected-id 0x01734093

pld create $_CHIPNAME.pld virtex2 -chain-position $_CHIPNAME.tap
# cfg_out cfg_in jprogb jstart jshutdown user1-4
virtex2 set_instr_codes $_CHIPNAME.pld 0x3C4 0x3C5 0x3CB 0x3CC 0x3CD
virtex2 set_user_codes $_CHIPNAME.pld 0x3C2 0x3C3 0x3E2 0x3E3
