From b3df6a0ebfa288d032d917b48b69f036444e57b6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 23 Jan 2011 18:48:16 +0000 Subject: usrp-e100: created component for stand-alone usrp-e utils and added wb test util --- host/usrp_e_utils/usrp-e-wb-test.cpp | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 host/usrp_e_utils/usrp-e-wb-test.cpp (limited to 'host/usrp_e_utils/usrp-e-wb-test.cpp') diff --git a/host/usrp_e_utils/usrp-e-wb-test.cpp b/host/usrp_e_utils/usrp-e-wb-test.cpp new file mode 100644 index 000000000..871cc46cc --- /dev/null +++ b/host/usrp_e_utils/usrp-e-wb-test.cpp @@ -0,0 +1,111 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include + +#include //ioctl +#include //open, close + +#include +#include "usrp_e100_regs.hpp" + +static const size_t num_test_iters = 432; + +static int fp; + +static int peek16(int reg){ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL16, &d); + return d.buf[0]; +} + +static void poke16(int reg, int val){ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); +} + +static int peek32(int reg){ + int ret; + struct usrp_e_ctl32 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL32, &d); + return d.buf[0]; +} + +static void poke32(int reg, int val){ + int ret; + struct usrp_e_ctl32 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL32, &d); +} + +int main(int, char *[]){ + + srandom(time(NULL)); //seed random() + + if ((fp = ::open("/dev/usrp_e0", O_RDWR)) < 0){ + std::cerr << "Open failed" << std::endl; + return -1; + } + + size_t num_pass = 0, num_fail = 0; + for (size_t i = 0; i < num_test_iters; i++){ + //make random values + int random_test32 = ::random(); + int random_test16 = ::random() & 0xffff; + int random_secs = ::random(); + + //set a bunch of registers + poke16(UE_REG_MISC_TEST, random_test16); + poke32(UE_REG_SR_MISC_TEST32, random_test32); + poke32(UE_REG_TIME64_TICKS, 0); + poke32(UE_REG_TIME64_IMM, 1); //immediate + poke32(UE_REG_TIME64_SECS, random_secs); + + //read a bunch of registers + if ( + (peek16(UE_REG_MISC_TEST) == random_test16) and + (peek32(UE_REG_RB_MISC_TEST32) == random_test32) and + (peek32(UE_REG_RB_TIME_NOW_SECS) == random_secs) and + (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and + true) num_pass++; + else num_fail++; + } + + std::cout << "num pass: " << num_pass << std::endl; + std::cout << "num fail: " << num_fail << std::endl; + + ::close(fp); + return 0; +} -- cgit v1.2.3 From c926cf77bb9b132172b0e900cea960abd6c5a43e Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 26 Jan 2011 15:55:44 -0800 Subject: Local changes for wishbone tests, PLease review carefully. --- host/usrp_e_utils/usrp-e-wb-test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'host/usrp_e_utils/usrp-e-wb-test.cpp') diff --git a/host/usrp_e_utils/usrp-e-wb-test.cpp b/host/usrp_e_utils/usrp-e-wb-test.cpp index 871cc46cc..3d6a8d101 100644 --- a/host/usrp_e_utils/usrp-e-wb-test.cpp +++ b/host/usrp_e_utils/usrp-e-wb-test.cpp @@ -26,7 +26,7 @@ #include #include "usrp_e100_regs.hpp" -static const size_t num_test_iters = 432; +static const size_t num_test_iters = 10000000; static int fp; @@ -81,6 +81,10 @@ int main(int, char *[]){ size_t num_pass = 0, num_fail = 0; for (size_t i = 0; i < num_test_iters; i++){ + if(i%1000000 == 0) { + std::cout << "num pass: " << num_pass; + std::cout << "\tnum fail: " << num_fail << std::endl; + } //make random values int random_test32 = ::random(); int random_test16 = ::random() & 0xffff; @@ -98,7 +102,7 @@ int main(int, char *[]){ (peek16(UE_REG_MISC_TEST) == random_test16) and (peek32(UE_REG_RB_MISC_TEST32) == random_test32) and (peek32(UE_REG_RB_TIME_NOW_SECS) == random_secs) and - (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and +// (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and true) num_pass++; else num_fail++; } -- cgit v1.2.3