#!/bin/sh
# $Id: xilinx_vhdl_memcolltype_fix 93 2007-10-28 21:24:44Z mueller $
#
# remove the lines
#
#    variable Write_A_Write_B : memory_collision_type := Write_A_Write_B;
#    variable Read_A_Write_B  : memory_collision_type := Read_A_Write_B;
#    variable Write_A_Read_B  : memory_collision_type := Write_A_Read_B;
#    variable Write_B_Write_A : memory_collision_type := Write_B_Write_A;
#    variable Read_B_Write_A  : memory_collision_type := Read_B_Write_A;
#    variable Write_B_Read_A  : memory_collision_type := Write_B_Read_A;
#
# from vhd sources. These self-referencial init are wrong and cause ghdl to
# choke. The awk script checks quite closely for this patterns.

for file in `egrep -l 'variable.*(Read|Write)_(A|B)_(Read|Write)_(A|B)' *.vhd`
do
  echo "# strip 'variable.. memory_collision_type..' in $file"
  mv $file $file.old
  awk '! /variable.*(Read|Write)_(A|B)_(Read|Write)_(A|B).*memory_collision_type.*(Read|Write)_(A|B)_(Read|Write)_(A|B)/ {print $0}' $file.old > $file
done
