#########################################################
#                 gen_tcelllib.tcl
#
# Description:  Erzeugt tcelllib aus NanGate fslib
#               für Tessent Shell MBIST Insertion
#
# Usage:        Im Tessent Shell Prompt:
#               SETUP> set script_dir "scripts_risc_v"
#               SETUP> set ekit_dir "."
#               SETUP> source scripts_risc_v/gen_tcelllib.tcl
#
# Dependencies: Tessent Shell (kein Oasys benötigt)
#########################################################
set script_dir "scripts_risc_v"
if {![info exists ekit_dir]} {
    set ekit_dir [file dirname ${script_dir}]
}

set fastscan_lib "${ekit_dir}/libs/fastscan/NangateOpenCellLibrary_45nm_LVT_slow_0p85V_conditional_nldm.fslib"
set output_dir   "${ekit_dir}/output"

# Prüfen ob fslib existiert
if {![file exists $fastscan_lib]} {
    puts "ERROR: fslib nicht gefunden: $fastscan_lib"
    exit 1
}

puts "\nINFO: Lade fslib: $fastscan_lib"
read_cell_library $fastscan_lib

puts "\nINFO: Schreibe tcelllib..."
file mkdir ${output_dir}
write_cell_library ${output_dir}/nangate_complete.tcelllib -replace

puts "\nINFO: Fertig -> ${output_dir}/nangate_complete.tcelllib"
exit
