mirror of
https://github.com/EEVengers/ThunderScope.git
synced 2025-04-14 23:59:19 +00:00
Merge pull request #191 from EEVengers/FPGA_DSP_PIPE_HOOKUP
Fpga dsp pipe hookup
This commit is contained in:
commit
4923b0a3f2
Software/waveview
@ -42,6 +42,8 @@ if(MSVC)
|
||||
add_definitions(-DNOGDI)
|
||||
endif()
|
||||
|
||||
add_definitions(-DNOHARDWARE)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBRARIES} ${Boost_LIBRARIES})
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <WinIoCtl.h>
|
||||
|
||||
#include "xdma_public.h"
|
||||
#include "common.hpp"
|
||||
|
||||
#pragma comment(lib, "setupapi.lib")
|
||||
|
||||
@ -61,16 +62,22 @@ class PCIeLink {
|
||||
|
||||
public:
|
||||
bool connected;
|
||||
PCIeLink();
|
||||
PCIeLink(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQueue);
|
||||
|
||||
int Connect();
|
||||
void InitBoard();
|
||||
|
||||
void Read(uint8_t* buff);
|
||||
void Write(ScopeCommand command, void* val);
|
||||
|
||||
void Pause();
|
||||
void UnPause();
|
||||
void Stop();
|
||||
|
||||
void ClockTick1();
|
||||
void ClockTick2();
|
||||
void PrintTimeDelta();
|
||||
double GetTimeDelta();
|
||||
|
||||
~PCIeLink();
|
||||
|
||||
@ -86,6 +93,13 @@ private:
|
||||
LARGE_INTEGER freq; //used for perforamnce testing
|
||||
int64_t last_chunk_read;
|
||||
|
||||
std::atomic<bool> _run;
|
||||
std::atomic<bool> _pause;
|
||||
std::thread PCIeReadThread;
|
||||
|
||||
//output queue in which read data from the FPGA is shoved into
|
||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQueue;
|
||||
|
||||
//used for speed testing
|
||||
LARGE_INTEGER tick1;
|
||||
LARGE_INTEGER tick2;
|
||||
@ -93,6 +107,7 @@ private:
|
||||
void _Read(HANDLE hPCIE, long long address, uint8_t* buff, int bytesToRead);
|
||||
void _Write(HANDLE hPCIE, long long address, uint8_t* buff, int bytesToWrite);
|
||||
void _FIFO_WRITE(HANDLE hPCIE, uint8_t* data, uint8_t bytesToWrite);
|
||||
void _Job();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -21,8 +21,13 @@
|
||||
#define BUFFER_256K 262144
|
||||
#define BUFFER_512K 524288
|
||||
#define BUFFER_1024K 1048576
|
||||
#define BUFFER_8M (1 << 23)
|
||||
|
||||
#ifdef NOHARDWARE
|
||||
#define BUFFER_SIZE BUFFER_8K
|
||||
#else
|
||||
#define BUFFER_SIZE BUFFER_8M
|
||||
#endif
|
||||
|
||||
// Window size in buffers
|
||||
#define DEFAULT_WINDOW 10
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "dspPipeline.hpp"
|
||||
#include "bridge.hpp"
|
||||
#include "common.hpp"
|
||||
#include "PCIe.hpp"
|
||||
|
||||
class controller
|
||||
{
|
||||
@ -55,6 +56,8 @@ private:
|
||||
Trigger* triggerThread = NULL;
|
||||
Processor* processorThread = NULL;
|
||||
postProcessor* postProcessorThread = NULL;
|
||||
PCIeLink* pcieLinkThread = NULL;
|
||||
|
||||
|
||||
// Control Command Processor
|
||||
std::thread controllerThread;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "controller.hpp"
|
||||
|
||||
uint32_t testSize = 1000;
|
||||
|
||||
@ -206,6 +207,7 @@ void runSocketTest ()
|
||||
delete bridgeThread_1;
|
||||
}
|
||||
|
||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> testerDataQueue{1000};
|
||||
|
||||
/*******************************************************************************
|
||||
* runPCIeTEST()
|
||||
@ -218,28 +220,19 @@ void runSocketTest ()
|
||||
* None
|
||||
******************************************************************************/
|
||||
void runPCIeTest() {
|
||||
PCIeLink* pcieLink = new PCIeLink();
|
||||
|
||||
pcieLink->Connect();
|
||||
pcieLink->Write(board_enable,nullptr);
|
||||
pcieLink->Write(clk_enable,nullptr);
|
||||
pcieLink->Write(adc_enable,nullptr);
|
||||
pcieLink->Write(dataMover_enable,nullptr);
|
||||
|
||||
uint8_t* buff = (uint8_t*)malloc(sizeof(uint8_t) * (1 << 23));
|
||||
pcieLink->ClockTick1();
|
||||
pcieLink->Read(buff);
|
||||
pcieLink->ClockTick2();
|
||||
controller* troller = new controller(&testerDataQueue);
|
||||
troller->controllerUnPause();
|
||||
|
||||
pcieLink->PrintTimeDelta();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
FILE* fp = fopen("TestData.txt","w");
|
||||
/*FILE* fp = fopen("TestData.txt","w");
|
||||
for(int i = 0; i < (1 << 23); i+= 8) {
|
||||
fprintf(fp,"%X,%X,%X,%X,%X,%X,%X,%X\n",
|
||||
buff[i],buff[i + 1],buff[i + 2],buff[i + 3],buff[i + 4],buff[i + 5],buff[i + 6],buff[i + 7]);
|
||||
}
|
||||
fclose(fp); */
|
||||
|
||||
fclose(fp);
|
||||
free(buff);
|
||||
delete pcieLink;
|
||||
|
||||
delete troller;
|
||||
}
|
@ -130,12 +130,19 @@ void PCIeLink::Read(uint8_t* buff) {
|
||||
bool enoughData = false;
|
||||
int64_t current_chunk;
|
||||
uint32_t kbytes_4_moved = 0;
|
||||
uint32_t error_code = 0;
|
||||
uint32_t overflow_count = 0;
|
||||
|
||||
while(!enoughData) {
|
||||
_Read(user_handle,DATAMOVER_TRANSFER_COUNTER,(uint8_t*)(&kbytes_4_moved),4);
|
||||
error_code = ((kbytes_4_moved & 0xC0000000)>>30);
|
||||
overflow_count = ((kbytes_4_moved & 0x3FFF0000)>>16);
|
||||
kbytes_4_moved = kbytes_4_moved & 0x0000FFFF;
|
||||
current_chunk = kbytes_4_moved / (1 << 11);
|
||||
INFO << "4k_Bytes Transfered: " << kbytes_4_moved;
|
||||
INFO << "Current Chunk: " << current_chunk;
|
||||
//INFO << "error code: " << error_code;
|
||||
//INFO << "overflow count: " << overflow_count;
|
||||
//INFO << "4kB Transfered: " << kbytes_4_moved;
|
||||
//INFO << "Current Chunk: " << current_chunk;
|
||||
if(last_chunk_read == -1) {
|
||||
enoughData = (kbytes_4_moved >= (1 << 11));
|
||||
if(enoughData && current_chunk == 0) {
|
||||
@ -160,12 +167,31 @@ void PCIeLink::Read(uint8_t* buff) {
|
||||
}
|
||||
last_chunk_read = current_chunk;
|
||||
int64_t reading_offset = current_chunk * (1 << 23);
|
||||
INFO << "Reading from current current chunk: " << current_chunk;
|
||||
INFO << "Offset: " << reading_offset;
|
||||
//INFO << "Reading from current current chunk: " << current_chunk;
|
||||
//INFO << "Offset: " << reading_offset;
|
||||
//Read the data from ddr3 memory
|
||||
_Read(c2h_0_handle,reading_offset,buff,1 << 23);
|
||||
}
|
||||
|
||||
void PCIeLink::InitBoard() {
|
||||
Write(board_enable,nullptr);
|
||||
Write(clk_enable,nullptr);
|
||||
Write(adc_enable,nullptr);
|
||||
Write(dataMover_enable,nullptr);
|
||||
}
|
||||
|
||||
void PCIeLink::Pause() {
|
||||
_pause.store(true);
|
||||
}
|
||||
|
||||
void PCIeLink::UnPause() {
|
||||
_pause.store(false);
|
||||
}
|
||||
|
||||
void PCIeLink::Stop() {
|
||||
_run.store(false);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Write()
|
||||
* Takes in a valid command that the changes a function/value on the scope
|
||||
@ -373,12 +399,34 @@ void PCIeLink::_Write(HANDLE hPCIE, int64_t address, uint8_t* buff, int bytesToW
|
||||
}
|
||||
}
|
||||
|
||||
PCIeLink::PCIeLink() {
|
||||
void PCIeLink::_Job() {
|
||||
while(_run.load()) {
|
||||
while(_pause.load()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
||||
}
|
||||
//allocate a buffer
|
||||
buffer* buff;
|
||||
buff = bufferAllocator.allocate(1);
|
||||
bufferAllocator.construct(buff);
|
||||
//read from the PCIeLink
|
||||
Read((uint8_t*)buff->data);
|
||||
//push to queue
|
||||
outputQueue->push(buff);
|
||||
}
|
||||
}
|
||||
|
||||
PCIeLink::PCIeLink(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQueue) {
|
||||
user_handle = INVALID_HANDLE_VALUE;
|
||||
c2h_0_handle = INVALID_HANDLE_VALUE;
|
||||
dataMoverReg[0] = 0x00;
|
||||
last_chunk_read = -1;
|
||||
_run = true;
|
||||
_pause = true;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
this->outputQueue = outputQueue;
|
||||
Connect();
|
||||
InitBoard();
|
||||
PCIeReadThread = std::thread(&PCIeLink::_Job, this);
|
||||
}
|
||||
|
||||
PCIeLink::~PCIeLink() {
|
||||
@ -386,8 +434,12 @@ PCIeLink::~PCIeLink() {
|
||||
CloseHandle(user_handle);
|
||||
if(c2h_0_handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(c2h_0_handle);
|
||||
}
|
||||
|
||||
_pause.store(false);
|
||||
_run.store(true);
|
||||
|
||||
PCIeReadThread.join();
|
||||
}
|
||||
|
||||
void PCIeLink::ClockTick1() {
|
||||
QueryPerformanceCounter(&tick1);
|
||||
@ -409,6 +461,10 @@ void PCIeLink::PrintTimeDelta() {
|
||||
INFO << "Time Delta is: " << time_sec;
|
||||
}
|
||||
|
||||
double PCIeLink::GetTimeDelta() {
|
||||
return (unsigned long long)(tick2.QuadPart - tick1.QuadPart) / (double)freq.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -208,7 +208,7 @@ void Bridge::TxJob() {
|
||||
send(client_tx_sock,tx_buff,packet_size,0);
|
||||
#endif
|
||||
//free the packet
|
||||
free(currentPacket);
|
||||
FreePacket(currentPacket);
|
||||
}
|
||||
// No more packets, sleep.
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(500));
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "controller.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#define NOHARDWARE
|
||||
|
||||
//RampDemo Related
|
||||
int8_t RD_PACKET_ORIGINAL[RD_PACKET_SIZE];
|
||||
|
||||
@ -25,11 +23,16 @@ controller::controller(boost::lockfree::queue<buffer*, boost::lockfree::fixed_si
|
||||
processorThread = new Processor(&triggerProcessorQueue, &processorPostProcessorQueue_1);
|
||||
postProcessorThread = new postProcessor(&processorPostProcessorQueue_1, &controllerQueue_tx);
|
||||
|
||||
#ifndef NOHARDWARE
|
||||
pcieLinkThread = new PCIeLink(dataQueue);
|
||||
#endif
|
||||
|
||||
// set default values
|
||||
setCh(1);
|
||||
setTriggerCh(1);
|
||||
setLevel(50);
|
||||
setPerSize(1);
|
||||
setWindowSize(1000);
|
||||
|
||||
//RampDemo related
|
||||
for(int ch = 0; ch < RD_CHAN_COUNT; ch++) {
|
||||
@ -426,6 +429,9 @@ void controller::controllerPause()
|
||||
processorThread->processorPause();
|
||||
triggerThread->triggerPause();
|
||||
postProcessorThread->postProcessorPause();
|
||||
#ifndef NOHARDWARE
|
||||
pcieLinkThread->Pause();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -445,6 +451,9 @@ void controller::controllerUnPause()
|
||||
processorThread->processorUnpause();
|
||||
triggerThread->triggerUnpause();
|
||||
postProcessorThread->postProcessorUnpause();
|
||||
#ifndef NOHARDWARE
|
||||
pcieLinkThread->UnPause();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -16,7 +16,7 @@ import TestPoints from '../../util/testpoints';
|
||||
class Graph extends React.Component<any, any> {
|
||||
static instanceList: Graph[] = [];
|
||||
timerID: number = 0;
|
||||
generator: TestPoints = new TestPoints(50, 50);
|
||||
generator: TestPoints = new TestPoints(1000, 128);
|
||||
|
||||
componentDidMount() {
|
||||
Graph.instanceList.push(this);
|
||||
|
Loading…
Reference in New Issue
Block a user