
# generate the offsets
awk '{x=$2}{dx=157}($2 < 4){{x=$2+1}{dx=0}}(NR>2){printf "          XY%d%d  S32     %d\n", $2, $3, x*4971+dx}' chips-layout.txt | sort -k 1 > tmp
awk '{y=$3}{dy=306}($2 < 4){{y=$3+1}{dy=0}}(NR>2){printf "          XY%d%d  S32     %d\n", $2, $3, y*5143+dy}' chips-layout.txt | sort -k 1 > tmp

# generate the parities
awk '{x=1}($2 < 4){x=-1}(NR>2){printf "          XY%d%d  S32     %d\n", $2, $3, x}' chips-layout.txt | sort -k 1 > tmp
awk '{y=1}($2 < 4){y=-1}(NR>2){printf "          XY%d%d  S32     %d\n", $2, $3, y}' chips-layout.txt | sort -k 1 > tmp

# generate the CONTENT table
awk '(NR > 2){printf "        %s  STR  XY%d%d:GPCChip\n", $1, $2, $3}' chips-layout.txt | sort -k 3 > tmp
