#!/usr/bin/perl

my $regs = <<EOF;
ECC1B0
ECC1B1
ECC1B2
ECC2B0
ECC2B1
ECC2B2
ECCCFG
ECCRESET
EPxAUTOINLENH
EPxAUTOINLENL
EPxBCH
EPxBCL
EPxFIFOCFG
EPxFIFOIE
EPxFIFOIRQ
EPxFIFOPFH
EPxFIFOPFL
EPxGPIFFLGSEL
EPxGPIFTRIG
FIFOPINPOLAR
FIFORESET
GPIFADRH
GPIFADRL
GPIFIE
GPIFIRQ
GPIFTCB0
GPIFTCB1 
GPIFTCB2
GPIFTCB3
GPIFTRIG
INPKTEND
OUTPKTEND
PINFLAGSAB
PINFLAGSCD
REVCTL
UDMACRCH
UDMACRCL
EOF


my @regs = map { s/x/\\d/g; $_ } split /\n/, $regs;

my $filename = shift;
die "Input file is not exists: $filename\n" unless -f $filename;

my $out_filename = "$filename.sync";

open FILE, "<$filename" || die "Can't open file $filename: $!\n";
open OUT_FILE, ">$out_filename" || die "Can't create file $out_filename: $!\n";

while(<FILE>) {
    chomp;
    foreach my $reg (@regs) {
	if(/$reg/) {
	    $_ .= "\t// SYNC";
	    last;
	}
    }
    print OUT_FILE "$_\n";
}

close OUT_FILE;
close FILE;
