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

#  Gowin FPGA IDCODEs
# from JTAG Programming and Configuration Guide
# http://cdn.gowinsemi.com.cn/TN653E.pdf

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

jtag newtap $_CHIPNAME tap -irlen 8 -ignore-version \
	-expected-id 0x0900281B \
	-expected-id 0x0900381B \
	-expected-id 0x0100681B \
	-expected-id 0x0300081B \
	-expected-id 0x0300181B \
	-expected-id 0x0120681B \
	-expected-id 0x0100381B \
	-expected-id 0x1100381B \
	-expected-id 0x0100981B \
	-expected-id 0x1100581B \
	-expected-id 0x1100481B \
	-expected-id 0x0100181B \
	-expected-id 0x1100181B \
	-expected-id 0x0100481B

pld create $_CHIPNAME.pld gowin -chain-position $_CHIPNAME.tap