diff --git a/src/main.cpp b/src/main.cpp index f5b9a2a..9d41234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -176,7 +176,8 @@ int main(int argc, char **argv) Device *fpga; if (fab == "xilinx") { - fpga = new Xilinx(jtag, args.bit_file, args.verbose); + fpga = new Xilinx(jtag, args.bit_file, args.write_flash, args.write_sram, + args.verbose); } else if (fab == "altera") { fpga = new Altera(jtag, args.bit_file, args.verbose); } else if (fab == "anlogic") { diff --git a/src/xilinx.cpp b/src/xilinx.cpp index 819e821..fa5e085 100644 --- a/src/xilinx.cpp +++ b/src/xilinx.cpp @@ -13,14 +13,25 @@ #include "part.hpp" #include "progressBar.hpp" -Xilinx::Xilinx(Jtag *jtag, const std::string &filename, bool verbose): +Xilinx::Xilinx(Jtag *jtag, const std::string &filename, + bool flash_wr, bool sram_wr, bool verbose): Device(jtag, filename, verbose) { if (_filename != ""){ - if (_file_extension == "bit") - _mode = Device::MEM_MODE; - else + if (flash_wr && sram_wr) { + printError("both write-flash and write-sram can't be set"); + throw std::exception(); + } + if (_file_extension == "mcs") { _mode = Device::SPI_MODE; + } else if (_file_extension == "bit") { + if (sram_wr) + _mode = Device::MEM_MODE; + else + _mode = Device::SPI_MODE; + } else { + _mode = Device::SPI_MODE; + } } } Xilinx::~Xilinx() {} @@ -97,6 +108,8 @@ void Xilinx::program_spi(unsigned int offset) ConfigBitstreamParser *_bit; if (_file_extension == "mcs") _bit = new McsParser(_filename, false, _verbose); + else if (_file_extension == "bit") + _bit = new BitParser(_filename, false, _verbose); else { if (offset == 0) { printError("Error: can't write raw data at the beginning of the flash"); diff --git a/src/xilinx.hpp b/src/xilinx.hpp index c00496c..8e91d8b 100644 --- a/src/xilinx.hpp +++ b/src/xilinx.hpp @@ -10,7 +10,8 @@ class Xilinx: public Device, SPIInterface { public: - Xilinx(Jtag *jtag, const std::string &filename, bool verbose); + Xilinx(Jtag *jtag, const std::string &filename, + bool flash_wr, bool sram_wr, bool verbose); ~Xilinx(); void program(unsigned int offset = 0) override;