58#include <shared_mutex>
60#include <sigc++/sigc++.h>
62#include <yaml-cpp/yaml.h>
64#include "../log/log.h"
65#include "../xptools/TimeUtil.h"
71#pragma GCC diagnostic push
72#pragma GCC diagnostic ignored "-Wshadow"
73#include <vulkan/vulkan_raii.hpp>
74#pragma GCC diagnostic pop
79extern bool g_hasAvx512F;
80extern bool g_hasAvx512VL;
81extern bool g_hasAvx512DQ;
87#define i64abs(x) llabs(x)
89#define i64abs(x) labs(x)
111uint32_t GetComputeBlockCount(
size_t numGlobal,
size_t blockSize);
128#include "SCPIDevice.h"
133#if !defined(_WIN32) && !defined(__APPLE__)
162#include "PowerSupply.h"
163#include "PowerSupplyChannel.h"
164#include "RFSignalGenerator.h"
165#include "RFSignalGeneratorChannel.h"
166#include "SCPIInstrument.h"
170#include "SCPIFunctionGenerator.h"
172#include "SCPIMiscInstrument.h"
173#include "SCPIMultimeter.h"
174#include "SCPIOscilloscope.h"
175#include "SCPIPowerSupply.h"
176#include "SCPIRFSignalGenerator.h"
177#include "SpectrometerDarkFrameChannel.h"
192#include "SpectrumChannel.h"
202std::string GetDefaultChannelColor(
int i);
204std::string
Trim(
const std::string& str);
205std::string
TrimQuotes(
const std::string& str);
206std::string BaseName(
const std::string& path);
208std::string
ReadFile(
const std::string& path);
212void GetTimestampOfFile(std::string path, time_t& timestamp, int64_t& fs);
215std::string
to_string_hex(uint64_t n,
bool zeropad =
false,
int len = 0);
221void InitializeSearchPaths();
226void ScopehalStaticCleanup();
233std::vector<std::string>
explode(
const std::string& str,
char separator);
234std::string
str_replace(
const std::string& search,
const std::string& replace,
const std::string& subject);
237#define FS_PER_PICOSECOND 1e3
238#define FS_PER_NANOSECOND 1e6
239#define FS_PER_MICROSECOND 1e9
240#define FS_PER_SECOND 1e15
241#define SECONDS_PER_FS 1e-15
245#define stos(str) static_cast<size_t>(stoll(str))
247#define stos(str) static_cast<size_t>(stol(str))
250extern std::vector<std::string> g_searchPaths;
281std::string NarrowPath(
wchar_t* wide);
283std::string ExpandPath(
const std::string& in);
284void CreateDirectory(
const std::string& path);
288uint32_t
CRC32(
const uint8_t* bytes,
size_t start,
size_t end);
289uint32_t
CRC32(
const std::vector<uint8_t>& bytes);
291uint32_t
ColorFromString(
const std::string& str,
unsigned int alpha = 255);
Declaration of AcceleratorBuffer.
Declaration of Bijection.
Helper class for binary driver: provides methods for handling binary data.
Declaration of CANChannel, CANSymbol, and CANWaveform.
Helper class for command line drivers: provides helper methods for command line based communication w...
Declaration of ComputePipeline.
Declaration of DigitalIOChannel.
Declaration of DigitalOutputChannel.
Declaration of FilterGraphExecutor.
Declaration of FilterParameter.
Declaration of FlowGraphNode.
Inline functions for FlowGraphNode which reference OscilloscopeChannel class.
Declaration of FunctionGeneratorChannel.
Declaration of FunctionGenerator.
Declaration of HIDInstrument.
Declaration of IBISParser, IVCurve, IBISCorner, and VTCurves.
Declaration of IDTable class.
Declaration of ImportFilter.
Declaration of Instrument.
Declaration of ModbusInstrument.
Declaration of MultimeterChannel.
Declaration of Multimeter.
Declaration of OscilloscopeChannel.
Declaration of Oscilloscope.
Declaration of PeakDetectionFilter.
Declaration of QueueManager and QueueHandle.
Declaration of SCPIHIDTransport.
Declaration of SCPILxiTransport.
Declaration of SCPINullTransport.
Declaration of SCPISocketCANTransport.
Declaration of SCPISocketTransport.
Declaration of Spectrometer.
Declaration of SCPITMCTransport.
Declaration of SCPITransport.
Declaration of SCPITwinLanTransport.
Declaration of SCPIUARTTransport.
Declaration of SParameterChannel.
Declaration of SParameterFilter.
Declaration of SParameterSourceFilter.
Declaration of SParameters and related classes.
Declaration of StreamDescriptor.
Inline functions for StreamDescriptor.
Declaration of SwitchMatrix.
Declaration of TouchstoneParser.
Declaration of VICPSocketTransport.
Definition: scopehal.h:277
bool g_hasShaderAtomicFloat
Indicates whether atomic operations on the float type are available in shaders.
Definition: VulkanInit.cpp:189
uint8_t g_vkComputeDeviceUuid[16]
UUID of g_vkComputeDevice.
Definition: VulkanInit.cpp:130
bool VulkanInit(bool skipGLFW=false)
Initialize a Vulkan context for compute.
Definition: VulkanInit.cpp:258
bool g_vulkanDeviceIsIntelMesa
Indicates that the Vulkan driver is Mesa on an Intel GPU.
Definition: VulkanInit.cpp:235
bool g_hasShaderInt64
Indicates whether the int64 type is available for use in shaders and SSBOs.
Definition: VulkanInit.cpp:171
std::unique_ptr< vk::raii::Instance > g_vkInstance
Global Vulkan instance.
Definition: VulkanInit.cpp:65
bool g_hasPushDescriptor
Indicates whether the VK_KHR_push_descriptor extension is available.
Definition: VulkanInit.cpp:207
bool g_hasMemoryBudget
Indicates whether the VK_EXT_memory_budget extension is available.
Definition: VulkanInit.cpp:201
std::unique_ptr< QueueManager > g_vkQueueManager
Allocates QueueHandle objects.
Definition: VulkanInit.cpp:106
bool g_hasShaderInt16
Indicates whether the int16 type is available for use in shaders and SSBOs.
Definition: VulkanInit.cpp:177
bool g_hasDebugUtils
Indicates whether the VK_EXT_debug_utils extension is available.
Definition: VulkanInit.cpp:195
bool g_vulkanDeviceIsMoltenVK
Indicates that the Vulkan driver is MoltenVK.
Definition: VulkanInit.cpp:247
vk::raii::Context g_vkContext
Global Vulkan context.
Definition: VulkanInit.cpp:59
bool g_hasShaderFloat64
Indicates whether the float64 type is available for use in shaders and SSBOs.
Definition: VulkanInit.cpp:165
uint32_t g_vkLocalMemoryHeap
Heap from which g_vkLocalMemoryType is allocated.
Definition: VulkanInit.cpp:154
uint32_t g_vkPinnedMemoryHeap
Heap from which g_vkPinnedMemoryType is allocated.
Definition: VulkanInit.cpp:148
size_t g_maxComputeGroupCount[3]
Maximum size of a Vulkan dispatch group for compute shaders, in each axis.
Definition: VulkanInit.cpp:226
bool g_vulkanDeviceIsAnyMesa
Indicates that the Vulkan driver is Mesa on any GPU.
Definition: VulkanInit.cpp:241
vk::raii::PhysicalDevice * g_vkComputePhysicalDevice
Physical device for g_vkComputeDevice.
Definition: VulkanInit.cpp:142
bool g_hasShaderInt8
Indicates whether the int8 type is available for use in shaders and SSBOs.
Definition: VulkanInit.cpp:183
bool g_vulkanDeviceHasUnifiedMemory
Indicates whether the Vulkan device is unified memory.
Definition: VulkanInit.cpp:220
uint32_t g_vkComputeDeviceDriverVer
Driver version of g_vkComputeDevice.
Definition: VulkanInit.cpp:136
string str_replace(const string &search, const string &replace, const string &subject)
Replaces all occurrences of the search string with "replace" in the given string.
Definition: scopehal.cpp:906
string TrimQuotes(const string &str)
Removes quotes from the start and end of a string.
Definition: scopehal.cpp:539
vector< uint32_t > ReadDataFileUint32(const string &relpath)
Locates and returns the contents of a data file as a std::vector<uint32_t>
Definition: scopehal.cpp:800
uint64_t ConvertVectorSignalToScalar(const vector< bool > &bits)
Converts a vector bus signal into a scalar (up to 64 bits wide)
Definition: scopehal.cpp:331
vector< string > explode(const string &str, char separator)
Splits a string up into an array separated by delimiters.
Definition: scopehal.cpp:872
string strtolower(const string &s)
Converts a string to lower case.
Definition: scopehal.cpp:895
string Trim(const string &str)
Removes whitespace from the start and end of a string.
Definition: scopehal.cpp:507
string ReadFile(const string &path)
Returns the contents of a file.
Definition: scopehal.cpp:649
string FindDataFile(const string &relpath)
Locates a data file.
Definition: scopehal.cpp:832
string ReadDataFile(const string &relpath)
Locates and returns the contents of a data file as a std::string.
Definition: scopehal.cpp:767
void TransportStaticInit()
Static initialization for SCPI transports.
Definition: scopehal.cpp:159
void InitializePlugins()
Initialize all plugins.
Definition: scopehal.cpp:342
const char * ScopehalGetVersion()
Returns the library version string (Semantic Version formatted)
Definition: scopehal.cpp:1023
uint32_t CRC32(const uint8_t *bytes, size_t start, size_t end)
Calculates a CRC32 checksum using the standard Ethernet polynomial.
Definition: scopehal.cpp:992
uint64_t prev_pow2(uint64_t v)
Rounds a 64-bit integer down to the next power of 2.
Definition: scopehal.cpp:636
std::string GetDirOfCurrentExecutable()
Gets the path to the directory containing the current executable.
Definition: scopehal.cpp:681
std::string to_string_sci(double d)
Like std::to_string, but output in scientific notation.
Definition: scopehal.cpp:584
uint64_t next_pow2(uint64_t v)
Rounds a 64-bit integer up to the next power of 2.
Definition: scopehal.cpp:612
std::string to_string_hex(uint64_t n, bool zeropad=false, int len=0)
Like std::to_string, but output in hex.
Definition: scopehal.cpp:594
void DetectCPUFeatures()
Static initialization for CPU feature flags.
Definition: scopehal.cpp:186
void DriverStaticInit()
Static initialization for instrument drivers.
Definition: scopehal.cpp:228
bool g_gpuFilterEnabled
True if filters can use GPU acceleration.
Definition: scopehal.cpp:140
std::shared_mutex g_vulkanActivityMutex
Mutex for controlling access to background Vulkan activity.
Definition: scopehal.cpp:154
float FreqToPhase(float hz)
Converts a frequency in Hz to a phase velocity in rad/sec.
Definition: scopehal.cpp:576
Definition: scopehal.h:254
Definition: scopehal.h:106