Skip to content

Commit

Permalink
test: Adapt for usage with transparent tracers
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelpro committed Feb 7, 2024
1 parent 14a4dc7 commit 62251ab
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
12 changes: 6 additions & 6 deletions dv/BaudRateGen/BaudRateGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ constexpr unsigned txWidth = clog2(txRate);
constexpr unsigned rxShift = clog2(Oversample);
constexpr unsigned rxWidth = txWidth - rxShift;

static void reset(VBaudRateGen& rg, int phase = 0, unsigned rate = txRate) {
static void reset(auto& rg, int phase = 0, unsigned rate = txRate) {
rg.phase = !!phase;
rg.rate = rate;
rg.syncReset = 0;
nyu::reset(rg);
}

TEST_CASE("BaudRateGen, Reset") {
VBaudRateGen& rg {nyu::getDUT<VBaudRateGen>()};
auto& rg {nyu::getDUT<VBaudRateGen>()};
reset(rg, 0);

REQUIRE(rg.rxClk == 0);
Expand All @@ -45,7 +45,7 @@ TEST_CASE("BaudRateGen, Reset") {
}

TEST_CASE("BaudRateGen, phase") {
VBaudRateGen& rg {nyu::getDUT<VBaudRateGen>()};
auto& rg {nyu::getDUT<VBaudRateGen>()};
reset(rg);

rg.syncReset = 1;
Expand All @@ -65,7 +65,7 @@ TEST_CASE("BaudRateGen, phase") {


TEST_CASE("BaudRateGen, rxClk") {
VBaudRateGen& rg {nyu::getDUT<VBaudRateGen>()};
auto& rg {nyu::getDUT<VBaudRateGen>()};

for(unsigned i {2}; i < (1 << rxWidth); i <<= 1) {
reset(rg, 0, i << rxShift);
Expand All @@ -90,7 +90,7 @@ TEST_CASE("BaudRateGen, rxClk") {
}

TEST_CASE("BaudRateGen, txClk") {
VBaudRateGen& rg {nyu::getDUT<VBaudRateGen>()};
auto& rg {nyu::getDUT<VBaudRateGen>()};

for(unsigned i {2}; i < (1 << txWidth); i <<= 1) {
reset(rg, 0, i);
Expand All @@ -113,7 +113,7 @@ TEST_CASE("BaudRateGen, txClk") {
}

TEST_CASE("BaudRateGen, rx/tx sync") {
VBaudRateGen& rg {nyu::getDUT<VBaudRateGen>()};
auto& rg {nyu::getDUT<VBaudRateGen>()};

for(unsigned rate {2 << 4}; rate < 500; rate += 1) {
reset(rg, 0, rate);
Expand Down
4 changes: 2 additions & 2 deletions dv/Loopback/Loopback_tb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

#include <VLoopback_tb.h>

static void send(VLoopback_tb& lb, std::uint8_t val) {
static void send(auto& lb, std::uint8_t val) {
lb.data_tx = val;
lb.valid = 1;
nyu::tick(lb);
lb.valid = 0;
}

TEST_CASE("Loopback_tb") {
VLoopback_tb& lb {nyu::getDUT<VLoopback_tb>()};
auto& lb {nyu::getDUT<VLoopback_tb>()};

nyu::reset(lb);

Expand Down
19 changes: 9 additions & 10 deletions dv/UartRx/UartRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,28 @@ using VUartRx = VSyncUartRx;

constexpr unsigned Oversample = 16;

static void start(VUartRx& rx, unsigned ticks = Oversample) {
static void start(auto& rx, unsigned ticks = Oversample) {
rx.in = 1;
nyu::tick(rx);
rx.in = 0;
nyu::tick(rx, ticks);
}

static void transmit(VUartRx& rx, std::uint8_t val,
unsigned ticks = Oversample) {
static void transmit(auto& rx, std::uint8_t val, unsigned ticks = Oversample) {
for(unsigned i {0}; i < 8; ++i) {
rx.in = val & 0x1;
nyu::tick(rx, ticks);
val >>= 1;
}
}

static void start_transmit(VUartRx& rx, std::uint8_t val) {
static void start_transmit(auto& rx, std::uint8_t val) {
start(rx);
transmit(rx, val);
}

TEST_CASE("UartRx, reset") {
VUartRx& rx {nyu::getDUT<VUartRx>()};
auto& rx {nyu::getDUT<VUartRx>()};

nyu::reset(rx);

Expand All @@ -46,7 +45,7 @@ TEST_CASE("UartRx, reset") {
}

TEST_CASE("UartRx, done") {
VUartRx& rx {nyu::getDUT<VUartRx>()};
auto& rx {nyu::getDUT<VUartRx>()};

nyu::reset(rx);

Expand All @@ -60,7 +59,7 @@ TEST_CASE("UartRx, done") {
}

TEST_CASE("UartRx, resync") {
VUartRx& rx {nyu::getDUT<VUartRx>()};
auto& rx {nyu::getDUT<VUartRx>()};

nyu::reset(rx);

Expand All @@ -81,7 +80,7 @@ TEST_CASE("UartRx, resync") {
REQUIRE(rx.done == 1);
}

void check_data_error(VUartRx& rx) {
void check_data_error(auto& rx) {
rx.in = 1;
nyu::tick(rx);
rx.in = 0;
Expand All @@ -94,7 +93,7 @@ void check_data_error(VUartRx& rx) {
}

TEST_CASE("UartRx, error") {
VUartRx& rx {nyu::getDUT<VUartRx>()};
auto& rx {nyu::getDUT<VUartRx>()};

nyu::reset(rx);

Expand All @@ -118,7 +117,7 @@ TEST_CASE("UartRx, error") {
}

TEST_CASE("UartRx, idle") {
VUartRx& rx {nyu::getDUT<VUartRx>()};
auto& rx {nyu::getDUT<VUartRx>()};
nyu::reset(rx);

start_transmit(rx, 0xAA);
Expand Down
23 changes: 11 additions & 12 deletions dv/UartRx/UartRxEn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,33 @@ using VUartRxEn = VSyncUartRxEn;

constexpr unsigned Oversample = 16;

static void reset(VUartRxEn& rx) {
static void reset(auto& rx) {
rx.en = 1;
nyu::reset(rx);
}

static void start(VUartRxEn& rx, unsigned ticks = Oversample) {
static void start(auto& rx, unsigned ticks = Oversample) {
rx.in = 1;
nyu::tick(rx);
rx.in = 0;
nyu::tick(rx, ticks);
}

static void transmit(VUartRxEn& rx, std::uint8_t val,
unsigned ticks = Oversample) {
static void transmit(auto& rx, std::uint8_t val, unsigned ticks = Oversample) {
for(unsigned i {0}; i < 8; ++i) {
rx.in = val & 0x1;
nyu::tick(rx, ticks);
val >>= 1;
}
}

static void start_transmit(VUartRxEn& rx, std::uint8_t val) {
static void start_transmit(auto& rx, std::uint8_t val) {
start(rx);
transmit(rx, val);
}

TEST_CASE("UartRxEn, reset") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};

reset(rx);

Expand All @@ -52,7 +51,7 @@ TEST_CASE("UartRxEn, reset") {
}

TEST_CASE("UartRxEn, done") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};

reset(rx);

Expand All @@ -66,7 +65,7 @@ TEST_CASE("UartRxEn, done") {
}

TEST_CASE("UartRxEn, enable off") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};

reset(rx);
rx.en = 0;
Expand All @@ -79,7 +78,7 @@ TEST_CASE("UartRxEn, enable off") {
}

TEST_CASE("UartRxEn, resync") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};

reset(rx);

Expand All @@ -100,7 +99,7 @@ TEST_CASE("UartRxEn, resync") {
REQUIRE(rx.done == 1);
}

void check_data_error(VUartRxEn& rx) {
void check_data_error(auto& rx) {
rx.in = 1;
nyu::tick(rx);
rx.in = 0;
Expand All @@ -113,7 +112,7 @@ void check_data_error(VUartRxEn& rx) {
}

TEST_CASE("UartRxEn, error") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};

reset(rx);

Expand All @@ -137,7 +136,7 @@ TEST_CASE("UartRxEn, error") {
}

TEST_CASE("UartRxEn, idle") {
VUartRxEn& rx {nyu::getDUT<VUartRxEn>()};
auto& rx {nyu::getDUT<VUartRxEn>()};
reset(rx);

start_transmit(rx, 0xAA);
Expand Down
12 changes: 6 additions & 6 deletions dv/UartTx/UartTxEn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

#include <VUartTxEn.h>

static void reset(VUartTxEn& tx) {
static void reset(auto& tx) {
tx.en = 1;
nyu::reset(tx);
}

static void send(VUartTxEn& tx, std::uint8_t val) {
static void send(auto& tx, std::uint8_t val) {
tx.data = val;
tx.valid = 1;
nyu::tick(tx);
tx.valid = 0;
}

TEST_CASE("UartTxEn, reset") {
VUartTxEn& tx {nyu::getDUT<VUartTxEn>()};
auto& tx {nyu::getDUT<VUartTxEn>()};

reset(tx);

Expand All @@ -34,7 +34,7 @@ TEST_CASE("UartTxEn, reset") {
}

TEST_CASE("UartTxEn, busy/done") {
VUartTxEn& tx {nyu::getDUT<VUartTxEn>()};
auto& tx {nyu::getDUT<VUartTxEn>()};

reset(tx);

Expand All @@ -55,7 +55,7 @@ TEST_CASE("UartTxEn, busy/done") {
}

TEST_CASE("UartTxEn, data") {
VUartTxEn& tx {nyu::getDUT<VUartTxEn>()};
auto& tx {nyu::getDUT<VUartTxEn>()};

reset(tx);

Expand Down Expand Up @@ -88,7 +88,7 @@ TEST_CASE("UartTxEn, data") {
}

TEST_CASE("UartTxEn, async valid") {
VUartTxEn& tx {nyu::getDUT<VUartTxEn>()};
auto& tx {nyu::getDUT<VUartTxEn>()};

reset(tx);
tx.en = 0;
Expand Down
4 changes: 2 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"vcpkg-configuration": {
"default-registry": {
"kind": "git",
"baseline": "247662ef304453c72acd6b520fa7ff7656e7347c",
"baseline": "66b4b34d99ab272fcf21f2bd12b616e371c6bb31",
"repository": "https://github.com/microsoft/vcpkg.git"
},
"registries": [
{
"kind": "git",
"baseline": "ae7ee57bc8769e222d366f502283a5540f0fc06f",
"baseline": "7a6b61ca47ca041f1c6558c649cbc2ddbf11d57a",
"repository": "https://github.com/NYU-Processor-Design/nyu-registry.git",
"packages": [
"nyu-*"
Expand Down

0 comments on commit 62251ab

Please sign in to comment.