# Run VPR for the s298 design
vpr ./test_vpr_arch/k6_frac_N10_40nm.xml ./test_blif/s298.blif --write_rr_graph example_rr_graph.xml

# Read OpenFPGA architecture definition
read_openfpga_arch -f ./test_openfpga_arch/k6_frac_N10_40nm_openfpga.xml

# Write out the architecture XML as a proof
#write_openfpga_arch -f ./arch_echo.xml

# Annotate the OpenFPGA architecture to VPR data base
link_openfpga_arch #--verbose

# Check and correct any naming conflicts in the BLIF netlist
check_netlist_naming_conflict --fix --report ./netlist_renaming.xml

# Apply fix-up to clustering nets based on routing results
pb_pin_fixup --verbose

# Apply fix-up to Look-Up Table truth tables based on packing results
lut_truth_table_fixup #--verbose

# Build the module graph 
#  - Enabled compression on routing architecture modules
#  - Enable pin duplication on grid modules 
build_fabric --compress_routing --duplicate_grid_pin #--verbose

# Repack the netlist to physical pbs
# This must be done before bitstream generator and testbench generation
# Strongly recommend it is done after all the fix-up have been applied
repack --verbose

# Build the bitstream 
fpga_bitstream --verbose

# Write the Verilog netlit for FPGA fabric
#  - Enable the use of explicit port mapping in Verilog netlist
write_fabric_verilog --file /var/tmp/xtang/openfpga_test_src --explicit_port_mapping --include_timing --include_signal_init --support_icarus_simulator --print_user_defined_template --verbose

# Finish and exit OpenFPGA
exit