2020-02-23 00:04:42 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes functions to build bitstream database
|
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from vtrutil library */
|
|
|
|
#include "vtr_time.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
2020-04-08 17:18:05 -05:00
|
|
|
/* Headers from openfpgashell library */
|
|
|
|
#include "command_exit_codes.h"
|
|
|
|
|
2020-02-28 12:14:50 -06:00
|
|
|
/* Headers from openfpgautil library */
|
|
|
|
#include "openfpga_digest.h"
|
|
|
|
|
2020-02-23 00:04:42 -06:00
|
|
|
#include "build_device_bitstream.h"
|
2020-04-21 13:02:10 -05:00
|
|
|
#include "arch_bitstream_writer.h"
|
|
|
|
#include "fabric_bitstream_writer.h"
|
2020-02-26 12:09:23 -06:00
|
|
|
#include "build_fabric_bitstream.h"
|
2020-02-23 00:04:42 -06:00
|
|
|
#include "openfpga_bitstream.h"
|
|
|
|
|
|
|
|
/* Include global variables of VPR */
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
2020-02-26 12:09:23 -06:00
|
|
|
* A wrapper function to call the build_device_bitstream() in FPGA bitstream
|
2020-02-23 00:04:42 -06:00
|
|
|
*******************************************************************/
|
2020-04-08 17:18:05 -05:00
|
|
|
int fpga_bitstream(OpenfpgaContext& openfpga_ctx,
|
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
2020-02-23 00:04:42 -06:00
|
|
|
|
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
2020-02-26 12:09:23 -06:00
|
|
|
CommandOptionId opt_file = cmd.option("file");
|
2020-02-23 00:04:42 -06:00
|
|
|
|
2020-02-26 12:09:23 -06:00
|
|
|
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)) {
|
2020-02-28 12:14:50 -06:00
|
|
|
std::string src_dir_path = find_path_dir_name(cmd_context.option_value(cmd, opt_file));
|
|
|
|
|
|
|
|
/* Create directories */
|
2020-04-08 13:55:09 -05:00
|
|
|
create_directory(src_dir_path);
|
2020-02-28 12:14:50 -06:00
|
|
|
|
2020-02-26 12:09:23 -06:00
|
|
|
write_arch_independent_bitstream_to_xml_file(openfpga_ctx.bitstream_manager(),
|
|
|
|
cmd_context.option_value(cmd, opt_file));
|
|
|
|
}
|
2020-04-08 17:18:05 -05:00
|
|
|
|
|
|
|
/* TODO: should identify the error code from internal function execution */
|
|
|
|
return CMD_EXEC_SUCCESS;
|
2020-02-26 12:09:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* A wrapper function to call the build_fabric_bitstream() in FPGA bitstream
|
|
|
|
*******************************************************************/
|
2020-04-08 17:18:05 -05:00
|
|
|
int build_fabric_bitstream(OpenfpgaContext& openfpga_ctx,
|
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
2020-02-26 12:09:23 -06:00
|
|
|
|
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
2020-04-21 13:02:10 -05:00
|
|
|
CommandOptionId opt_file = cmd.option("file");
|
2020-02-26 12:09:23 -06:00
|
|
|
|
2020-04-21 13:02:10 -05:00
|
|
|
/* Build fabric bitstream here */
|
2020-02-26 12:09:23 -06:00
|
|
|
openfpga_ctx.mutable_fabric_bitstream() = build_fabric_dependent_bitstream(openfpga_ctx.bitstream_manager(),
|
|
|
|
openfpga_ctx.module_graph(),
|
|
|
|
cmd_context.option_enable(cmd, opt_verbose));
|
2020-04-21 13:02:10 -05:00
|
|
|
|
|
|
|
/* Write fabric bitstream if required */
|
|
|
|
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));
|
|
|
|
|
|
|
|
/* Create directories */
|
|
|
|
create_directory(src_dir_path);
|
|
|
|
|
|
|
|
write_fabric_bitstream_to_text_file(openfpga_ctx.bitstream_manager(),
|
|
|
|
openfpga_ctx.fabric_bitstream(),
|
|
|
|
cmd_context.option_value(cmd, opt_file));
|
|
|
|
}
|
2020-04-08 17:18:05 -05:00
|
|
|
|
|
|
|
/* TODO: should identify the error code from internal function execution */
|
|
|
|
return CMD_EXEC_SUCCESS;
|
2020-02-23 00:04:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* end namespace openfpga */
|