#open_run impl_2
set project_bmm_files [get_files *.bmm]
set BB FALSE


#	foreach fn $project_bmm_files {
#   set temp [file rootname $fn]
#		set bd_fn ${temp}_bd.bmm
		set fn $bmm_file
    set bd_fn $bmm_bd
		puts "INFO: Creating file $bd_fn"		
		set fileID [open $fn r]

		if [catch {open $bd_fn w} fileID_bd] {
			puts "ERROR: Could not open file $bd_fn"
			close $fileID
			exit
		}
		
		while {[gets $fileID line] >= 0 } {	
			#puts "DEBUG: BB is $BB"
			#puts "DEBUG: Line is $line"
			if {[regexp {^[ \t]+BUS_BLOCK} $line]} {
				set BB TRUE
				puts $fileID_bd $line 
				continue
			} elseif {[regexp {^[ \t]+END_BUS_BLOCK;} $line]} {
				set BB FALSE
			}
			
			if { $BB eq "TRUE" } {
				if {[regexp {(^[ \t]+([^\s]*).*);} $line match new_line inst] == 1} {
					set BRAM_site [get_property SITE [get_cells $inst]]
					set expression [regexp {_(.*)} $BRAM_site match bmm_string]
					#puts "INFO: Located BRAM at site $BRAM_site"
					set new_line "$new_line PLACED = ${bmm_string};"
					#puts $new_line
					puts $fileID_bd $new_line
				} else {
				#puts "ERROR: Script not expecting this input. Please contact Xilinx"
				}
			} else {
				puts $fileID_bd $line 
			}
		}
		
		
		close $fileID_bd
		close $fileID
#	}



