diff --git a/openfpga/src/base/openfpga_bitstream.cpp b/openfpga/src/base/openfpga_bitstream.cpp index ea5b0abff..870b5935a 100644 --- a/openfpga/src/base/openfpga_bitstream.cpp +++ b/openfpga/src/base/openfpga_bitstream.cpp @@ -12,8 +12,11 @@ #include "openfpga_digest.h" #include "openfpga_reserved_words.h" -#include "build_device_bitstream.h" +/* Headers from fpgabitstream library */ +#include "read_xml_arch_bitstream.h" #include "arch_bitstream_writer.h" + +#include "build_device_bitstream.h" #include "fabric_bitstream_writer.h" #include "build_fabric_bitstream.h" #include "openfpga_bitstream.h" @@ -31,21 +34,26 @@ int fpga_bitstream(OpenfpgaContext& openfpga_ctx, const Command& cmd, const CommandContext& cmd_context) { CommandOptionId opt_verbose = cmd.option("verbose"); - CommandOptionId opt_file = cmd.option("file"); + CommandOptionId opt_write_file = cmd.option("write_file"); + CommandOptionId opt_read_file = cmd.option("read_file"); - openfpga_ctx.mutable_bitstream_manager() = build_device_bitstream(g_vpr_ctx, - openfpga_ctx, - cmd_context.option_enable(cmd, opt_verbose)); + if (true == cmd_context.option_enable(cmd, opt_read_file)) { + openfpga_ctx.mutable_bitstream_manager() = read_xml_architecture_bitstream(cmd_context.option_value(cmd, opt_write_file).c_str()); + } else { + openfpga_ctx.mutable_bitstream_manager() = build_device_bitstream(g_vpr_ctx, + openfpga_ctx, + cmd_context.option_enable(cmd, opt_verbose)); + } - if (true == cmd_context.option_enable(cmd, opt_file)) { - std::string src_dir_path = find_path_dir_name(cmd_context.option_value(cmd, opt_file)); + if (true == cmd_context.option_enable(cmd, opt_write_file)) { + std::string src_dir_path = find_path_dir_name(cmd_context.option_value(cmd, opt_write_file)); /* Create directories */ create_directory(src_dir_path); write_arch_independent_bitstream_to_xml_file(openfpga_ctx.bitstream_manager(), std::string(FPGA_TOP_MODULE_NAME), - cmd_context.option_value(cmd, opt_file)); + cmd_context.option_value(cmd, opt_write_file)); } /* TODO: should identify the error code from internal function execution */ diff --git a/openfpga/src/base/openfpga_bitstream_command.cpp b/openfpga/src/base/openfpga_bitstream_command.cpp index 70149dd43..1a337e9d0 100644 --- a/openfpga/src/base/openfpga_bitstream_command.cpp +++ b/openfpga/src/base/openfpga_bitstream_command.cpp @@ -46,10 +46,14 @@ ShellCommandId add_openfpga_arch_bitstream_command(openfpga::Shell& dependent_cmds) { Command shell_cmd("build_architecture_bitstream"); - /* Add an option '--file' in short '-f'*/ - CommandOptionId opt_file = shell_cmd.add_option("file", true, "file path to output the bitstream database"); - shell_cmd.set_option_short_name(opt_file, "f"); - shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING); + /* Add an option '--write_file' */ + CommandOptionId opt_write_file = shell_cmd.add_option("write_file", false, "file path to output the bitstream database"); + shell_cmd.set_option_require_value(opt_write_file, openfpga::OPT_STRING); + + /* Add an option '--read_file' */ + CommandOptionId opt_read_file = shell_cmd.add_option("read_file", false, "file path to read the bitstream database"); + shell_cmd.set_option_require_value(opt_read_file, openfpga::OPT_STRING); + /* Add an option '--verbose' */ shell_cmd.add_option("verbose", false, "Enable verbose output"); diff --git a/openfpga_flow/OpenFPGAShellScripts/configuration_chain_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/configuration_chain_example_script.openfpga index 0cf8a6448..33891b72d 100644 --- a/openfpga_flow/OpenFPGAShellScripts/configuration_chain_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/configuration_chain_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/duplicated_grid_pin_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/duplicated_grid_pin_example_script.openfpga index ae729290e..97f540116 100644 --- a/openfpga_flow/OpenFPGAShellScripts/duplicated_grid_pin_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/duplicated_grid_pin_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/example_script.openfpga index ae729290e..97f540116 100644 --- a/openfpga_flow/OpenFPGAShellScripts/example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/fast_configuration_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/fast_configuration_example_script.openfpga index fceabcaaa..d6800e2f1 100644 --- a/openfpga_flow/OpenFPGAShellScripts/fast_configuration_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/fast_configuration_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/flatten_routing_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/flatten_routing_example_script.openfpga index 5ab1c56b6..e5cb63413 100644 --- a/openfpga_flow/OpenFPGAShellScripts/flatten_routing_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/flatten_routing_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/full_testbench_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/full_testbench_example_script.openfpga index ae729290e..97f540116 100644 --- a/openfpga_flow/OpenFPGAShellScripts/full_testbench_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/full_testbench_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_example_script.openfpga index 4f340704b..d98e9b74d 100644 --- a/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_example_script.openfpga @@ -40,7 +40,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_from_key_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_from_key_example_script.openfpga index a61336d61..47b3edce3 100644 --- a/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_from_key_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/generate_secure_fabric_from_key_example_script.openfpga @@ -40,7 +40,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/generate_testbench_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/generate_testbench_example_script.openfpga index 971f8d374..a0e09687f 100644 --- a/openfpga_flow/OpenFPGAShellScripts/generate_testbench_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/generate_testbench_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/implicit_verilog_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/implicit_verilog_example_script.openfpga index e86ba055e..ed7ccf1de 100644 --- a/openfpga_flow/OpenFPGAShellScripts/implicit_verilog_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/implicit_verilog_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/mcnc_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/mcnc_example_script.openfpga index 5f17a5c65..6c753df2f 100644 --- a/openfpga_flow/OpenFPGAShellScripts/mcnc_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/mcnc_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose diff --git a/openfpga_flow/OpenFPGAShellScripts/sdc_time_unit_example_script.openfpga b/openfpga_flow/OpenFPGAShellScripts/sdc_time_unit_example_script.openfpga index 36c3c88b9..fc8d333f5 100644 --- a/openfpga_flow/OpenFPGAShellScripts/sdc_time_unit_example_script.openfpga +++ b/openfpga_flow/OpenFPGAShellScripts/sdc_time_unit_example_script.openfpga @@ -37,7 +37,7 @@ repack #--verbose # Build the bitstream # - Output the fabric-independent bitstream to a file -build_architecture_bitstream --verbose --file fabric_indepenent_bitstream.xml +build_architecture_bitstream --verbose --write_file fabric_indepenent_bitstream.xml # Build fabric-dependent bitstream build_fabric_bitstream --verbose