Skip to content

Commit

Permalink
BERTDialog: Custom pattern, refclk out, TX line rate configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Aug 30, 2023
1 parent b7bcaa2 commit 18441d3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib
51 changes: 51 additions & 0 deletions src/ngscopeclient/BERTDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ BERTDialog::BERTDialog(SCPIBERT* bert, shared_ptr<BERTState> state, Session* ses
, m_bert(bert)
, m_state(state)
{
m_txPattern = bert->GetGlobalCustomPattern();
m_txPatternText = to_string_hex(m_txPattern);

//Transmit pattern
m_refclkIndex = bert->GetRefclkOutMux();
m_refclkNames = bert->GetRefclkOutMuxNames();

auto currentRate = bert->GetDataRate();
m_dataRateIndex = 0;
m_dataRates = bert->GetAvailableDataRates();
Unit bps(Unit::UNIT_BITRATE);
for(size_t i=0; i<m_dataRates.size(); i++)
{
auto rate = m_dataRates[i];
if(rate == currentRate)
m_dataRateIndex = i;

m_dataRateNames.push_back(bps.PrettyPrint(rate));
}
}

BERTDialog::~BERTDialog()
Expand All @@ -63,6 +82,8 @@ BERTDialog::~BERTDialog()

bool BERTDialog::DoRender()
{
float width = 10 * ImGui::GetFontSize();

//Device information
if(ImGui::CollapsingHeader("Info"))
{
Expand All @@ -86,10 +107,40 @@ bool BERTDialog::DoRender()
ImGui::EndDisabled();
}

//Global pattern generator settings
if(!m_bert->IsCustomPatternPerChannel())
{
if(ImGui::CollapsingHeader("Pattern Generator"))
{
ImGui::SetNextItemWidth(width);
if(ImGui::InputText("Custom Pattern", &m_txPatternText))
{
sscanf(m_txPatternText.c_str(), "%lx", &m_txPattern);
m_bert->SetGlobalCustomPattern(m_txPattern);
}

HelpMarker(to_string(m_bert->GetCustomPatternLength()) +
" -bit pattern sent by all channels in custom-pattern mode");
}
}

//Timebase settings
if(ImGui::CollapsingHeader("Timebase"))
{
ImGui::SetNextItemWidth(width);
if(Dialog::Combo("Clock Out", m_refclkNames, m_refclkIndex))
{
m_bert->SetRefclkOutMux(m_refclkIndex);

//Need to refresh custom pattern here
//because ML4039 sets this to 0xaaaa if we select SERDES mode on clock out
m_txPattern = m_bert->GetGlobalCustomPattern();
m_txPatternText = to_string_hex(m_txPattern);
}

ImGui::SetNextItemWidth(width);
if(Dialog::Combo("Data Rate", m_dataRateNames, m_dataRateIndex))
m_bert->SetDataRate(m_dataRates[m_dataRateIndex]);
}

return true;
Expand Down
13 changes: 13 additions & 0 deletions src/ngscopeclient/BERTDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ class BERTDialog : public Dialog

///@brief Set of channel names
std::vector<std::string> m_channelNames;

///@brief Custom transmit pattern
uint64_t m_txPattern;
std::string m_txPatternText;

///@brief Refclk output mux selector
int m_refclkIndex;
std::vector<std::string> m_refclkNames;

///@brief Data rate selector
int m_dataRateIndex;
std::vector<int64_t> m_dataRates;
std::vector<std::string> m_dataRateNames;
};


Expand Down
1 change: 1 addition & 0 deletions src/ngscopeclient/ngscopeclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <GLFW/glfw3.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <misc/cpp/imgui_stdlib.h>
#include <backends/imgui_impl_glfw.h>
#include <backends/imgui_impl_vulkan.h>

Expand Down

0 comments on commit 18441d3

Please sign in to comment.