7
mirror of https://github.com/EEVengers/ThunderScope.git synced 2025-04-22 17:43:44 +00:00

XKCD Life

This commit is contained in:
Daniel Vasile 2021-03-22 20:06:08 -04:00
parent c9a4c2780a
commit cf4bd7da0b
5 changed files with 46 additions and 18 deletions
Software/waveview/scope_link

View File

@ -15,6 +15,7 @@
#include <WinIoCtl.h>
#include "xdma_public.h"
#include "common.hpp"
#pragma comment(lib, "setupapi.lib")
@ -62,6 +63,7 @@ class PCIeLink {
public:
bool connected;
PCIeLink();
PCIeLink(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQueue);
int Connect();
@ -71,6 +73,7 @@ public:
void ClockTick1();
void ClockTick2();
void PrintTimeDelta();
double GetTimeDelta();
~PCIeLink();
@ -86,6 +89,9 @@ private:
LARGE_INTEGER freq; //used for perforamnce testing
int64_t last_chunk_read;
//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 +99,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:

View File

@ -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;

View File

@ -225,13 +225,17 @@ void runPCIeTest() {
pcieLink->Write(clk_enable,nullptr);
pcieLink->Write(adc_enable,nullptr);
pcieLink->Write(dataMover_enable,nullptr);
//pcieLink->Write(dataMover_disable,nullptr);
uint8_t* buff = (uint8_t*)malloc(sizeof(uint8_t) * (1 << 23));
pcieLink->ClockTick1();
pcieLink->Read(buff);
pcieLink->ClockTick2();
pcieLink->PrintTimeDelta();
//read 5 times
for(int i = 0; i < 3; i++) {
pcieLink->ClockTick1();
pcieLink->Read(buff);
pcieLink->ClockTick2();
pcieLink->PrintTimeDelta();
}
FILE* fp = fopen("TestData.txt","w");
for(int i = 0; i < (1 << 23); i+= 8) {

View File

@ -129,21 +129,22 @@ void PCIeLink::Read(uint8_t* buff) {
//Once more than 2^23 bytes have been written, halt the datamover
bool enoughData = false;
int64_t current_chunk;
uint32_t kbytes_32_moved = 0;
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_32_moved),4);
error_code = ((kbytes_32_moved & 0xC0000000)>>30);
overflow_count = ((kbytes_32_moved & 0x3FFF0000)>>16);
kbytes_32_moved = kbytes_32_moved & 0x0000FFFF;
current_chunk = kbytes_32_moved / (1 << 8);
INFO << "error code: " << error_code;
INFO << "overflow count: " << overflow_count;
INFO << "32k_Bytes Transfered: " << kbytes_32_moved;
INFO << "Current Chunk: " << current_chunk;
_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 << "error code: " << error_code;
//INFO << "overflow count: " << overflow_count;
//INFO << "32k_Bytes Transfered: " << kbytes_32_moved;
//INFO << "Current Chunk: " << current_chunk;
if(last_chunk_read == -1) {
enoughData = (kbytes_32_moved >= (1 << 8));
enoughData = (kbytes_4_moved >= (1 << 11));
if(enoughData && current_chunk == 0) {
enoughData = false;
continue;
@ -166,8 +167,8 @@ 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);
}
@ -387,6 +388,15 @@ PCIeLink::PCIeLink() {
QueryPerformanceFrequency(&freq);
}
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;
QueryPerformanceFrequency(&freq);
this->outputQueue = outputQueue;
}
PCIeLink::~PCIeLink() {
if(user_handle != INVALID_HANDLE_VALUE)
CloseHandle(user_handle);
@ -394,7 +404,6 @@ PCIeLink::~PCIeLink() {
CloseHandle(c2h_0_handle);
}
void PCIeLink::ClockTick1() {
QueryPerformanceCounter(&tick1);
}
@ -415,6 +424,10 @@ void PCIeLink::PrintTimeDelta() {
INFO << "Time Delta is: " << time_sec;
}
double PCIeLink::GetTimeDelta() {
return (unsigned long long)(tick2.QuadPart - tick1.QuadPart) / (double)freq.QuadPart;
}

View File

@ -24,6 +24,7 @@ controller::controller(boost::lockfree::queue<buffer*, boost::lockfree::fixed_si
triggerThread = new Trigger(dataQueue, &triggerProcessorQueue, triggerLevel);
processorThread = new Processor(&triggerProcessorQueue, &processorPostProcessorQueue_1);
postProcessorThread = new postProcessor(&processorPostProcessorQueue_1, &controllerQueue_tx);
// set default values
setCh(1);