blob: 277dcdf22fec9d23e717b1e8ef0c6114b05f34f5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#include "board.h"
#include "prog.h"
#include <thread>
#include <boost/lockfree/spsc_queue.hpp>
#ifdef PYSMC
#include "ext/pybind11/include/pybind11/pybind11.h"
namespace py = pybind11;
#endif
//ERROR CODES
#define SOFTMC_SUCCESS 0
#define SOFTMC_ERR -1
#define SOFTMC_NO_PLATFORM -2
#define SOFTMC_ERR_OPEN_FPGA -3
#define SOFTMC_NO_SUCH_FPGA -4
class SoftMCPlatform{
#define INSTR_BUF_SIZE 32*2048
#define API_BUF_SIZE 1024*1024*2
public:
SoftMCPlatform();
SoftMCPlatform(bool);
~SoftMCPlatform();
/**
* Initializes the whole platform
* @return SOFTMC_SUCCESS on sucessful initialization
*/
int init();
/**
* Resets SoftMC logic, won't reset PCI-E endpoint or the PHY interface
*/
void reset_fpga();
/**
* Sends SoftMC program to the FPGA board over PCI-E
* @param prog reference to the program object to send
*/
void execute(Program & prog);
/**
* Receive data from the FPGA board over PCI-E
* @param dst_buf pointer to the buffer that will receive the data
* @param num_words number of bytes to read
*/
int receiveData(void* dst_buf, int num_words);
#ifdef PYSMC
int py_receiveData(int num_words);
#endif
/**
* Compare data with a given data pattern (repeating bytes)
* and return number of bitflips in 8KB of data
* @param comp_pattern one byte data pattern to compare the read data
*/
int count_bitflips_in_row(unsigned char comp_pattern);
/**
* Turn auto-refresh on-off
* @param on true to turn aref on false otherwise
*/
void set_aref(bool on);
/**
* Used along with Program::dumpRegisters to read register content
*/
void readRegisterDump();
private:
bool is_dummy;
BoardInterface *iface;
void* instr_buf;
std::thread receiver;
boost::lockfree::spsc_queue<int, boost::lockfree::capacity<API_BUF_SIZE/4>> api_recv_buf;
void* xdma_recv_buf;
void consumeData();
#ifdef PYSMC
public:
uint8_t* py_data_buffer = nullptr;
py::memoryview get_buffer_memoryview();
#endif
};
|