Altera:
- merge epcq and svf into the class - merge reset() - check in constructor file type to determine if bitstream is to send in sram or spi flash
This commit is contained in:
parent
c5e26c0c69
commit
ecdde91dff
63
altera.cpp
63
altera.cpp
|
|
@ -1,13 +1,64 @@
|
||||||
#include "altera.hpp"
|
#include "altera.hpp"
|
||||||
#include "ftdijtag.hpp"
|
#include "ftdijtag.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
|
#include "epcq.hpp"
|
||||||
|
|
||||||
Altera::Altera(FtdiJtag *jtag, enum prog_mode mode, std::string filename):Device(jtag, mode, filename),
|
#define IDCODE 6
|
||||||
_bitfile(filename)
|
#define IRLENGTH 10
|
||||||
{}
|
#define BIT_FOR_FLASH "/usr/local/share/cyc1000_prog/test_sfl.svf"
|
||||||
|
|
||||||
|
Altera::Altera(FtdiJtag *jtag, std::string filename):Device(jtag, filename),
|
||||||
|
_svf(_jtag)
|
||||||
|
{
|
||||||
|
if (_filename != "") {
|
||||||
|
if (_file_extension == "svf")
|
||||||
|
_mode = Device::MEM_MODE;
|
||||||
|
else
|
||||||
|
_mode = Device::SPI_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
Altera::~Altera()
|
Altera::~Altera()
|
||||||
{}
|
{}
|
||||||
void Altera::program()
|
void Altera::reset()
|
||||||
{}
|
{
|
||||||
|
/* PULSE_NCONFIG */
|
||||||
|
unsigned char tx_buff[2] = {0x01, 0x00};
|
||||||
|
_jtag->set_state(FtdiJtag::TEST_LOGIC_RESET);
|
||||||
|
_jtag->shiftIR(tx_buff, NULL, IRLENGTH);
|
||||||
|
_jtag->toggleClk(1);
|
||||||
|
_jtag->set_state(FtdiJtag::TEST_LOGIC_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Altera::program(unsigned int offset)
|
||||||
|
{
|
||||||
|
if (_mode == Device::NONE_MODE)
|
||||||
|
return;
|
||||||
|
/* in all case we consider svf is mandatory
|
||||||
|
* MEM_MODE : svf file provided for constructor
|
||||||
|
* is the bitstream to use
|
||||||
|
* SPI_MODE : svf file provided is bridge to have
|
||||||
|
* access to the SPI flash
|
||||||
|
*/
|
||||||
|
/* mem mode -> svf */
|
||||||
|
if (_mode == Device::MEM_MODE) {
|
||||||
|
_svf.parse(_filename);
|
||||||
|
} else if (_mode == Device::SPI_MODE) {
|
||||||
|
/* GGM: TODO: fix this issue */
|
||||||
|
EPCQ epcq(_jtag->vid(), _jtag->pid(), 2, 6000000);
|
||||||
|
_svf.parse(BIT_FOR_FLASH);
|
||||||
|
epcq.program(offset, _filename, (_file_extension == "rpd")? true:false);
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
int Altera::idCode()
|
int Altera::idCode()
|
||||||
{}
|
{
|
||||||
|
unsigned char tx_data = IDCODE;
|
||||||
|
unsigned char rx_data[4];
|
||||||
|
_jtag->go_test_logic_reset();
|
||||||
|
_jtag->shiftIR(&tx_data, NULL, IRLENGTH);
|
||||||
|
_jtag->shiftDR(NULL, rx_data, 32);
|
||||||
|
return ((rx_data[0] & 0x000000ff) |
|
||||||
|
((rx_data[1] << 8) & 0x0000ff00) |
|
||||||
|
((rx_data[2] << 16) & 0x00ff0000) |
|
||||||
|
((rx_data[3] << 24) & 0xff000000));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,18 @@
|
||||||
#include "bitparser.hpp"
|
#include "bitparser.hpp"
|
||||||
#include "device.hpp"
|
#include "device.hpp"
|
||||||
#include "ftdijtag.hpp"
|
#include "ftdijtag.hpp"
|
||||||
|
#include "svf_jtag.hpp"
|
||||||
|
|
||||||
class Altera: public Device {
|
class Altera: public Device {
|
||||||
public:
|
public:
|
||||||
Altera(FtdiJtag *jtag, enum prog_mode mode, std::string filename);
|
Altera(FtdiJtag *jtag, std::string filename);
|
||||||
~Altera();
|
~Altera();
|
||||||
|
|
||||||
void program();
|
void program(unsigned int offset = 0);
|
||||||
int idCode();
|
int idCode();
|
||||||
|
void reset() override;
|
||||||
private:
|
private:
|
||||||
BitParser _bitfile;
|
SVF_jtag _svf;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue