Skip to content
Snippets Groups Projects
Commit c3ff6984 authored by Thomas Owen James's avatar Thomas Owen James :speech_balloon:
Browse files

removed option to load sb852 bitfile from scdaq

parent 1950cc88
No related branches found
No related tags found
1 merge request!63removed option to load sb852 bitfile from scdaq
Pipeline #5691475 passed
......@@ -12,12 +12,6 @@
input:wzdma
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:micron_bitfile_path
## Settings for DMA input
# DMA device
......
#include "MicronDmaInputFilter.h"
#include <ctype.h>
......@@ -10,41 +9,32 @@
#include "format.h"
#include "log.h"
using uint256_t = boost::multiprecision::number<
boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude,
boost::multiprecision::unchecked, void>,
boost::multiprecision::et_off>;
MicronDmaInputFilter::MicronDmaInputFilter(size_t packetBufferSize, size_t nbPacketBuffers,
ctrl &control, config &conf)
: InputFilter(packetBufferSize, nbPacketBuffers, control) {
std::string bitFileName = conf.getBitFileName();
bool loadBitFile = conf.getLoadBitFile();
int err;
processorType_ = conf.getProcessorType();
// The RunBitFile function will locate a Pico card that can run the given bit
// file, and is not already opened in exclusive-access mode by another program.
// By default it requests exclusive access to the Pico card so no other programs
// will try to reuse the card and interfere with us.
// first argument sets share access to true for the pico driver,
// to allow other programs to e.g read registers
LOG(TRACE) << "Finding pico driver...";
int err = micron_find_pico_sb852(true, &pico_);
if (loadBitFile) {
LOG(DEBUG) << "Loading FPGA with '" << bitFileName << "' ...";
err = micron_run_bit_file(bitFileName.c_str(), &pico_);
} else {
// first argument sets share access to true for the pico driver,
// to allow other programs to e.g read registers
err = micron_find_pico_sb852(true, &pico_);
if (err < 0) {
// All functions in the Pico API return an error code. If that code is < 0,
// then you should use the PicoErrors_FullError function to decode the error message.
std::string error = "Find pico driver error " + *micron_picoerrors_fullerror(stream2_, 0, 0);
throw std::runtime_error(error);
}
LOG(TRACE) << "Opening streams to and from the FPGA";
stream2_ = micron_create_stream(pico_, 2);
if (stream2_ < 0) {
// All functions in the Pico API return an error code. If that code is < 0,
// then you should use the PicoErrors_FullError function to decode the error message.
throw std::runtime_error(bitFileName + ": CreateStream error: " +
micron_picoerrors_fullerror(stream2_, 0, packetBufferSize));
std::string error =
"CreateStream error: " + *micron_picoerrors_fullerror(stream2_, 0, int(packetBufferSize));
throw std::runtime_error(error);
}
LOG(TRACE) << "Created Micron DMA input filter";
}
......@@ -65,27 +55,7 @@ int pad_for_16bytes(int len) {
return pad_len;
}
// print <count> 256-bit numbers from buf
void print256(FILE *f, void *buf, int count) {
uint32_t *u32p = (uint32_t *)buf;
for (int i = 0; i < count; ++i) {
fprintf(f, "0x%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x\n", u32p[8 * i + 7], u32p[8 * i + 6],
u32p[8 * i + 5], u32p[8 * i + 4], u32p[8 * i + 3], u32p[8 * i + 2], u32p[8 * i + 1],
u32p[8 * i]);
}
}
// print <count> 128-bit numbers from buf
void print128(FILE *f, void *buf, int count) {
uint32_t *u32p = (uint32_t *)buf;
for (int i = 0; i < count; ++i)
fprintf(f, "0x%08x_%08x_%08x_%08x\n", u32p[4 * i + 3], u32p[4 * i + 2], u32p[4 * i + 1],
u32p[4 * i]);
}
ssize_t MicronDmaInputFilter::runMicronDAQ(char **buffer, size_t bufferSize) {
ssize_t MicronDmaInputFilter::runMicronDAQ(char **buffer) {
// Usually Pico streams come in two flavors: 4Byte wide, 16Byte wide
// (equivalent to 32bit, 128bit respectively) However, all calls to ReadStream
// and WriteStream must be 16Byte aligned (even for 4B wide streams) There is
......@@ -123,7 +93,7 @@ ssize_t MicronDmaInputFilter::runMicronDAQ(char **buffer, size_t bufferSize) {
if (processorType_ == StreamProcessor::ProcessorType::BRIL) {
u32p = (uint32_t *)((*buffer));
packetSize = 20 * 32 * 1791; // bril packet size 16*3488 + 32*8;
packetSize = 32 * 1791; // fixed bril 1-histo packet size
} else {
packetSize = 32 * (*((uint32_t *)((*buffer) + 8)) + 2);
}
......@@ -135,17 +105,17 @@ ssize_t MicronDmaInputFilter::runMicronDAQ(char **buffer, size_t bufferSize) {
err = micron_read_stream(pico_, stream2_, *buffer, packetSize);
if (err < 0) {
std::cout << "err = " << err << std::endl;
throw std::runtime_error("ReadStream finished with error");
std::string error =
"ReadStream error: " + *micron_picoerrors_fullerror(stream2_, *buffer, packetSize);
throw std::runtime_error(error);
}
return (packetSize);
}
// Print some additional info
void MicronDmaInputFilter::print(std::ostream &out) const {}
// Read a packet from DMA
ssize_t MicronDmaInputFilter::readInput(char **buffer, size_t bufferSize) {
return runMicronDAQ(buffer, bufferSize);
return runMicronDAQ(buffer);
}
// Required for virtual function but currently unused
void MicronDmaInputFilter::print(std::ostream &out) const {}
......@@ -18,11 +18,10 @@ class MicronDmaInputFilter : public InputFilter {
protected:
ssize_t readInput(char **buffer, size_t bufferSize); // Override
void print(std::ostream &out) const; // Override
private:
micron_private *pico_;
int stream2_;
ssize_t runMicronDAQ(char **buffer, size_t bufferSize);
ssize_t runMicronDAQ(char **buffer);
StreamProcessor::ProcessorType processorType_;
};
typedef std::shared_ptr<MicronDmaInputFilter> MicronDmaInputFilterPtr;
......
......@@ -93,8 +93,6 @@ class config {
return boost::lexical_cast<uint32_t>(v.c_str());
}
const std::string &getBitFileName() const { return vmap.at("bitFileName"); }
StreamProcessor::ProcessorType getProcessorType() const {
const std::string &input = vmap.at("processor_type");
if (input == "PASS_THROUGH") {
......@@ -125,8 +123,6 @@ class config {
return (true ? vmap.at("output_force_write") == "yes" : false);
}
bool getLoadBitFile() const { return (true ? vmap.at("loadBitFile") == "yes" : false); }
uint32_t getNOrbitsPerDMAPacket() const {
std::string v = vmap.at("NOrbitsPerDMAPacket");
return boost::lexical_cast<uint32_t>(v.c_str());
......
......@@ -209,8 +209,8 @@ size_t StreamProcessor::fillFRDEventHeader_V6(char *wr_ptr_FRDHead, uint32_t inp
}
uint32_t StreamProcessor::FillBril(char *rd_ptr, char *wr_ptr, char *end_ptr) {
static constexpr uint32_t NHistosPerPacket = 20; // should not be changed, any more and SB852
// crashes, would need to re-upload bitfile
static constexpr uint32_t NHistosPerPacket = 1; // set to 1 for minimum brildaq latency
uint32_t histo_i = 0, histo_word_i = 0;
std::array<std::array<uint32_t, constants::NBXPerOrbit + constants::NFramesInHistoHeader>,
NHistosPerPacket>
......@@ -232,11 +232,6 @@ uint32_t StreamProcessor::FillBril(char *rd_ptr, char *wr_ptr, char *end_ptr) {
continue;
}
if (histo_i == 0) {
continue;
} // Currently appears to be a bug where first histogram of packet is
// truncated, need to understand and fix, for now skip
if (histo_word_i < constants::NFramesInHistoHeader) {
histo_arr[histo_i][histo_word_i] = (fr->word >> 0) & 0xffffffff;
} else {
......
......@@ -12,12 +12,6 @@
#
input:filedma
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:/home/tjames/Pico_Toplevel-bril-250722-1.tgz
## Settings for DMA input
# DMA device
......
......@@ -12,12 +12,6 @@
#
input:filedma
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:/home/tjames/Pico_Toplevel-bril-250722-1.tgz
## Settings for DMA input
# DMA device
......
......@@ -12,12 +12,6 @@
#
input:filedma
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:/home/tjames/Pico_Toplevel-bril-250722-1.tgz
## Settings for DMA input
# DMA device
......
......@@ -12,12 +12,6 @@
#
input:filedma
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:/home/tjames/Pico_Toplevel-bril-250722-1.tgz
## Settings for DMA input
# DMA device
......
......@@ -12,12 +12,6 @@
#
input:micronDMA
# Settings for Micron board only
loadBitFile:yes
# ONLY for Micron Board/DMA, must be in tgz format, produced by pico utility package_flash
bitFileName:/home/tjames/Pico_Toplevel-bril-250722-1.tgz
## Settings for DMA input
# DMA device
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment