openfpga/src/fpga_bitstream/write_text_fabric_bitstream.cpp
/********************************************************************
 * Write the fabric bitstream to a plain text file 
 * Notes: 
 *   - This is the final bitstream which is loadable to the FPGA fabric
 *     (Verilog netlists etc.)
 *   - Do NOT include any comments or other characters that the 0|1 bitstream content
 *     in this file
 *
 * Return:
 *  - 0 if succeed
 *  - 1 if critical errors occured
 *******************************************************************/
Write the fabric bitstream to a plain text file
Notes:
- This is the final bitstream which is loadable to the FPGA fabric
(Verilog netlists etc.)
- Do NOT include any comments or other characters that the 0|1 bitstream content
in this file

- 0 if succeed
- 1 if critical errors occured
Write the fabric bitstream to a plain text file Notes : - This is the final bitstream which is loadable to the FPGA fabric ( Verilog netlists etc . ) - Do NOT include any comments or other characters that the 0|1 bitstream content in this file - 0 if succeed - 1 if critical errors occured
int write_fabric_bitstream_to_text_file(const BitstreamManager& bitstream_manager,
                                        const FabricBitstream& fabric_bitstream,
                                        const ConfigProtocol& config_protocol,
                                        const std::string& fname,
                                        const bool& verbose) {
  if (true == fname.empty()) {
    VTR_LOG_ERROR("Received empty file name to output bitstream!\n\tPlease specify a valid file name.\n");
  }
  std::string timer_message = std::string("Write ") + std::to_string(fabric_bitstream.num_bits()) + std::string(" fabric bitstream into plain text file '") + fname + std::string("'");
  vtr::ScopedStartFinishTimer timer(timer_message);
  std::fstream fp;
  fp.open(fname, std::fstream::out | std::fstream::trunc);
  check_file_stream(fname.c_str(), fp);
  int status = 0;
  for (const FabricBitId& fabric_bit : fabric_bitstream.bits()) {
    status = write_fabric_config_bit_to_text_file(fp, bitstream_manager,
                                                  fabric_bitstream,
                                                  fabric_bit,
                                                  config_protocol.type());
    if (1 == status) {
      break;
    }
  }
  fp << std::endl;
  fp.close();
  VTR_LOGV(verbose,
           "Outputted %lu configuration bits to plain text file: %s\n",
           fabric_bitstream.bits().size(),
           fname.c_str());
  return status;
}
int write_fabric_bitstream_to_text_file ( const BitstreamManager & bitstream_manager , const FabricBitstream & fabric_bitstream , const ConfigProtocol & config_protocol , const std :: string & fname , const bool & verbose ) { if ( true == fname . empty ( ) ) { VTR_LOG_ERROR ( " \n \t \n " ) ; } std :: string timer_message = std :: string ( " " ) + std :: to_string ( fabric_bitstream . num_bits ( ) ) + std :: string ( " " ) + fname + std :: string ( " " ) ; vtr :: ScopedStartFinishTimer timer ( timer_message ) ; std :: fstream fp ; fp . open ( fname , std :: fstream :: out | std :: fstream :: trunc ) ; check_file_stream ( fname . c_str ( ) , fp ) ; int status = 0 ; for ( const FabricBitId & fabric_bit : fabric_bitstream . bits ( ) ) { status = write_fabric_config_bit_to_text_file ( fp , bitstream_manager , fabric_bitstream , fabric_bit , config_protocol . type ( ) ) ; if ( 1 == status ) { break ; } } fp << std :: endl ; fp . close ( ) ; VTR_LOGV ( verbose , " \n " , fabric_bitstream . bits ( ) . size ( ) , fname . c_str ( ) ) ; return status ; }
Write the fabric bitstream to a plain text file
 Notes:
   - This is the final bitstream which is loadable to the FPGA fabric
     (Verilog netlists etc.)
Write the fabric bitstream to a plain text file Notes : - This is the final bitstream which is loadable to the FPGA fabric ( Verilog netlists etc . )
/* Ensure that we have a valid file name */ /* Create the file stream */ /* Output fabric bitstream to the file */ /* Print an end to the file here */ /* Close file handler */