summaryrefslogtreecommitdiff
path: root/gr-radar-mono/src/fpga/tb
diff options
context:
space:
mode:
Diffstat (limited to 'gr-radar-mono/src/fpga/tb')
-rw-r--r--gr-radar-mono/src/fpga/tb/Makefile.am30
-rw-r--r--gr-radar-mono/src/fpga/tb/radar_tb.sav23
-rwxr-xr-xgr-radar-mono/src/fpga/tb/radar_tb.sh3
-rw-r--r--gr-radar-mono/src/fpga/tb/radar_tb.v182
-rwxr-xr-xgr-radar-mono/src/fpga/tb/radar_tb_wave.sh2
5 files changed, 240 insertions, 0 deletions
diff --git a/gr-radar-mono/src/fpga/tb/Makefile.am b/gr-radar-mono/src/fpga/tb/Makefile.am
new file mode 100644
index 000000000..9e3aef3a5
--- /dev/null
+++ b/gr-radar-mono/src/fpga/tb/Makefile.am
@@ -0,0 +1,30 @@
+#
+# Copyright 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+EXTRA_DIST = \
+ radar_tb.v \
+ radar_tb.sav \
+ radar_tb.sh \
+ radar_tb_wave.sh
+
+MOSTLYCLEANFILES = *~ *.vcd *.out* radar_tb
diff --git a/gr-radar-mono/src/fpga/tb/radar_tb.sav b/gr-radar-mono/src/fpga/tb/radar_tb.sav
new file mode 100644
index 000000000..a4015a764
--- /dev/null
+++ b/gr-radar-mono/src/fpga/tb/radar_tb.sav
@@ -0,0 +1,23 @@
+*-20.535921 1109000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
+@28
+radar_tb.clk
+radar_tb.ena
+radar_tb.rst
+radar_tb.uut.reset
+radar_tb.uut.tx_enable
+radar_tb.uut.rx_enable
+@200
+-
+@24
+radar_tb.uut.freq[31:0]
+@421
+radar_tb.uut.controller.ampl_o[15:0]
+@200
+-
+@28
+radar_tb.tx_strobe
+@8420
+radar_tb.uut.tx_dac_i_o[13:0]
+radar_tb.uut.tx_dac_q_o[13:0]
+@200
+-
diff --git a/gr-radar-mono/src/fpga/tb/radar_tb.sh b/gr-radar-mono/src/fpga/tb/radar_tb.sh
new file mode 100755
index 000000000..a255ec854
--- /dev/null
+++ b/gr-radar-mono/src/fpga/tb/radar_tb.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+iverilog -y ../lib/ -y ../../../../usrp/fpga/sdr_lib \
+ radar_tb.v -o radar_tb && ./radar_tb > radar_tb.out
diff --git a/gr-radar-mono/src/fpga/tb/radar_tb.v b/gr-radar-mono/src/fpga/tb/radar_tb.v
new file mode 100644
index 000000000..5551a1672
--- /dev/null
+++ b/gr-radar-mono/src/fpga/tb/radar_tb.v
@@ -0,0 +1,182 @@
+// -*- verilog -*-
+//
+// USRP - Universal Software Radio Peripheral
+//
+// Copyright (C) 2007 Corgan Enterprises 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 2 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, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA
+//
+
+`timescale 1ns/1ps
+
+`include "../lib/radar.v"
+
+module radar_tb;
+
+ // System bus
+ reg clk;
+ reg rst;
+ reg ena;
+
+ // Configuration bus
+ reg [6:0] saddr;
+ reg [31:0] sdata;
+ reg s_strobe;
+
+ // DAC bus
+ reg tx_strobe;
+ wire [13:0] tx_dac_i;
+ wire [13:0] tx_dac_q;
+
+ // ADC bus
+ reg rx_strobe;
+ reg [15:0] rx_adc_i;
+ reg [15:0] rx_adc_q;
+
+ // FIFO bus
+ wire fifo_strobe;
+ wire [15:0] fifo_i;
+ wire [15:0] fifo_q;
+
+ // Configuration shadow registers
+ reg [31:0] mode;
+
+ radar uut
+ (.clk_i(clk),.saddr_i(saddr),.sdata_i(sdata),.s_strobe_i(s_strobe),
+ .tx_strobe_i(tx_strobe),.tx_dac_i_o(tx_dac_i),.tx_dac_q_o(tx_dac_q),
+ .rx_strobe_i(rx_strobe),.rx_adc_i_i(rx_adc_i),.rx_adc_q_i(rx_adc_q),
+ .rx_strobe_o(fifo_strobe),.rx_ech_i_o(fifo_i),.rx_ech_q_o(fifo_q));
+
+ // Drive tx_strobe @ half clock rate
+ always @(posedge clk)
+ tx_strobe <= ~tx_strobe;
+
+ // Start up initialization
+ initial
+ begin
+ clk = 0;
+ rst = 0;
+ ena = 0;
+ saddr = 0;
+ sdata = 0;
+ s_strobe = 0;
+ tx_strobe = 0;
+ rx_strobe = 1;
+ rx_adc_i = 0;
+ rx_adc_q = 0;
+ mode = 0;
+
+ @(posedge clk);
+ rst = 1;
+ @(posedge clk);
+ rst = 0;
+ @(posedge clk);
+ ena = 1;
+ end
+
+ always
+ #5 clk <= ~clk;
+
+ initial
+ begin
+ //$monitor($time, " clk=%b rst=%b", clk, uut.reset);
+
+ $dumpfile("radar_tb.vcd");
+ $dumpvars(0, radar_tb);
+ end
+
+ // Test tasks
+ task write_cfg_register;
+ input [6:0] regno;
+ input [31:0] value;
+
+ begin
+ @(posedge clk);
+ saddr <= regno;
+ sdata <= value;
+ s_strobe <= 1'b1;
+ @(posedge clk);
+ s_strobe <= 0;
+ end
+ endtask // write_cfg_register
+
+ // Application reset line
+ task set_reset;
+ input reset;
+
+ begin
+ mode = reset ? (mode | `bmFR_RADAR_MODE_RESET) : (mode & ~`bmFR_RADAR_MODE_RESET);
+ write_cfg_register(`FR_RADAR_MODE, mode);
+ end
+ endtask // reset
+
+ // Enable/disable transmitter
+ task enable_tx;
+ input enabled;
+
+ begin
+ mode = enabled ? (mode | `bmFR_RADAR_MODE_TX) : (mode & ~`bmFR_RADAR_MODE_TX);
+ write_cfg_register(`FR_RADAR_MODE, mode);
+ end
+ endtask // enable_tx
+
+ // Enable/disable receiver
+ task enable_rx;
+ input enabled;
+
+ begin
+ mode = enabled ? (mode | `bmFR_RADAR_MODE_RX) : (mode & ~`bmFR_RADAR_MODE_RX);
+ write_cfg_register(`FR_RADAR_MODE, mode);
+ end
+ endtask // enable_rx
+
+ // Waveform amplitude
+ task set_amplitude;
+ input [13:0] amp;
+
+ begin
+ write_cfg_register(`FR_RADAR_AMPL, amp);
+ end
+ endtask // set_amplitude
+
+ // Waveform frequency
+ task set_frequency;
+ input [31:0] freq;
+
+ begin
+ write_cfg_register(`FR_RADAR_FREQ1N, freq);
+ end
+ endtask // frequency
+
+ // Test transmitter functionality
+ task test_tx;
+ begin
+ #20 set_reset(1);
+ #20 set_amplitude(16'd9946);
+ #20 set_frequency(32'h08000000);
+ #20 enable_tx(1);
+ #20 enable_rx(0);
+ #20 set_reset(0);
+ #10000;
+ end
+ endtask // test_tx
+
+ // Execute tests
+ initial
+ begin
+ #20 test_tx;
+ #100 $finish;
+ end
+endmodule
diff --git a/gr-radar-mono/src/fpga/tb/radar_tb_wave.sh b/gr-radar-mono/src/fpga/tb/radar_tb_wave.sh
new file mode 100755
index 000000000..45bba9f5e
--- /dev/null
+++ b/gr-radar-mono/src/fpga/tb/radar_tb_wave.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+gtkwave radar_tb.vcd radar_tb.sav