Compare commits
17 commits
master
...
dev-larger
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd247aaedd | ||
|
|
d745aee7d1 | ||
|
|
1ed7eae6da | ||
|
|
fdfcbe729e | ||
|
|
c4389a41a1 | ||
|
|
09619ffc6e | ||
|
|
52bc9f816d | ||
|
|
a7f8dfe1cd | ||
|
|
16cc54d4d4 | ||
|
|
d4d5f19d50 | ||
|
|
eee90e037c | ||
|
|
74865da9ba | ||
|
|
5af24d2ea0 | ||
|
|
b37fcaaa46 | ||
|
|
8b1127172a | ||
|
|
4f420975fa | ||
|
|
21052767ca |
49 changed files with 1645 additions and 68 deletions
|
|
@ -6,6 +6,11 @@ hosted on GitHub: https://github.com/nuand/bladeRF
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
v2.5.0 (2024-07-30)
|
||||||
|
--------------------------------
|
||||||
|
* Bumped GPIF DMA buffer size to 8192 bytes
|
||||||
|
* Reduced the number of GPIF DMA buffers to 11 per channel
|
||||||
|
|
||||||
v2.4.0 (2020-08-01)
|
v2.4.0 (2020-08-01)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
* Add ability to send short packets to FX3 from FPGA
|
* Add ability to send short packets to FX3 from FPGA
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules)
|
||||||
|
|
||||||
# Update these definitions when updating the firmware version
|
# Update these definitions when updating the firmware version
|
||||||
set(VERSION_INFO_MAJOR 2)
|
set(VERSION_INFO_MAJOR 2)
|
||||||
set(VERSION_INFO_MINOR 4)
|
set(VERSION_INFO_MINOR 5)
|
||||||
set(VERSION_INFO_PATCH 0)
|
set(VERSION_INFO_PATCH 0)
|
||||||
|
|
||||||
if(NOT DEFINED VERSION_INFO_EXTRA)
|
if(NOT DEFINED VERSION_INFO_EXTRA)
|
||||||
|
|
|
||||||
|
|
@ -290,8 +290,8 @@ static void NuandRFLinkStart(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
CyU3PMemSet((uint8_t *)&dmaCfg, 0, sizeof(dmaCfg));
|
CyU3PMemSet((uint8_t *)&dmaCfg, 0, sizeof(dmaCfg));
|
||||||
dmaCfg.size = size * 2;
|
dmaCfg.size = size * 8;
|
||||||
dmaCfg.count = 22;
|
dmaCfg.count = 11;
|
||||||
dmaCfg.prodSckId = BLADE_RF_SAMPLE_EP_PRODUCER_USB_SOCKET;
|
dmaCfg.prodSckId = BLADE_RF_SAMPLE_EP_PRODUCER_USB_SOCKET;
|
||||||
dmaCfg.consSckId = CY_U3P_PIB_SOCKET_3;
|
dmaCfg.consSckId = CY_U3P_PIB_SOCKET_3;
|
||||||
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
|
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ proc compile_fx3_gpif { root } {
|
||||||
vlib work
|
vlib work
|
||||||
|
|
||||||
vcom -2008 -work work [file join $root ./synthesis/set_clear_ff.vhd]
|
vcom -2008 -work work [file join $root ./synthesis/set_clear_ff.vhd]
|
||||||
|
vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd]
|
||||||
vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif.vhd]
|
vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif.vhd]
|
||||||
vcom -2008 -work work [file join $root ./simulation/util.vhd]
|
vcom -2008 -work work [file join $root ./simulation/util.vhd]
|
||||||
vcom -2008 -work work [file join $root ./simulation/fx3_model.vhd]
|
vcom -2008 -work work [file join $root ./simulation/fx3_model.vhd]
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ proc compile_nuand { root platform } {
|
||||||
|
|
||||||
vcom -work nuand -2008 [file join $root ./synthesis/tb/atsc_tx_tb.vhd]
|
vcom -work nuand -2008 [file join $root ./synthesis/tb/atsc_tx_tb.vhd]
|
||||||
|
|
||||||
|
vcom -work nuand -2008 [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd]
|
||||||
vcom -work nuand -2008 [file join $root ./simulation/fx3_model.vhd]
|
vcom -work nuand -2008 [file join $root ./simulation/fx3_model.vhd]
|
||||||
vcom -work nuand -2008 [file join $root ./simulation/lms6002d_model.vhd]
|
vcom -work nuand -2008 [file join $root ./simulation/lms6002d_model.vhd]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ library ieee;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.util.all;
|
use work.util.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
|
|
||||||
entity fx3_model is
|
entity fx3_model is
|
||||||
port (
|
port (
|
||||||
|
|
@ -102,7 +104,7 @@ begin
|
||||||
done <= rx_done and tx_done;
|
done <= rx_done and tx_done;
|
||||||
|
|
||||||
rx_sample_stream : process
|
rx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable req_time : time;
|
variable req_time : time;
|
||||||
begin
|
begin
|
||||||
|
|
@ -155,7 +157,7 @@ begin
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
tx_sample_stream : process
|
tx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable timestamp_cntr : natural := 80;
|
variable timestamp_cntr : natural := 80;
|
||||||
variable header_len : natural := 0;
|
variable header_len : natural := 0;
|
||||||
|
|
@ -201,7 +203,7 @@ begin
|
||||||
data_out := x"12341234";
|
data_out := x"12341234";
|
||||||
when 2 =>
|
when 2 =>
|
||||||
data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32));
|
data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32));
|
||||||
timestamp_cntr := timestamp_cntr + 508 * 2;
|
timestamp_cntr := timestamp_cntr + (GPIF_BUF_SIZE_SS-4) * 2;
|
||||||
when 3 =>
|
when 3 =>
|
||||||
data_out := (others => '0');
|
data_out := (others => '0');
|
||||||
when 4 =>
|
when 4 =>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ library nuand ;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
library std ;
|
library std ;
|
||||||
use std.env.all ;
|
use std.env.all ;
|
||||||
|
|
@ -435,8 +436,8 @@ begin
|
||||||
wait until reset = '0' ;
|
wait until reset = '0' ;
|
||||||
end if ;
|
end if ;
|
||||||
while true loop
|
while true loop
|
||||||
wait until rising_edge(fx3_clock) and unsigned(rx_sample_fifo.rused) > 512 ;
|
wait until rising_edge(fx3_clock) and unsigned(rx_sample_fifo.rused) > GPIF_BUF_SIZE_SS;
|
||||||
for i in 1 to 512 loop
|
for i in 1 to GPIF_BUF_SIZE_SS loop
|
||||||
rx_sample_fifo.rreq <= '1' ;
|
rx_sample_fifo.rreq <= '1' ;
|
||||||
nop( fx3_clock, 1 ) ;
|
nop( fx3_clock, 1 ) ;
|
||||||
if( CHECK_OVERFLOW ) then
|
if( CHECK_OVERFLOW ) then
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ library ieee;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fifo_readwrite_p.all;
|
use work.fifo_readwrite_p.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fifo_reader is
|
entity fifo_reader is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -71,8 +72,8 @@ end entity;
|
||||||
|
|
||||||
architecture simple of fifo_reader is
|
architecture simple of fifo_reader is
|
||||||
|
|
||||||
constant DMA_BUF_SIZE_SS : natural := 512;
|
constant DMA_BUF_SIZE_SS : natural := GPIF_BUF_SIZE_SS;
|
||||||
constant DMA_BUF_SIZE_HS : natural := 256;
|
constant DMA_BUF_SIZE_HS : natural := GPIF_BUF_SIZE_HS;
|
||||||
|
|
||||||
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
|
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
|
||||||
signal underflow_detected : std_logic := '0';
|
signal underflow_detected : std_logic := '0';
|
||||||
|
|
@ -493,7 +494,11 @@ begin
|
||||||
-- still need to be processed (not including the first). This becomes the number of clock
|
-- still need to be processed (not including the first). This becomes the number of clock
|
||||||
-- cycles to wait before asserting the FIFO read request to get a new batch of samples.
|
-- cycles to wait before asserting the FIFO read request to get a new batch of samples.
|
||||||
fifo_future.samples_left_init <= NUM_STREAMS - fifo_current.enabled_channels;
|
fifo_future.samples_left_init <= NUM_STREAMS - fifo_current.enabled_channels;
|
||||||
fifo_future.samples_left <= NUM_STREAMS - fifo_current.enabled_channels;
|
|
||||||
|
if (fifo_current.samples_left = FIFO_FSM_RESET_VALUE.samples_left) then
|
||||||
|
fifo_future.samples_left <= NUM_STREAMS - fifo_current.enabled_channels;
|
||||||
|
fifo_future.ch_shift <= 0;
|
||||||
|
end if;
|
||||||
|
|
||||||
if( packet_en = '1' ) then
|
if( packet_en = '1' ) then
|
||||||
fifo_future.state <= READ_PACKET;
|
fifo_future.state <= READ_PACKET;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ library ieee;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.fifo_readwrite_p.all;
|
use work.fifo_readwrite_p.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fifo_writer is
|
entity fifo_writer is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -70,8 +71,8 @@ end entity;
|
||||||
|
|
||||||
architecture simple of fifo_writer is
|
architecture simple of fifo_writer is
|
||||||
|
|
||||||
constant DMA_BUF_SIZE_SS : natural := 512;
|
constant DMA_BUF_SIZE_SS : natural := GPIF_BUF_SIZE_SS;
|
||||||
constant DMA_BUF_SIZE_HS : natural := 256;
|
constant DMA_BUF_SIZE_HS : natural := GPIF_BUF_SIZE_HS;
|
||||||
|
|
||||||
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
|
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
|
||||||
|
|
||||||
|
|
@ -187,7 +188,7 @@ begin
|
||||||
meta_fifo_used_v := unsigned(meta_fifo_full & meta_fifo_usedw);
|
meta_fifo_used_v := unsigned(meta_fifo_full & meta_fifo_usedw);
|
||||||
meta_fifo_used_v_r <= meta_fifo_used_v;
|
meta_fifo_used_v_r <= meta_fifo_used_v;
|
||||||
|
|
||||||
if( fifo_full = '0' and ((FIFO_MAX - fifo_used_v_r) > ( dma_buf_size * 4 )) and
|
if( fifo_full = '0' and ((FIFO_MAX - fifo_used_v_r) > ( dma_buf_size )) and
|
||||||
( ( meta_en = '1' and meta_fifo_full = '0' and ( META_MAX - 4 ) > meta_fifo_used_v_r )
|
( ( meta_en = '1' and meta_fifo_full = '0' and ( META_MAX - 4 ) > meta_fifo_used_v_r )
|
||||||
or (meta_en = '0') ) ) then
|
or (meta_en = '0') ) ) then
|
||||||
fifo_enough <= true;
|
fifo_enough <= true;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip pll_r
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
|
||||||
|
|
||||||
# Implementation Details
|
# Implementation Details
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx-adsb.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx-adsb.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sy
|
||||||
set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip tone_generator/tone_generator.qip]]
|
set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip tone_generator/tone_generator.qip]]
|
||||||
|
|
||||||
# Implementation Details
|
# Implementation Details
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip pll_r
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
|
||||||
|
|
||||||
# Implementation Details
|
# Implementation Details
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synth
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip rfic_spi_controller/vhdl/rfic_spi_controller.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip rfic_spi_controller/vhdl/rfic_spi_controller.vhd]]
|
||||||
|
|
||||||
# Implementation Details
|
# Implementation Details
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,10 @@ set_false_path -from exp_present -to *
|
||||||
set_false_path -from pwr_status -to *
|
set_false_path -from pwr_status -to *
|
||||||
|
|
||||||
# JTAG settings
|
# JTAG settings
|
||||||
create_clock -name {altera_reserved_tck} -period 100 [get_ports {altera_reserved_tck}]
|
set_clock_groups -exclusive -group [get_clocks altera_reserved_tck]
|
||||||
set_clock_groups -asynchronous -group {altera_reserved_tck}
|
set_input_delay -clock [get_clocks altera_reserved_tck] 2.0 [get_ports altera_reserved_tdi]
|
||||||
set_false_path -from [get_ports {altera_reserved_tms}]
|
set_input_delay -clock [get_clocks altera_reserved_tck] 2.0 [get_ports altera_reserved_tms]
|
||||||
set_false_path -from [get_ports {altera_reserved_tdi}]
|
set_output_delay -clock [get_clocks altera_reserved_tck] 2.0 [get_ports altera_reserved_tdo]
|
||||||
set_false_path -to [get_ports {altera_reserved_tdo}]
|
|
||||||
|
|
||||||
# Exceptions
|
# Exceptions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ compile_nuand ../../../ip/nuand bladerf-micro
|
||||||
|
|
||||||
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
|
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
|
||||||
|
|
||||||
|
vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd
|
||||||
vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif.vhd
|
vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif.vhd
|
||||||
|
|
||||||
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd
|
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
source ../../../ip/nuand/nuand.do
|
||||||
|
|
||||||
|
vcom -work nuand -2008 ../vhdl/rx.vhd
|
||||||
|
vcom -work nuand -2008 ../vhdl/tx.vhd
|
||||||
|
|
||||||
|
vlib rtl_work
|
||||||
|
vcom -work rtl_work -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
|
||||||
|
|
||||||
|
compile_nuand ../../../ip/nuand bladerf-micro
|
||||||
|
|
||||||
|
vcom -work nuand -2008 ../vhdl/tb/fx3_model_fifo_stress.vhd
|
||||||
|
vcom -work nuand -2008 ../vhdl/tb/fx3_gpif_iq_8bit_fifo_stress_tb.vhd
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#define FPGA_VERSION_ID 0x7777
|
#define FPGA_VERSION_ID 0x7777
|
||||||
#define FPGA_VERSION_MAJOR 0
|
#define FPGA_VERSION_MAJOR 0
|
||||||
#define FPGA_VERSION_MINOR 15
|
#define FPGA_VERSION_MINOR 16
|
||||||
#define FPGA_VERSION_PATCH 3
|
#define FPGA_VERSION_PATCH 0
|
||||||
#define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \
|
#define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \
|
||||||
(FPGA_VERSION_MINOR << 8) | \
|
(FPGA_VERSION_MINOR << 8) | \
|
||||||
(FPGA_VERSION_PATCH << 16) ) )
|
(FPGA_VERSION_PATCH << 16) ) )
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,11 @@ package bladerf_p is
|
||||||
|
|
||||||
constant TX_FIFO_WWIDTH : natural := 32; -- write side data width
|
constant TX_FIFO_WWIDTH : natural := 32; -- write side data width
|
||||||
constant TX_FIFO_RWIDTH : natural := 64; -- read side data width
|
constant TX_FIFO_RWIDTH : natural := 64; -- read side data width
|
||||||
constant TX_FIFO_LENGTH : natural := 16384; -- samples
|
constant TX_FIFO_LENGTH : natural := 8192; -- samples
|
||||||
|
|
||||||
constant RX_FIFO_WWIDTH : natural := 64; -- write side data width
|
constant RX_FIFO_WWIDTH : natural := 64; -- write side data width
|
||||||
constant RX_FIFO_RWIDTH : natural := 32; -- read side data width
|
constant RX_FIFO_RWIDTH : natural := 32; -- read side data width
|
||||||
constant RX_FIFO_LENGTH : natural := 4096; -- samples
|
constant RX_FIFO_LENGTH : natural := 8192; -- samples
|
||||||
|
|
||||||
constant ADSB_FIFO_WWIDTH : natural := 128; -- write side data width
|
constant ADSB_FIFO_WWIDTH : natural := 128; -- write side data width
|
||||||
constant ADSB_FIFO_RWIDTH : natural := 32; -- read side data width
|
constant ADSB_FIFO_RWIDTH : natural := 32; -- read side data width
|
||||||
|
|
@ -184,11 +184,11 @@ package bladerf_p is
|
||||||
|
|
||||||
constant META_FIFO_TX_WWIDTH : natural := 32; -- write side data width
|
constant META_FIFO_TX_WWIDTH : natural := 32; -- write side data width
|
||||||
constant META_FIFO_TX_RWIDTH : natural := 128; -- read side data width
|
constant META_FIFO_TX_RWIDTH : natural := 128; -- read side data width
|
||||||
constant META_FIFO_TX_LENGTH : natural := 512; -- 32-bit words
|
constant META_FIFO_TX_LENGTH : natural := 2048; -- 32-bit words
|
||||||
|
|
||||||
constant META_FIFO_RX_WWIDTH : natural := 128; -- write side data width
|
constant META_FIFO_RX_WWIDTH : natural := 128; -- write side data width
|
||||||
constant META_FIFO_RX_RWIDTH : natural := 32; -- read side data width
|
constant META_FIFO_RX_RWIDTH : natural := 32; -- read side data width
|
||||||
constant META_FIFO_RX_LENGTH : natural := 512; -- 32-bit words
|
constant META_FIFO_RX_LENGTH : natural := 2048; -- 32-bit words
|
||||||
|
|
||||||
type tx_fifo_t is record
|
type tx_fifo_t is record
|
||||||
aclr : std_logic;
|
aclr : std_logic;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,840 @@
|
||||||
|
-- Copyright (c) 2024 Nuand LLC
|
||||||
|
--
|
||||||
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
-- of this software and associated documentation files (the "Software"), to deal
|
||||||
|
-- in the Software without restriction, including without limitation the rights
|
||||||
|
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
-- copies of the Software, and to permit persons to whom the Software is
|
||||||
|
-- furnished to do so, subject to the following conditions:
|
||||||
|
--
|
||||||
|
-- The above copyright notice and this permission notice shall be included in
|
||||||
|
-- all copies or substantial portions of the Software.
|
||||||
|
--
|
||||||
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
-- THE SOFTWARE.
|
||||||
|
|
||||||
|
library ieee;
|
||||||
|
use ieee.std_logic_1164.all;
|
||||||
|
use ieee.numeric_std.all;
|
||||||
|
|
||||||
|
library rtl_work;
|
||||||
|
|
||||||
|
library altera_lnsim;
|
||||||
|
use altera_lnsim.altera_pll;
|
||||||
|
|
||||||
|
library nuand;
|
||||||
|
use nuand.util.all ;
|
||||||
|
use nuand.fifo_readwrite_p.all;
|
||||||
|
use nuand.common_dcfifo_p.all;
|
||||||
|
use nuand.bladerf_p.all;
|
||||||
|
|
||||||
|
entity fx3_gpif_iq_8bit_fifo_stress is
|
||||||
|
generic (
|
||||||
|
-- For bladeRF2 (2x2 MIMO):
|
||||||
|
NUM_MIMO_STREAMS : natural := 2;
|
||||||
|
FIFO_READER_READ_THROTTLE : natural := 0;
|
||||||
|
|
||||||
|
ENABLE_CHANNEL_0 : std_logic := '1';
|
||||||
|
ENABLE_CHANNEL_1 : std_logic := '0';
|
||||||
|
EIGHT_BIT_MODE_EN : std_logic := '1'
|
||||||
|
);
|
||||||
|
end entity;
|
||||||
|
|
||||||
|
architecture arch of fx3_gpif_iq_8bit_fifo_stress is
|
||||||
|
|
||||||
|
-- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
|
||||||
|
constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
|
||||||
|
|
||||||
|
-- For reasons unknown, simulation of this system in ModelSim requires that
|
||||||
|
-- wrreq and data be asserted shortly before the rising clock edge. Sigh...
|
||||||
|
constant FIFO_WORKAROUND : time := 1 ps;
|
||||||
|
|
||||||
|
type fx3_control_t is record
|
||||||
|
usb_speed : std_logic;
|
||||||
|
tx_enable : std_logic;
|
||||||
|
rx_enable : std_logic;
|
||||||
|
meta_enable : std_logic;
|
||||||
|
packet : std_logic;
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type fx3_gpif_t is record
|
||||||
|
gpif_in : std_logic_vector(31 downto 0);
|
||||||
|
gpif_out : std_logic_vector(31 downto 0);
|
||||||
|
gpif_oe : std_logic;
|
||||||
|
ctl_in : std_logic_vector(12 downto 0);
|
||||||
|
ctl_out : std_logic_vector(12 downto 0);
|
||||||
|
ctl_oe : std_logic_vector(12 downto 0);
|
||||||
|
end record;
|
||||||
|
|
||||||
|
signal sys_rst : std_logic := '1';
|
||||||
|
signal done : boolean := false;
|
||||||
|
|
||||||
|
signal fx3_pclk : std_logic := '1';
|
||||||
|
signal fx3_pclk_pll : std_logic := '1';
|
||||||
|
signal sys_clk : std_logic := '1';
|
||||||
|
|
||||||
|
signal pll_reset : std_logic := '0';
|
||||||
|
signal pll_locked : std_logic := '0';
|
||||||
|
signal fx3_control : fx3_control_t;
|
||||||
|
signal fx3_gpif : fx3_gpif_t;
|
||||||
|
signal fx3_gpif_i : std_logic_vector(31 downto 0);
|
||||||
|
signal fx3_ctl_i : std_logic_vector(12 downto 0);
|
||||||
|
|
||||||
|
-- Control mapping
|
||||||
|
alias dma0_rx_ack is fx3_ctl_i( 0);
|
||||||
|
alias dma1_rx_ack is fx3_ctl_i( 1);
|
||||||
|
alias dma2_tx_ack is fx3_ctl_i( 2);
|
||||||
|
alias dma3_tx_ack is fx3_ctl_i( 3);
|
||||||
|
alias dma_rx_enable is fx3_ctl_i( 4);
|
||||||
|
alias dma_tx_enable is fx3_ctl_i( 5);
|
||||||
|
alias dma_idle is fx3_ctl_i( 6);
|
||||||
|
alias system_reset is fx3_ctl_i( 7);
|
||||||
|
alias dma0_rx_reqx is fx3_ctl_i( 8);
|
||||||
|
alias dma1_rx_reqx is fx3_ctl_i(12); -- due to 9 being connected to dclk
|
||||||
|
alias dma2_tx_reqx is fx3_ctl_i(10);
|
||||||
|
alias dma3_tx_reqx is fx3_ctl_i(11);
|
||||||
|
|
||||||
|
signal loopback_i : signed(15 downto 0) := (others =>'0');
|
||||||
|
signal loopback_q : signed(15 downto 0) := (others =>'0');
|
||||||
|
signal loopback_valid : std_logic := '0';
|
||||||
|
signal loopback_enabled : std_logic := '0';
|
||||||
|
|
||||||
|
signal tx_clock : std_logic := '1' ;
|
||||||
|
signal rx_clock : std_logic := '1' ;
|
||||||
|
|
||||||
|
signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
|
||||||
|
signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
|
||||||
|
signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
|
||||||
|
signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
|
||||||
|
signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
|
||||||
|
|
||||||
|
signal rx_mux_i : signed(15 downto 0);
|
||||||
|
signal rx_mux_q : signed(15 downto 0);
|
||||||
|
signal rx_mux_valid : std_logic;
|
||||||
|
|
||||||
|
signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
|
||||||
|
signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
|
||||||
|
|
||||||
|
constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
|
||||||
|
constant TX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
|
||||||
|
constant RX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
|
||||||
|
|
||||||
|
signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
|
||||||
|
signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
|
||||||
|
signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
|
||||||
|
signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
|
||||||
|
|
||||||
|
signal tx_reset : std_logic := '0';
|
||||||
|
signal tx_ts_reset : std_logic := '0';
|
||||||
|
signal rx_reset : std_logic := '0';
|
||||||
|
signal rx_ts_reset : std_logic := '0';
|
||||||
|
|
||||||
|
signal meta_en_tx : std_logic := '0';
|
||||||
|
signal meta_en_rx : std_logic := '0';
|
||||||
|
|
||||||
|
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
|
||||||
|
signal tx_packet_control : packet_control_t;
|
||||||
|
|
||||||
|
signal trigger_signal_sync_tb : std_logic;
|
||||||
|
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
|
||||||
|
|
||||||
|
function data_gen (count : natural) return std_logic_vector is
|
||||||
|
variable msw, lsw : std_logic_vector(15 downto 0);
|
||||||
|
begin
|
||||||
|
msw := std_logic_vector(to_signed(count, 16));
|
||||||
|
lsw := std_logic_vector(to_signed(-count, 16));
|
||||||
|
|
||||||
|
return (msw & lsw);
|
||||||
|
end function data_gen;
|
||||||
|
|
||||||
|
signal rx_packet_ready : std_logic;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- Brief summary of data flow
|
||||||
|
-- ========================================================================
|
||||||
|
--
|
||||||
|
-- Simulated samples flow from fx3_model's TX side to its RX side. The
|
||||||
|
-- validity of the data is checked there.
|
||||||
|
--
|
||||||
|
-- entity U_fx3_model FX3 model, TX process
|
||||||
|
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
|
||||||
|
-- process register_gpif
|
||||||
|
-- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
|
||||||
|
-- entity U_fx3_gpif GPIF implementation, write side
|
||||||
|
-- signal tx_sample_fifo.w* TX fifo, write side
|
||||||
|
-- entity U_tx_sample_fifo
|
||||||
|
-- signal tx_sample_fifo.r* TX fifo, read side
|
||||||
|
-- process tx_mux
|
||||||
|
-- signal loopback_fifo.w* Loopback fifo, write side
|
||||||
|
-- entity U_rx_loopback_fifo
|
||||||
|
-- signal loopback_fifo.r* Loopback fifo, read side
|
||||||
|
-- process loopback_fifo_control
|
||||||
|
-- signal loopback_{i,q,valid}
|
||||||
|
-- process rx_mux
|
||||||
|
-- signal rx_mux_{i,q,valid}
|
||||||
|
-- entity U_fifo_writer
|
||||||
|
-- signal rx_sample_fifo.w* RX fifo, write side
|
||||||
|
-- entity U_rx_sample_fifo
|
||||||
|
-- signal rx_sample_fifo.r* RX fifo, read side
|
||||||
|
-- entity U_fx3_gpif GPIF implementation, read side
|
||||||
|
-- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
|
||||||
|
-- process register_gpif
|
||||||
|
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
|
||||||
|
-- entity U_fx3_model FX3 model, RX process
|
||||||
|
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- Instantiations
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
-- Unit under test
|
||||||
|
-- Clock domain: fx3_pclk_pll
|
||||||
|
U_fx3_gpif : entity nuand.fx3_gpif
|
||||||
|
port map (
|
||||||
|
pclk => fx3_pclk_pll,
|
||||||
|
reset => sys_rst,
|
||||||
|
usb_speed => fx3_control.usb_speed,
|
||||||
|
gpif_in => fx3_gpif.gpif_in,
|
||||||
|
gpif_out => fx3_gpif.gpif_out,
|
||||||
|
gpif_oe => fx3_gpif.gpif_oe,
|
||||||
|
ctl_in => fx3_gpif.ctl_in,
|
||||||
|
ctl_out => fx3_gpif.ctl_out,
|
||||||
|
ctl_oe => fx3_gpif.ctl_oe,
|
||||||
|
tx_enable => fx3_control.tx_enable,
|
||||||
|
rx_enable => fx3_control.rx_enable,
|
||||||
|
meta_enable => fx3_control.meta_enable,
|
||||||
|
packet_enable => fx3_control.packet,
|
||||||
|
tx_fifo_write => tx_sample_fifo.wreq,
|
||||||
|
tx_fifo_full => tx_sample_fifo.wfull,
|
||||||
|
tx_fifo_empty => tx_sample_fifo.wempty,
|
||||||
|
tx_fifo_usedw => tx_sample_fifo.wused,
|
||||||
|
tx_fifo_data => tx_sample_fifo.wdata,
|
||||||
|
tx_timestamp => tx_timestamp,
|
||||||
|
tx_meta_fifo_write => tx_meta_fifo.wreq,
|
||||||
|
tx_meta_fifo_full => tx_meta_fifo.wfull,
|
||||||
|
tx_meta_fifo_empty => tx_meta_fifo.wempty,
|
||||||
|
tx_meta_fifo_usedw => tx_meta_fifo.wused,
|
||||||
|
tx_meta_fifo_data => tx_meta_fifo.wdata,
|
||||||
|
rx_fifo_read => rx_sample_fifo.rreq,
|
||||||
|
rx_fifo_full => rx_sample_fifo.rfull,
|
||||||
|
rx_fifo_empty => rx_sample_fifo.rempty,
|
||||||
|
rx_fifo_usedw => rx_sample_fifo.rused,
|
||||||
|
rx_fifo_data => rx_sample_fifo.rdata,
|
||||||
|
rx_meta_fifo_read => rx_meta_fifo.rreq,
|
||||||
|
rx_meta_fifo_full => rx_meta_fifo.rfull,
|
||||||
|
rx_meta_fifo_empty => rx_meta_fifo.rempty,
|
||||||
|
rx_meta_fifo_usedr => rx_meta_fifo.rused,
|
||||||
|
rx_meta_fifo_data => rx_meta_fifo.rdata
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Discrete control signals for fx3_gpif
|
||||||
|
fx3_control.usb_speed <= '0';
|
||||||
|
fx3_control.meta_enable <= '0';
|
||||||
|
fx3_control.packet <= '0';
|
||||||
|
|
||||||
|
U_pkt_gen : entity nuand.rx_packet_generator
|
||||||
|
port map(
|
||||||
|
rx_clock => rx_clock,
|
||||||
|
rx_reset => rx_reset,
|
||||||
|
|
||||||
|
rx_enable => fx3_control.rx_enable,
|
||||||
|
rx_packet_enable => fx3_control.packet,
|
||||||
|
|
||||||
|
rx_packet_ready => rx_packet_ready,
|
||||||
|
|
||||||
|
rx_packet_control => rx_packet_control
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
meta_en_tx <= fx3_control.meta_enable;
|
||||||
|
meta_en_rx <= fx3_control.meta_enable;
|
||||||
|
|
||||||
|
increment_tx_ts : process(tx_clock)
|
||||||
|
variable ping : boolean := true ;
|
||||||
|
begin
|
||||||
|
if( rising_edge(tx_clock) ) then
|
||||||
|
ping := not ping ;
|
||||||
|
if( ping = true ) then
|
||||||
|
tx_timestamp <= tx_timestamp + 1 ;
|
||||||
|
end if ;
|
||||||
|
end if ;
|
||||||
|
end process ;
|
||||||
|
|
||||||
|
increment_rx_ts : process(rx_clock)
|
||||||
|
variable ping : boolean := true ;
|
||||||
|
begin
|
||||||
|
if( rising_edge(rx_clock) ) then
|
||||||
|
ping := not ping ;
|
||||||
|
if( ping = true ) then
|
||||||
|
rx_timestamp <= rx_timestamp + 1 ;
|
||||||
|
end if ;
|
||||||
|
end if ;
|
||||||
|
end process ;
|
||||||
|
|
||||||
|
-- Model of FX3's GPIF interface
|
||||||
|
-- Clock domain: fx3_pclk (source)
|
||||||
|
U_fx3_model : entity nuand.fx3_model(micro_dma_fifo_stress)
|
||||||
|
port map (
|
||||||
|
fx3_pclk => fx3_pclk,
|
||||||
|
fx3_gpif => fx3_gpif_i,
|
||||||
|
fx3_ctl => fx3_ctl_i,
|
||||||
|
fx3_uart_rxd => '0',
|
||||||
|
fx3_uart_txd => open,
|
||||||
|
fx3_uart_cts => open,
|
||||||
|
fx3_rx_en => '1',
|
||||||
|
fx3_rx_meta_en => meta_en_rx,
|
||||||
|
fx3_tx_en => '1',
|
||||||
|
fx3_tx_meta_en => meta_en_tx,
|
||||||
|
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
|
||||||
|
done => done
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Generate phase-shifted PLL clock
|
||||||
|
U_fx3_pll : entity rtl_work.fx3_pll
|
||||||
|
port map (
|
||||||
|
inclk0 => fx3_pclk,
|
||||||
|
areset => pll_reset,
|
||||||
|
c0 => fx3_pclk_pll,
|
||||||
|
locked => pll_locked
|
||||||
|
);
|
||||||
|
|
||||||
|
tx_clock <= not tx_clock after TX_HALF_PERIOD ;
|
||||||
|
rx_clock <= not rx_clock after RX_HALF_PERIOD ;
|
||||||
|
|
||||||
|
|
||||||
|
-- Reset handler
|
||||||
|
sys_rst <= '0' after 100 ns;
|
||||||
|
|
||||||
|
-- Generate system clock
|
||||||
|
sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
|
||||||
|
|
||||||
|
|
||||||
|
tx_reset <= sys_rst;
|
||||||
|
tx_ts_reset <= sys_rst;
|
||||||
|
rx_reset <= sys_rst;
|
||||||
|
rx_ts_reset <= sys_rst;
|
||||||
|
|
||||||
|
meta_en_tx <= fx3_control.meta_enable;
|
||||||
|
meta_en_rx <= fx3_control.meta_enable;
|
||||||
|
|
||||||
|
-- TX Submodule
|
||||||
|
U_tx : entity work.tx
|
||||||
|
generic map (
|
||||||
|
NUM_STREAMS => dac_controls'length
|
||||||
|
)
|
||||||
|
port map (
|
||||||
|
tx_reset => tx_reset,
|
||||||
|
tx_clock => tx_clock,
|
||||||
|
tx_enable => fx3_control.tx_enable,
|
||||||
|
|
||||||
|
meta_en => meta_en_tx,
|
||||||
|
timestamp_reset => tx_ts_reset,
|
||||||
|
usb_speed => fx3_control.usb_speed,
|
||||||
|
tx_underflow_led => open,
|
||||||
|
tx_timestamp => tx_timestamp,
|
||||||
|
|
||||||
|
-- Triggering
|
||||||
|
trigger_arm => '0',
|
||||||
|
trigger_fire => '0',
|
||||||
|
trigger_master => '0',
|
||||||
|
trigger_line => open,
|
||||||
|
|
||||||
|
-- Packet FIFO
|
||||||
|
packet_en => fx3_control.packet,
|
||||||
|
packet_empty => open,
|
||||||
|
packet_control => tx_packet_control,
|
||||||
|
packet_ready => '1',
|
||||||
|
|
||||||
|
-- 8-bit mode
|
||||||
|
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
|
||||||
|
|
||||||
|
-- Samples from host via FX3
|
||||||
|
sample_fifo_wclock => fx3_pclk_pll,
|
||||||
|
sample_fifo_wreq => tx_sample_fifo.wreq,
|
||||||
|
sample_fifo_wdata => tx_sample_fifo.wdata,
|
||||||
|
sample_fifo_wempty => tx_sample_fifo.wempty,
|
||||||
|
sample_fifo_wfull => tx_sample_fifo.wfull,
|
||||||
|
sample_fifo_wused => tx_sample_fifo.wused,
|
||||||
|
|
||||||
|
-- Metadata from host via FX3
|
||||||
|
meta_fifo_wclock => fx3_pclk_pll,
|
||||||
|
meta_fifo_wreq => tx_meta_fifo.wreq,
|
||||||
|
meta_fifo_wdata => tx_meta_fifo.wdata,
|
||||||
|
meta_fifo_wempty => tx_meta_fifo.wempty,
|
||||||
|
meta_fifo_wfull => tx_meta_fifo.wfull,
|
||||||
|
meta_fifo_wused => tx_meta_fifo.wused,
|
||||||
|
|
||||||
|
-- Digital Loopback Interface
|
||||||
|
loopback_enabled => '0',
|
||||||
|
loopback_fifo_wdata => loopback_fifo.wdata,
|
||||||
|
loopback_fifo_wreq => loopback_fifo.wreq,
|
||||||
|
loopback_fifo_wfull => loopback_fifo.wfull,
|
||||||
|
loopback_fifo_wused => loopback_fifo.wused,
|
||||||
|
|
||||||
|
-- RFFE Interface
|
||||||
|
dac_controls => dac_controls,
|
||||||
|
dac_streams => dac_streams
|
||||||
|
);
|
||||||
|
|
||||||
|
-- RX Submodule
|
||||||
|
U_rx : entity work.rx
|
||||||
|
generic map (
|
||||||
|
NUM_STREAMS => adc_controls'length
|
||||||
|
)
|
||||||
|
port map (
|
||||||
|
rx_reset => rx_reset,
|
||||||
|
rx_clock => rx_clock,
|
||||||
|
rx_enable => fx3_control.rx_enable,
|
||||||
|
|
||||||
|
meta_en => meta_en_rx,
|
||||||
|
timestamp_reset => rx_ts_reset,
|
||||||
|
usb_speed => fx3_control.usb_speed,
|
||||||
|
rx_mux_sel => to_unsigned(0, 3),
|
||||||
|
rx_overflow_led => open,
|
||||||
|
rx_timestamp => rx_timestamp,
|
||||||
|
|
||||||
|
-- Triggering
|
||||||
|
trigger_arm => '0',
|
||||||
|
trigger_fire => '0',
|
||||||
|
trigger_master => '0',
|
||||||
|
trigger_line => open,
|
||||||
|
trigger_signal_sync_tb => trigger_signal_sync_tb,
|
||||||
|
|
||||||
|
-- Packet FIFO
|
||||||
|
packet_en => fx3_control.packet,
|
||||||
|
packet_control => rx_packet_control,
|
||||||
|
packet_ready => rx_packet_ready,
|
||||||
|
|
||||||
|
-- 8-bit mode
|
||||||
|
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
|
||||||
|
|
||||||
|
-- Samples to host via FX3
|
||||||
|
sample_fifo_rclock => fx3_pclk_pll,
|
||||||
|
sample_fifo_raclr => not fx3_control.rx_enable,
|
||||||
|
sample_fifo_rreq => rx_sample_fifo.rreq,
|
||||||
|
sample_fifo_rdata => rx_sample_fifo.rdata,
|
||||||
|
sample_fifo_rempty => rx_sample_fifo.rempty,
|
||||||
|
sample_fifo_rfull => rx_sample_fifo.rfull,
|
||||||
|
sample_fifo_rused => rx_sample_fifo.rused,
|
||||||
|
|
||||||
|
-- Mini expansion signals
|
||||||
|
mini_exp => "00",
|
||||||
|
|
||||||
|
-- Metadata to host via FX3
|
||||||
|
meta_fifo_rclock => fx3_pclk_pll,
|
||||||
|
meta_fifo_raclr => not fx3_control.rx_enable,
|
||||||
|
meta_fifo_rreq => rx_meta_fifo.rreq,
|
||||||
|
meta_fifo_rdata => rx_meta_fifo.rdata,
|
||||||
|
meta_fifo_rempty => rx_meta_fifo.rempty,
|
||||||
|
meta_fifo_rfull => rx_meta_fifo.rfull,
|
||||||
|
meta_fifo_rused => rx_meta_fifo.rused,
|
||||||
|
|
||||||
|
-- Digital Loopback Interface
|
||||||
|
loopback_fifo_wenabled => open,
|
||||||
|
loopback_fifo_wreset => tx_reset,
|
||||||
|
loopback_fifo_wclock => tx_clock,
|
||||||
|
loopback_fifo_wdata => loopback_fifo.wdata,
|
||||||
|
loopback_fifo_wreq => loopback_fifo.wreq,
|
||||||
|
loopback_fifo_wfull => loopback_fifo.wfull,
|
||||||
|
loopback_fifo_wused => loopback_fifo.wused,
|
||||||
|
|
||||||
|
-- RFFE Interface
|
||||||
|
adc_controls => adc_controls,
|
||||||
|
adc_streams => adc_streams
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- Data converters
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
|
||||||
|
-- The TX side of the AD9361 HDL is a FIFO pull interface
|
||||||
|
-- that expects a readahead FIFO. It toggles the data request
|
||||||
|
-- signal every other cycle. This behavior is mimicked here.
|
||||||
|
process( tx_clock, sys_rst )
|
||||||
|
begin
|
||||||
|
if( sys_rst = '1' ) then
|
||||||
|
dac_controls <= (
|
||||||
|
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
|
||||||
|
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
|
||||||
|
);
|
||||||
|
elsif( rising_edge(tx_clock) ) then
|
||||||
|
for i in dac_controls'range loop
|
||||||
|
dac_controls(i) <= (
|
||||||
|
enable => dac_controls(i).enable,
|
||||||
|
data_req => not dac_controls(i).data_req );
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
else generate
|
||||||
|
dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
|
||||||
|
end generate;
|
||||||
|
|
||||||
|
gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
|
||||||
|
process( rx_clock, sys_rst )
|
||||||
|
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
||||||
|
constant COUNT_RESET : integer := 0;
|
||||||
|
variable count : integer range -2047 to 2047 := COUNT_RESET;
|
||||||
|
begin
|
||||||
|
if( sys_rst = '1' ) then
|
||||||
|
count := COUNT_RESET;
|
||||||
|
adc_controls <= (
|
||||||
|
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
|
||||||
|
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
|
||||||
|
);
|
||||||
|
elsif( rising_edge(rx_clock) ) then
|
||||||
|
for i in adc_controls'range loop
|
||||||
|
adc_controls(i) <= (
|
||||||
|
enable => adc_controls(i).enable,
|
||||||
|
data_req => not adc_controls(i).data_req );
|
||||||
|
if( adc_controls(i).enable = '1') then
|
||||||
|
if( adc_streams(i).data_v = '1' ) then
|
||||||
|
if( EIGHT_BIT_MODE_EN = '1' ) then
|
||||||
|
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
|
||||||
|
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
|
||||||
|
count := (count + 1) mod 128;
|
||||||
|
else
|
||||||
|
adc_streams(i).data_i <= to_signed(count, 16);
|
||||||
|
adc_streams(i).data_q <= to_signed(-count, 16);
|
||||||
|
count := (count + 1) mod 2048;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
adc_streams(i).data_v <= not adc_streams(i).data_v;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
else generate
|
||||||
|
adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
|
||||||
|
end generate;
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- Processes
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
-- FX3 GPIF bidirectional signal control
|
||||||
|
-- Adapted from same process in bladerf-hosted.vhd
|
||||||
|
register_gpif : process(sys_rst, fx3_pclk_pll)
|
||||||
|
begin
|
||||||
|
if( sys_rst = '1' ) then
|
||||||
|
fx3_gpif_i <= (others => 'Z');
|
||||||
|
fx3_gpif.gpif_in <= (others => 'Z');
|
||||||
|
elsif( rising_edge(fx3_pclk_pll) ) then
|
||||||
|
fx3_gpif.gpif_in <= fx3_gpif_i;
|
||||||
|
|
||||||
|
if( fx3_gpif.gpif_oe = '1' ) then
|
||||||
|
fx3_gpif_i <= fx3_gpif.gpif_out;
|
||||||
|
else
|
||||||
|
fx3_gpif_i <= (others =>'Z');
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
-- FX3 CTL bidirectional signals
|
||||||
|
-- Adapted from same generator in bladerf-hosted.vhd
|
||||||
|
generate_ctl : for i in fx3_ctl_i'range generate
|
||||||
|
fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
|
||||||
|
end generate;
|
||||||
|
|
||||||
|
fx3_gpif.ctl_in <= fx3_ctl_i;
|
||||||
|
|
||||||
|
-- Controller for loopback FIFO
|
||||||
|
-- Stripped-down version of same process from rx.vhd
|
||||||
|
loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
|
||||||
|
begin
|
||||||
|
if( sys_rst = '1' ) then
|
||||||
|
loopback_enabled <= '0';
|
||||||
|
loopback_fifo.rreq <= '0';
|
||||||
|
loopback_i <= (others => '0');
|
||||||
|
loopback_q <= (others => '0');
|
||||||
|
loopback_valid <= '0';
|
||||||
|
elsif( rising_edge(loopback_fifo.rclock) ) then
|
||||||
|
loopback_enabled <= '0';
|
||||||
|
loopback_fifo.rreq <= '0';
|
||||||
|
loopback_i <= loopback_i;
|
||||||
|
loopback_q <= loopback_q;
|
||||||
|
loopback_valid <= '0';
|
||||||
|
|
||||||
|
-- Is loopback enabled?
|
||||||
|
loopback_enabled <= fx3_control.rx_enable;
|
||||||
|
|
||||||
|
-- Do the loopback
|
||||||
|
loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
|
||||||
|
loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
|
||||||
|
loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
|
||||||
|
|
||||||
|
-- Read from the FIFO if req'd
|
||||||
|
loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
-- RX multiplexer
|
||||||
|
-- Stripped-down version of same process from rx.vhd
|
||||||
|
rx_mux : process(sys_rst, sys_clk)
|
||||||
|
begin
|
||||||
|
if( sys_rst = '1' ) then
|
||||||
|
rx_mux_i <= (others =>'0');
|
||||||
|
rx_mux_q <= (others =>'0');
|
||||||
|
rx_mux_valid <= '0';
|
||||||
|
elsif( rising_edge(sys_clk) ) then
|
||||||
|
rx_mux_i <= loopback_i;
|
||||||
|
rx_mux_q <= loopback_q;
|
||||||
|
rx_mux_valid <= loopback_valid;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
-- TX multiplexer
|
||||||
|
-- Stripped-down version of mimo_channel_sel_mux from tx.vhd
|
||||||
|
--tx_mux : process( sys_clk )
|
||||||
|
--begin
|
||||||
|
-- if( rising_edge(sys_clk) ) then
|
||||||
|
-- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
|
||||||
|
|
||||||
|
-- loopback_fifo.wdata <= tx_sample_fifo.rdata;
|
||||||
|
-- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
|
||||||
|
-- end if;
|
||||||
|
--end process;
|
||||||
|
|
||||||
|
|
||||||
|
-- ========================================================================
|
||||||
|
-- Verification
|
||||||
|
-- ========================================================================
|
||||||
|
print_config: process
|
||||||
|
begin
|
||||||
|
wait until rising_edge(fx3_control.tx_enable);
|
||||||
|
report lf&
|
||||||
|
"[CONFIG] EIGHT_BIT_MODE_EN: " & std_logic'image(EIGHT_BIT_MODE_EN) &lf&
|
||||||
|
"[CONFIG] ENABLE_CHANNEL_0: " & std_logic'image(ENABLE_CHANNEL_0) &lf&
|
||||||
|
"[CONFIG] ENABLE_CHANNEL_1: " & std_logic'image(ENABLE_CHANNEL_1);
|
||||||
|
end process print_config;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Check for metavalues
|
||||||
|
-- We should never see metavalues written to the FIFOs
|
||||||
|
--
|
||||||
|
check_fifo_write : process(fx3_pclk_pll) is
|
||||||
|
begin
|
||||||
|
if( rising_edge(fx3_pclk_pll) ) then
|
||||||
|
if( tx_sample_fifo.wreq = '1' and fx3_control.meta_enable = '0' ) then
|
||||||
|
for i in tx_sample_fifo.wdata'range loop
|
||||||
|
assert tx_sample_fifo.wdata(i) = '0' or tx_sample_fifo.wdata(i) = '1'
|
||||||
|
severity failure;
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
check_fifo_read : process(fx3_pclk_pll) is
|
||||||
|
begin
|
||||||
|
if( rising_edge(fx3_pclk_pll) ) then
|
||||||
|
if( rx_sample_fifo.rreq = '1' ) then
|
||||||
|
for i in rx_sample_fifo.rdata'range loop
|
||||||
|
assert rx_sample_fifo.rdata(i) = '0' or rx_sample_fifo.rdata(i) = '1'
|
||||||
|
severity failure;
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end process check_fifo_read;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Check for fullness on FIFOs
|
||||||
|
--
|
||||||
|
assert(rx_sample_fifo.wfull = '0') report "rx_sample_fifo full (write)" severity warning;
|
||||||
|
assert(tx_sample_fifo.wfull = '0') report "tx_sample_fifo full (write)" severity warning;
|
||||||
|
assert(loopback_fifo.wfull = '0') report "loopback_fifo full (write)" severity warning;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tx Sample Check
|
||||||
|
--
|
||||||
|
look_for_dropped_tx_samples : process(tx_clock) is
|
||||||
|
constant MESSAGES_PER_ITERATION : natural := 7; --Provided in fx3_model
|
||||||
|
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
||||||
|
variable current_message_count : natural := 1;
|
||||||
|
variable iq_value : signed (15 downto 0) := x"0000";
|
||||||
|
variable expected_sample_i : signed (15 downto 0);
|
||||||
|
variable expected_sample_q : signed (15 downto 0);
|
||||||
|
variable failure_count : natural := 0;
|
||||||
|
begin
|
||||||
|
for i in dac_controls'range loop
|
||||||
|
if( rising_edge(tx_clock)
|
||||||
|
and dac_controls(i).enable = '1'
|
||||||
|
and dac_streams(i).data_v = '1'
|
||||||
|
and fx3_control.tx_enable = '1' )
|
||||||
|
then
|
||||||
|
if( EIGHT_BIT_MODE_EN = '1' ) then
|
||||||
|
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
|
||||||
|
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
|
||||||
|
|
||||||
|
assert ( dac_streams(i).data_i = expected_sample_i )
|
||||||
|
report "dac_streams("&to_string(i)&").data_i: " & to_hstring(dac_streams(i).data_i) & " | " &
|
||||||
|
"expected_sample_i: " & to_hstring(expected_sample_i)
|
||||||
|
severity warning;
|
||||||
|
assert ( dac_streams(i).data_q = expected_sample_q )
|
||||||
|
report "dac_streams("&to_string(i)&").data_q: " & to_hstring(dac_streams(i).data_q) & " | " &
|
||||||
|
"expected_sample_q: " & to_hstring(expected_sample_q)
|
||||||
|
severity warning;
|
||||||
|
|
||||||
|
if ( dac_streams(i).data_i /= expected_sample_i or dac_streams(i).data_q /= expected_sample_q ) then
|
||||||
|
failure_count := failure_count + 1;
|
||||||
|
if ( failure_count >= 6 ) then
|
||||||
|
report "tx fail count tolerance exceeded" severity failure;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
iq_value := (iq_value + 2) mod 128;
|
||||||
|
else
|
||||||
|
expected_sample_i := iq_value;
|
||||||
|
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
||||||
|
|
||||||
|
assert(dac_streams(i).data_i = expected_sample_i)
|
||||||
|
report "dac_streams("&to_string(i)&").data_i: " & to_hstring(dac_streams(i).data_i) & " | " &
|
||||||
|
"expected_sample_i: " & to_hstring(expected_sample_i)
|
||||||
|
severity failure;
|
||||||
|
assert(dac_streams(i).data_q = expected_sample_q)
|
||||||
|
report "dac_streams("&to_string(i)&").data_q: " & to_hstring(dac_streams(i).data_q) & " | " &
|
||||||
|
"expected_sample_q: " & to_hstring(expected_sample_q)
|
||||||
|
severity failure;
|
||||||
|
|
||||||
|
-- Set iq values based on blocks received
|
||||||
|
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
||||||
|
if( iq_value = x"03FE" ) then
|
||||||
|
iq_value := x"0000";
|
||||||
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
|
current_message_count := current_message_count + 1;
|
||||||
|
else
|
||||||
|
current_message_count := 1;
|
||||||
|
end if;
|
||||||
|
else
|
||||||
|
iq_value := (iq_value + 2) mod 2048;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
end process look_for_dropped_tx_samples;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Rx Sample Check
|
||||||
|
--
|
||||||
|
first_rx_val_at_mux: process
|
||||||
|
-- Catches and saves the first sample of
|
||||||
|
-- each rx enabled burst seen by the mux
|
||||||
|
begin
|
||||||
|
for i in adc_controls'range loop
|
||||||
|
if( adc_controls(i).enable = '1') then
|
||||||
|
if( ENABLE_CHANNEL_0 = '1' and ENABLE_CHANNEL_1 = '1' ) then
|
||||||
|
adc_stream_val_at_rx_enable <= adc_streams(i).data_i - 1;
|
||||||
|
else
|
||||||
|
adc_stream_val_at_rx_enable <= adc_streams(i).data_i;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
wait until rising_edge(trigger_signal_sync_tb);
|
||||||
|
end process first_rx_val_at_mux;
|
||||||
|
|
||||||
|
look_for_dropped_rx_samples: process(fx3_pclk_pll)
|
||||||
|
variable rx_val : integer := 0;
|
||||||
|
|
||||||
|
variable q_expected : std_logic_vector (15 downto 0);
|
||||||
|
variable i_expected : std_logic_vector (15 downto 0);
|
||||||
|
variable q_out : std_logic_vector (15 downto 0);
|
||||||
|
variable i_out : std_logic_vector (15 downto 0);
|
||||||
|
|
||||||
|
variable q0_expected_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable i0_expected_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable q1_expected_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable i1_expected_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable q0_out_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable i0_out_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable q1_out_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
variable i1_out_eight_bit_mode : std_logic_vector (7 downto 0);
|
||||||
|
|
||||||
|
variable previous_adc_stream_val_at_rx_enable : signed (15 downto 0) := ( others => '0');
|
||||||
|
variable fail_count: natural := 0;
|
||||||
|
variable both_channels_en : std_logic;
|
||||||
|
begin
|
||||||
|
if( previous_adc_stream_val_at_rx_enable /= adc_stream_val_at_rx_enable ) then
|
||||||
|
rx_val := to_integer(adc_stream_val_at_rx_enable (15 downto 4)) when EIGHT_BIT_MODE_EN else
|
||||||
|
to_integer(adc_stream_val_at_rx_enable);
|
||||||
|
previous_adc_stream_val_at_rx_enable := adc_stream_val_at_rx_enable;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if( rising_edge(fx3_pclk_pll)
|
||||||
|
and fx3_gpif.gpif_oe = '1'
|
||||||
|
and fx3_control.rx_enable = '1' ) then
|
||||||
|
if( EIGHT_BIT_MODE_EN = '1') then
|
||||||
|
-- The +-1 ch1 offset in SISO mode will not reach 128
|
||||||
|
both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1;
|
||||||
|
q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else
|
||||||
|
std_logic_vector(to_signed(-((rx_val + 1) mod 128), 8));
|
||||||
|
i1_expected_eight_bit_mode := std_logic_vector(to_signed(rx_val + 1, 8)) when both_channels_en else
|
||||||
|
std_logic_vector(to_signed((rx_val + 1) mod 128, 8));
|
||||||
|
q0_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val, 8));
|
||||||
|
i0_expected_eight_bit_mode := std_logic_vector(to_signed(rx_val, 8));
|
||||||
|
|
||||||
|
q1_out_eight_bit_mode := fx3_gpif.gpif_out(31 downto 24);
|
||||||
|
i1_out_eight_bit_mode := fx3_gpif.gpif_out(23 downto 16);
|
||||||
|
q0_out_eight_bit_mode := fx3_gpif.gpif_out(15 downto 8);
|
||||||
|
i0_out_eight_bit_mode := fx3_gpif.gpif_out(7 downto 0);
|
||||||
|
|
||||||
|
if( q1_out_eight_bit_mode /= q1_expected_eight_bit_mode or
|
||||||
|
i1_out_eight_bit_mode /= i1_expected_eight_bit_mode or
|
||||||
|
q0_out_eight_bit_mode /= q0_expected_eight_bit_mode or
|
||||||
|
i0_out_eight_bit_mode /= i0_expected_eight_bit_mode) then
|
||||||
|
fail_count := fail_count + 1;
|
||||||
|
report "-----------------------------";
|
||||||
|
if( fail_count > 3 ) then
|
||||||
|
report "rx fail count tolerance exceeded" severity failure;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
assert ( q1_out_eight_bit_mode = q1_expected_eight_bit_mode )
|
||||||
|
report "data_q1: " & to_hstring(q1_out_eight_bit_mode) & " | " &
|
||||||
|
"expected: " & to_hstring(q1_expected_eight_bit_mode)
|
||||||
|
severity warning;
|
||||||
|
assert ( i1_out_eight_bit_mode = i1_expected_eight_bit_mode )
|
||||||
|
report "data_i1: " & to_hstring(i1_out_eight_bit_mode) & " | " &
|
||||||
|
"expected: " & to_hstring(i1_expected_eight_bit_mode)
|
||||||
|
severity warning;
|
||||||
|
assert ( q0_out_eight_bit_mode = q0_expected_eight_bit_mode )
|
||||||
|
report "data_q0: " & to_hstring(q0_out_eight_bit_mode) & " | " &
|
||||||
|
"expected: " & to_hstring(q0_expected_eight_bit_mode)
|
||||||
|
severity warning;
|
||||||
|
assert ( i0_out_eight_bit_mode = i0_expected_eight_bit_mode )
|
||||||
|
report "data_i0: " & to_hstring(i0_out_eight_bit_mode) & " | " &
|
||||||
|
"expected: " & to_hstring(i0_expected_eight_bit_mode)
|
||||||
|
severity warning;
|
||||||
|
|
||||||
|
-- 128 limit set by gen_adc_controls above
|
||||||
|
rx_val := (rx_val + 2) mod 128;
|
||||||
|
else
|
||||||
|
q_expected := std_logic_vector(to_signed(-rx_val, 16));
|
||||||
|
i_expected := std_logic_vector(to_signed(rx_val, 16));
|
||||||
|
q_out := fx3_gpif.gpif_out(31 downto 16);
|
||||||
|
i_out := fx3_gpif.gpif_out(15 downto 0);
|
||||||
|
|
||||||
|
assert(q_out = q_expected)
|
||||||
|
report "data_q: " & to_hstring(q_out) & " | " &
|
||||||
|
"expected: " & to_hstring(q_expected)
|
||||||
|
severity failure;
|
||||||
|
assert(i_out = i_expected)
|
||||||
|
report "data_i: " & to_hstring(i_out) & " | " &
|
||||||
|
"expected: " & to_hstring(i_expected)
|
||||||
|
severity failure;
|
||||||
|
|
||||||
|
-- 2047 limit set by gen_adc_controls above
|
||||||
|
rx_val := (rx_val + 1) mod 2048;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end process look_for_dropped_rx_samples;
|
||||||
|
|
||||||
|
end architecture;
|
||||||
|
|
@ -32,6 +32,7 @@ library nuand;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fx3_gpif_iq_8bit_tb is
|
entity fx3_gpif_iq_8bit_tb is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -659,6 +660,7 @@ begin
|
||||||
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
||||||
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
||||||
variable current_message_count : natural := 1;
|
variable current_message_count : natural := 1;
|
||||||
|
variable valid_sample_count : natural := 0;
|
||||||
variable iq_value : signed (15 downto 0) := x"0000";
|
variable iq_value : signed (15 downto 0) := x"0000";
|
||||||
variable expected_sample_i : signed (15 downto 0);
|
variable expected_sample_i : signed (15 downto 0);
|
||||||
variable expected_sample_q : signed (15 downto 0);
|
variable expected_sample_q : signed (15 downto 0);
|
||||||
|
|
@ -670,6 +672,7 @@ begin
|
||||||
and dac_streams(i).data_v = '1'
|
and dac_streams(i).data_v = '1'
|
||||||
and fx3_control.tx_enable = '1' )
|
and fx3_control.tx_enable = '1' )
|
||||||
then
|
then
|
||||||
|
valid_sample_count := valid_sample_count + 1;
|
||||||
if( EIGHT_BIT_MODE_EN = '1' ) then
|
if( EIGHT_BIT_MODE_EN = '1' ) then
|
||||||
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
|
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
|
||||||
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
|
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
|
||||||
|
|
@ -706,7 +709,7 @@ begin
|
||||||
|
|
||||||
-- Set iq values based on blocks received
|
-- Set iq values based on blocks received
|
||||||
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
||||||
if( iq_value = x"03FE" ) then
|
if( valid_sample_count mod GPIF_BUF_SIZE_SS = 0 ) then
|
||||||
iq_value := x"0000";
|
iq_value := x"0000";
|
||||||
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
current_message_count := current_message_count + 1;
|
current_message_count := current_message_count + 1;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ library nuand;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fx3_gpif_iq_tb is
|
entity fx3_gpif_iq_tb is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -638,6 +639,7 @@ begin
|
||||||
look_for_dropped_tx_samples : process(tx_clock) is
|
look_for_dropped_tx_samples : process(tx_clock) is
|
||||||
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
||||||
variable current_message_count : natural := 1;
|
variable current_message_count : natural := 1;
|
||||||
|
variable valid_sample_count : natural := 0;
|
||||||
variable iq_value : signed (15 downto 0) := x"0000";
|
variable iq_value : signed (15 downto 0) := x"0000";
|
||||||
variable expected_sample_q : signed (15 downto 0);
|
variable expected_sample_q : signed (15 downto 0);
|
||||||
variable expected_sample_i : signed (15 downto 0);
|
variable expected_sample_i : signed (15 downto 0);
|
||||||
|
|
@ -648,6 +650,7 @@ begin
|
||||||
and dac_streams(i).data_v = '1'
|
and dac_streams(i).data_v = '1'
|
||||||
and fx3_control.tx_enable = '1' )
|
and fx3_control.tx_enable = '1' )
|
||||||
then
|
then
|
||||||
|
valid_sample_count := valid_sample_count + 1;
|
||||||
expected_sample_i := iq_value;
|
expected_sample_i := iq_value;
|
||||||
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
||||||
|
|
||||||
|
|
@ -662,7 +665,7 @@ begin
|
||||||
|
|
||||||
-- Set iq values based on blocks received
|
-- Set iq values based on blocks received
|
||||||
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
||||||
if( iq_value = x"03FE" ) then
|
if( valid_sample_count mod GPIF_BUF_SIZE_SS = 0 ) then
|
||||||
iq_value := x"0000";
|
iq_value := x"0000";
|
||||||
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
current_message_count := current_message_count + 1;
|
current_message_count := current_message_count + 1;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ library nuand;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fx3_gpif_meta_8bit_tb is
|
entity fx3_gpif_meta_8bit_tb is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -696,7 +697,8 @@ begin
|
||||||
look_for_dropped_tx_samples : process(tx_clock) is
|
look_for_dropped_tx_samples : process(tx_clock) is
|
||||||
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
||||||
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
|
||||||
variable dac_stream_back_to_0 : natural := 0;
|
constant HEADER_LEN : natural := 4; -- In clk cycles
|
||||||
|
variable valid_sample_count : natural := 0;
|
||||||
variable current_message_count : natural := 1;
|
variable current_message_count : natural := 1;
|
||||||
variable iq_value : signed (15 downto 0) := x"0000";
|
variable iq_value : signed (15 downto 0) := x"0000";
|
||||||
variable expected_sample_i : signed (15 downto 0);
|
variable expected_sample_i : signed (15 downto 0);
|
||||||
|
|
@ -709,6 +711,7 @@ begin
|
||||||
and dac_streams(i).data_v = '1'
|
and dac_streams(i).data_v = '1'
|
||||||
and fx3_control.tx_enable = '1' )
|
and fx3_control.tx_enable = '1' )
|
||||||
then
|
then
|
||||||
|
valid_sample_count := valid_sample_count + 1;
|
||||||
if( EIGHT_BIT_MODE_EN = '1' ) then
|
if( EIGHT_BIT_MODE_EN = '1' ) then
|
||||||
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
|
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
|
||||||
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
|
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
|
||||||
|
|
@ -729,9 +732,16 @@ begin
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
dac_stream_back_to_0 := dac_stream_back_to_0 + 1 when iq_value = 0;
|
if( valid_sample_count mod (2*GPIF_BUF_SIZE_SS - 8) = 0 ) then
|
||||||
iq_value := (iq_value + 2) mod 128 when dac_stream_back_to_0 mod 16 /= 0 else
|
iq_value := x"0000";
|
||||||
(iq_value + 2) mod 112;
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
|
current_message_count := current_message_count + 1;
|
||||||
|
else
|
||||||
|
current_message_count := 1;
|
||||||
|
end if;
|
||||||
|
else
|
||||||
|
iq_value := (iq_value + 2) mod 128;
|
||||||
|
end if;
|
||||||
else
|
else
|
||||||
expected_sample_i := iq_value;
|
expected_sample_i := iq_value;
|
||||||
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
||||||
|
|
@ -747,7 +757,7 @@ begin
|
||||||
|
|
||||||
-- Set iq values based on blocks received
|
-- Set iq values based on blocks received
|
||||||
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
||||||
if( iq_value = x"03F6" ) then
|
if( valid_sample_count mod (GPIF_BUF_SIZE_SS - HEADER_LEN) = 0 ) then
|
||||||
iq_value := x"0000";
|
iq_value := x"0000";
|
||||||
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
current_message_count := current_message_count + 1;
|
current_message_count := current_message_count + 1;
|
||||||
|
|
@ -910,11 +920,11 @@ begin
|
||||||
|
|
||||||
-- Allows a 0 increment for the first ts assertion
|
-- Allows a 0 increment for the first ts assertion
|
||||||
if( ENABLE_CHANNEL_0 = '1' and ENABLE_CHANNEL_1 = '1') then
|
if( ENABLE_CHANNEL_0 = '1' and ENABLE_CHANNEL_1 = '1') then
|
||||||
ts_increment := 254 when EIGHT_BIT_MODE_EN = '0'
|
ts_increment := (GPIF_BUF_SIZE_SS-4)/2 when EIGHT_BIT_MODE_EN = '0'
|
||||||
else 508;
|
else (GPIF_BUF_SIZE_SS-4);
|
||||||
else
|
else
|
||||||
ts_increment := 508 when EIGHT_BIT_MODE_EN = '0'
|
ts_increment := (GPIF_BUF_SIZE_SS -4) when EIGHT_BIT_MODE_EN = '0'
|
||||||
else 1016;
|
else 2*(GPIF_BUF_SIZE_SS -4);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
iteration := iteration + 1;
|
iteration := iteration + 1;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ library nuand;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fx3_gpif_meta_tb is
|
entity fx3_gpif_meta_tb is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -683,8 +684,10 @@ begin
|
||||||
end process tx_sample_start_check;
|
end process tx_sample_start_check;
|
||||||
|
|
||||||
look_for_dropped_tx_samples : process(tx_clock) is
|
look_for_dropped_tx_samples : process(tx_clock) is
|
||||||
|
constant HEADER_LEN : integer := 4; -- In clk cycles
|
||||||
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
|
||||||
variable current_message_count : natural := 1;
|
variable current_message_count : natural := 1;
|
||||||
|
variable valid_sample_count : natural := 0;
|
||||||
variable iq_value : signed (15 downto 0) := x"0000";
|
variable iq_value : signed (15 downto 0) := x"0000";
|
||||||
variable expected_sample_q : signed (15 downto 0);
|
variable expected_sample_q : signed (15 downto 0);
|
||||||
variable expected_sample_i : signed (15 downto 0);
|
variable expected_sample_i : signed (15 downto 0);
|
||||||
|
|
@ -695,6 +698,7 @@ begin
|
||||||
and dac_streams(i).data_v = '1'
|
and dac_streams(i).data_v = '1'
|
||||||
and fx3_control.tx_enable = '1' )
|
and fx3_control.tx_enable = '1' )
|
||||||
then
|
then
|
||||||
|
valid_sample_count := valid_sample_count + 1;
|
||||||
expected_sample_i := iq_value;
|
expected_sample_i := iq_value;
|
||||||
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
|
||||||
|
|
||||||
|
|
@ -709,7 +713,7 @@ begin
|
||||||
|
|
||||||
-- Set iq values based on blocks received
|
-- Set iq values based on blocks received
|
||||||
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
|
||||||
if( iq_value = x"03F6" ) then
|
if( valid_sample_count mod (GPIF_BUF_SIZE_SS-HEADER_LEN) = 0 ) then
|
||||||
iq_value := x"0000";
|
iq_value := x"0000";
|
||||||
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
if( current_message_count < MESSAGES_PER_ITERATION ) then
|
||||||
current_message_count := current_message_count + 1;
|
current_message_count := current_message_count + 1;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ library ieee;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.util.all;
|
use work.util.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
architecture micro_dma of fx3_model is
|
architecture micro_dma of fx3_model is
|
||||||
|
|
||||||
|
|
@ -98,7 +99,7 @@ begin
|
||||||
done <= rx_done and tx_done;
|
done <= rx_done and tx_done;
|
||||||
|
|
||||||
rx_sample_stream : process
|
rx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable req_time : time;
|
variable req_time : time;
|
||||||
begin
|
begin
|
||||||
|
|
@ -151,8 +152,8 @@ begin
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
tx_sample_stream : process
|
tx_sample_stream : process
|
||||||
constant TIME_BETWEEN_ITERATIONS : natural := 4593;
|
constant TIME_BETWEEN_ITERATIONS : natural := 7000;
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable timestamp_cntr : natural := 400;
|
variable timestamp_cntr : natural := 400;
|
||||||
variable header_len : natural := 0;
|
variable header_len : natural := 0;
|
||||||
|
|
@ -242,7 +243,7 @@ begin
|
||||||
nop(fx3_pclk, 10);
|
nop(fx3_pclk, 10);
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
wait for 1 ms;
|
wait for 1.5 ms;
|
||||||
dma_tx_enable <= '0';
|
dma_tx_enable <= '0';
|
||||||
wait for 10 us;
|
wait for 10 us;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
@ -333,7 +334,7 @@ begin
|
||||||
done <= rx_done and tx_done;
|
done <= rx_done and tx_done;
|
||||||
|
|
||||||
rx_sample_stream : process
|
rx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable req_time : time;
|
variable req_time : time;
|
||||||
begin
|
begin
|
||||||
|
|
@ -387,7 +388,7 @@ begin
|
||||||
|
|
||||||
tx_sample_stream : process
|
tx_sample_stream : process
|
||||||
constant TIME_BETWEEN_ITERATIONS : natural := 4556;
|
constant TIME_BETWEEN_ITERATIONS : natural := 4556;
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable timestamp_cntr : natural := 250;
|
variable timestamp_cntr : natural := 250;
|
||||||
variable header_len : natural := 0;
|
variable header_len : natural := 0;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,280 @@
|
||||||
|
-- Copyright (c) 2024 Nuand LLC
|
||||||
|
--
|
||||||
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
-- of this software and associated documentation files (the "Software"), to deal
|
||||||
|
-- in the Software without restriction, including without limitation the rights
|
||||||
|
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
-- copies of the Software, and to permit persons to whom the Software is
|
||||||
|
-- furnished to do so, subject to the following conditions:
|
||||||
|
--
|
||||||
|
-- The above copyright notice and this permission notice shall be included in
|
||||||
|
-- all copies or substantial portions of the Software.
|
||||||
|
--
|
||||||
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
-- THE SOFTWARE.
|
||||||
|
|
||||||
|
library ieee;
|
||||||
|
use ieee.std_logic_1164.all;
|
||||||
|
use ieee.numeric_std.all;
|
||||||
|
use ieee.math_real.all;
|
||||||
|
use ieee.math_complex.all;
|
||||||
|
|
||||||
|
library work;
|
||||||
|
use work.util.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
|
architecture micro_dma_fifo_stress of fx3_model is
|
||||||
|
|
||||||
|
constant PCLK_HALF_PERIOD : time := 1 sec * (1.0/100.0e6/2.0);
|
||||||
|
constant START_COUNT : natural := 32;
|
||||||
|
constant BLOCKS_PER_ITERATION : natural := 7;
|
||||||
|
constant ITERATIONS : natural := 4;
|
||||||
|
|
||||||
|
-- Control mapping
|
||||||
|
alias dma0_rx_ack is fx3_ctl( 0);
|
||||||
|
alias dma1_rx_ack is fx3_ctl( 1);
|
||||||
|
alias dma2_tx_ack is fx3_ctl( 2);
|
||||||
|
alias dma3_tx_ack is fx3_ctl( 3);
|
||||||
|
alias dma_rx_enable is fx3_ctl( 4);
|
||||||
|
alias dma_tx_enable is fx3_ctl( 5);
|
||||||
|
alias dma_idle is fx3_ctl( 6);
|
||||||
|
alias system_reset is fx3_ctl( 7);
|
||||||
|
alias dma0_rx_reqx is fx3_ctl( 8);
|
||||||
|
alias dma1_rx_reqx is fx3_ctl(12); -- due to 9 being connected to dclk
|
||||||
|
alias dma2_tx_reqx is fx3_ctl(10);
|
||||||
|
alias dma3_tx_reqx is fx3_ctl(11);
|
||||||
|
|
||||||
|
type gpif_state_t is (IDLE, TX_META, TX_SAMPLES, RX_SAMPLES);
|
||||||
|
signal gpif_state_rx, gpif_state_tx : gpif_state_t;
|
||||||
|
|
||||||
|
signal rx_done : boolean := false;
|
||||||
|
signal tx_done : boolean := false;
|
||||||
|
|
||||||
|
signal rx_data : std_logic_vector(31 downto 0);
|
||||||
|
signal tx_data : std_logic_vector(31 downto 0);
|
||||||
|
|
||||||
|
impure function data_gen (count : natural) return std_logic_vector is
|
||||||
|
variable eight_bit_msw_i : std_logic_vector(7 downto 0);
|
||||||
|
variable eight_bit_msw_q : std_logic_vector(7 downto 0);
|
||||||
|
variable eight_bit_lsw_i : std_logic_vector(7 downto 0);
|
||||||
|
variable eight_bit_lsw_q : std_logic_vector(7 downto 0);
|
||||||
|
variable msw, lsw : std_logic_vector(15 downto 0);
|
||||||
|
begin
|
||||||
|
if( eight_bit_mode_en = '1' ) then
|
||||||
|
eight_bit_lsw_i := std_logic_vector(to_unsigned(count, 8));
|
||||||
|
eight_bit_lsw_q := std_logic_vector(to_unsigned(count+1, 8));
|
||||||
|
eight_bit_msw_i := std_logic_vector(to_unsigned(count+2, 8));
|
||||||
|
eight_bit_msw_q := std_logic_vector(to_unsigned(count+3, 8));
|
||||||
|
lsw := eight_bit_lsw_q & eight_bit_lsw_i;
|
||||||
|
msw := eight_bit_msw_q & eight_bit_msw_i;
|
||||||
|
else
|
||||||
|
msw := std_logic_vector(to_signed(count+1, 16));
|
||||||
|
lsw := std_logic_vector(to_signed(count, 16));
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return (msw & lsw);
|
||||||
|
end function data_gen;
|
||||||
|
|
||||||
|
impure function data_check (count : natural ; rxdata : std_logic_vector(31 downto 0)) return boolean is
|
||||||
|
begin
|
||||||
|
return (rxdata = data_gen(count));
|
||||||
|
end function data_check;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
-- DCLK which isn't used
|
||||||
|
fx3_ctl(9) <= '0';
|
||||||
|
|
||||||
|
fx3_ctl(3 downto 0) <= (others => 'Z');
|
||||||
|
|
||||||
|
-- Create a 100MHz clock output
|
||||||
|
fx3_pclk <= not fx3_pclk after PCLK_HALF_PERIOD when (not rx_done or not tx_done) else '0';
|
||||||
|
|
||||||
|
-- Doneness
|
||||||
|
done <= rx_done and tx_done;
|
||||||
|
|
||||||
|
rx_sample_stream : process
|
||||||
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
|
variable count : natural := START_COUNT;
|
||||||
|
variable req_time : time;
|
||||||
|
begin
|
||||||
|
gpif_state_rx <= IDLE;
|
||||||
|
dma0_rx_reqx <= '1';
|
||||||
|
dma1_rx_reqx <= '1';
|
||||||
|
dma_rx_enable <= '0';
|
||||||
|
rx_data <= (others => 'U');
|
||||||
|
|
||||||
|
wait until rising_edge(fx3_pclk) and system_reset = '0';
|
||||||
|
|
||||||
|
nop(fx3_pclk, 1000);
|
||||||
|
|
||||||
|
wait until rising_edge(fx3_pclk) and fx3_rx_en = '1';
|
||||||
|
|
||||||
|
wait for 30 us;
|
||||||
|
|
||||||
|
for j in 1 to ITERATIONS loop
|
||||||
|
dma_rx_enable <= '1';
|
||||||
|
|
||||||
|
for i in 1 to BLOCKS_PER_ITERATION loop
|
||||||
|
dma0_rx_reqx <= '0';
|
||||||
|
req_time := now;
|
||||||
|
wait until rising_edge( fx3_pclk ) and dma0_rx_ack = '1';
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
dma0_rx_reqx <= '1';
|
||||||
|
|
||||||
|
report "RX iteration " & to_string(j) & " block " & to_string(i) & " delay " & to_string(now - req_time);
|
||||||
|
|
||||||
|
for i in 1 to BLOCK_SIZE loop
|
||||||
|
gpif_state_rx <= RX_SAMPLES;
|
||||||
|
rx_data <= fx3_gpif;
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
|
||||||
|
--assert data_check(count, rx_data) severity failure;
|
||||||
|
|
||||||
|
count := (count + 1) mod 2048;
|
||||||
|
gpif_state_rx <= IDLE;
|
||||||
|
rx_data <= (others => 'X');
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
dma_rx_enable <= '0';
|
||||||
|
wait for 10 us;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
report "Done with RX sample stream";
|
||||||
|
rx_done <= true;
|
||||||
|
wait;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
tx_sample_stream : process
|
||||||
|
constant TIME_BETWEEN_ITERATIONS : natural := 4593;
|
||||||
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
|
variable count : natural := START_COUNT;
|
||||||
|
variable timestamp_cntr : natural := 400;
|
||||||
|
variable header_len : natural := 0;
|
||||||
|
variable data_out : std_logic_vector(31 downto 0);
|
||||||
|
variable req_time : time;
|
||||||
|
begin
|
||||||
|
gpif_state_tx <= IDLE;
|
||||||
|
dma2_tx_reqx <= '1';
|
||||||
|
dma3_tx_reqx <= '1';
|
||||||
|
dma_tx_enable <= '0';
|
||||||
|
fx3_gpif <= (others =>'Z');
|
||||||
|
|
||||||
|
wait until rising_edge(fx3_pclk) and system_reset = '0';
|
||||||
|
|
||||||
|
nop(fx3_pclk, 1000);
|
||||||
|
|
||||||
|
wait until rising_edge(fx3_pclk) and fx3_tx_en = '1';
|
||||||
|
|
||||||
|
wait for 30 us;
|
||||||
|
|
||||||
|
for k in 1 to ITERATIONS loop
|
||||||
|
dma_tx_enable <= '1';
|
||||||
|
|
||||||
|
for fifo_stress_idx in 1 to 3 loop
|
||||||
|
for j in 1 to BLOCKS_PER_ITERATION loop
|
||||||
|
header_len := 0;
|
||||||
|
dma3_tx_reqx <= '0';
|
||||||
|
req_time := now;
|
||||||
|
wait until rising_edge( fx3_pclk ) and dma3_tx_ack = '1';
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
dma3_tx_reqx <= '1';
|
||||||
|
|
||||||
|
report "TX iteration " & to_string(k) & " block " & to_string(j) & " delay " & to_string(now - req_time);
|
||||||
|
|
||||||
|
|
||||||
|
if( fx3_tx_meta_en = '1') then
|
||||||
|
header_len := 4;
|
||||||
|
|
||||||
|
for i in 1 to 4 loop
|
||||||
|
case (i) is
|
||||||
|
when 1 =>
|
||||||
|
data_out := x"00000000";
|
||||||
|
when 2 =>
|
||||||
|
data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32));
|
||||||
|
if (j = BLOCKS_PER_ITERATION) then
|
||||||
|
timestamp_cntr := timestamp_cntr + TIME_BETWEEN_ITERATIONS;
|
||||||
|
else
|
||||||
|
timestamp_cntr := timestamp_cntr + 254;
|
||||||
|
end if;
|
||||||
|
when 3 =>
|
||||||
|
data_out := (others => '0');
|
||||||
|
when 4 =>
|
||||||
|
data_out := (others => '1');
|
||||||
|
end case;
|
||||||
|
|
||||||
|
gpif_state_tx <= TX_META;
|
||||||
|
fx3_gpif <= data_out;
|
||||||
|
tx_data <= data_out;
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
|
||||||
|
gpif_state_tx <= IDLE;
|
||||||
|
tx_data <= (others => 'X');
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
count := 0;
|
||||||
|
|
||||||
|
for i in 1 to (BLOCK_SIZE - header_len) loop
|
||||||
|
gpif_state_tx <= TX_SAMPLES;
|
||||||
|
data_out := data_gen(count);
|
||||||
|
if( eight_bit_mode_en = '1' ) then
|
||||||
|
fx3_gpif <= data_out;
|
||||||
|
tx_data <= data_out;
|
||||||
|
else
|
||||||
|
fx3_gpif <= std_logic_vector(to_unsigned(j, 8)) & data_out(23 downto 0);
|
||||||
|
tx_data <= std_logic_vector(to_unsigned(j, 8)) & data_out(23 downto 0);
|
||||||
|
end if;
|
||||||
|
wait until rising_edge( fx3_pclk );
|
||||||
|
|
||||||
|
count := (count + 4) mod 128 when eight_bit_mode_en = '1' else
|
||||||
|
(count + 2) mod 2048;
|
||||||
|
gpif_state_tx <= IDLE;
|
||||||
|
tx_data <= (others => 'X');
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
fx3_gpif <= (others =>'Z');
|
||||||
|
nop(fx3_pclk, 10);
|
||||||
|
end loop;
|
||||||
|
wait for 10 us;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
wait for 2 ms;
|
||||||
|
dma_tx_enable <= '0';
|
||||||
|
wait for 10 us;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
report "Done with TX sample stream";
|
||||||
|
tx_done <= true;
|
||||||
|
wait;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
reset_system : process
|
||||||
|
begin
|
||||||
|
system_reset <= '1';
|
||||||
|
dma_idle <= '0';
|
||||||
|
nop( fx3_pclk, 100 );
|
||||||
|
system_reset <= '0';
|
||||||
|
nop( fx3_pclk, 10 );
|
||||||
|
dma_idle <= '1';
|
||||||
|
wait;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
-- TODO: UART Interface
|
||||||
|
fx3_uart_txd <= '1';
|
||||||
|
fx3_uart_cts <= '1';
|
||||||
|
|
||||||
|
assert (gpif_state_tx = IDLE and gpif_state_rx /= IDLE)
|
||||||
|
or (gpif_state_rx = IDLE and gpif_state_tx /= IDLE)
|
||||||
|
or (gpif_state_rx = IDLE and gpif_state_tx = IDLE)
|
||||||
|
report "gpif_state_rx and gpif_state_tx cannot both be non-idle"
|
||||||
|
severity failure;
|
||||||
|
|
||||||
|
end architecture micro_dma_fifo_stress;
|
||||||
|
|
@ -32,6 +32,7 @@ library nuand;
|
||||||
use nuand.fifo_readwrite_p.all;
|
use nuand.fifo_readwrite_p.all;
|
||||||
use nuand.common_dcfifo_p.all;
|
use nuand.common_dcfifo_p.all;
|
||||||
use nuand.bladerf_p.all;
|
use nuand.bladerf_p.all;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity rx_timestamp_tb is
|
entity rx_timestamp_tb is
|
||||||
generic (
|
generic (
|
||||||
|
|
@ -618,7 +619,8 @@ begin
|
||||||
-- variable timestamp : unsigned(63 downto 0) := (others => '0');
|
-- variable timestamp : unsigned(63 downto 0) := (others => '0');
|
||||||
begin
|
begin
|
||||||
wait for 1 ns;
|
wait for 1 ns;
|
||||||
delta_expected := to_unsigned(508, 64) when not EIGHT_BIT_MODE_EN else to_unsigned(1016, 64);
|
delta_expected := to_unsigned(GPIF_BUF_SIZE_SS-HEADER_LEN, 64) when not EIGHT_BIT_MODE_EN
|
||||||
|
else to_unsigned(2*(GPIF_BUF_SIZE_SS-HEADER_LEN), 64);
|
||||||
|
|
||||||
if (ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1) then
|
if (ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1) then
|
||||||
delta_expected := delta_expected/2;
|
delta_expected := delta_expected/2;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ library ieee;
|
||||||
|
|
||||||
library work;
|
library work;
|
||||||
use work.util.all;
|
use work.util.all;
|
||||||
|
use work.fx3_gpif_p.all;
|
||||||
|
|
||||||
architecture wlan_micro_packet_dma of fx3_model is
|
architecture wlan_micro_packet_dma of fx3_model is
|
||||||
|
|
||||||
|
|
@ -108,7 +109,7 @@ begin
|
||||||
done <= rx_done and tx_done;
|
done <= rx_done and tx_done;
|
||||||
|
|
||||||
rx_sample_stream : process
|
rx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable req_time : time;
|
variable req_time : time;
|
||||||
begin
|
begin
|
||||||
|
|
@ -161,7 +162,7 @@ begin
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
tx_sample_stream : process
|
tx_sample_stream : process
|
||||||
constant BLOCK_SIZE : natural := 512;
|
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
|
||||||
variable count : natural := START_COUNT;
|
variable count : natural := START_COUNT;
|
||||||
variable timestamp_cntr : natural := 100;
|
variable timestamp_cntr : natural := 100;
|
||||||
variable header_len : natural := 0;
|
variable header_len : natural := 0;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
|
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-adsb.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-adsb.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-atsc_tx.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-atsc_tx.vhd]]
|
||||||
set_global_assignment -name QIP_FILE [file normalize nios_system/synthesis/nios_system.qip]
|
set_global_assignment -name QIP_FILE [file normalize nios_system/synthesis/nios_system.qip]
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/bladerf_agc.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/bladerf_agc.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip trigger/trigger.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip trigger/trigger.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
|
||||||
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/rx_packet_generator.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/rx_packet_generator.vhd]]
|
||||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-hosted.vhd]]
|
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-hosted.vhd]]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ vcom -work nuand -2008 ../../../ip/altera/rx_meta_fifo/rx_meta_fifo.vhd
|
||||||
|
|
||||||
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
|
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
|
||||||
|
|
||||||
|
vcom -work nuand -2008 ../vhdl/fx3_gpif_p.vhd
|
||||||
vcom -work nuand -2008 ../vhdl/fx3_gpif.vhd
|
vcom -work nuand -2008 ../vhdl/fx3_gpif.vhd
|
||||||
|
|
||||||
vcom -work nuand -2008 ../vhdl/bladerf.vhd
|
vcom -work nuand -2008 ../vhdl/bladerf.vhd
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ library ieee;
|
||||||
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
||||||
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
||||||
|
|
||||||
|
library nuand;
|
||||||
|
use nuand.fx3_gpif_p.all;
|
||||||
|
|
||||||
entity fx3_gpif is
|
entity fx3_gpif is
|
||||||
port (
|
port (
|
||||||
-- FX3 control signals
|
-- FX3 control signals
|
||||||
|
|
@ -117,10 +120,6 @@ architecture sample_shuffler of fx3_gpif is
|
||||||
constant META_DOWNCOUNT_RESET : natural := 4;
|
constant META_DOWNCOUNT_RESET : natural := 4;
|
||||||
constant FINI_DOWNCOUNT_RESET : natural := 10;
|
constant FINI_DOWNCOUNT_RESET : natural := 10;
|
||||||
|
|
||||||
-- GPIF buf sizes for USB high-speed and super-speed
|
|
||||||
constant GPIF_BUF_SIZE_HS : natural := 256;
|
|
||||||
constant GPIF_BUF_SIZE_SS : natural := 512;
|
|
||||||
|
|
||||||
type dma_handshake_t is record
|
type dma_handshake_t is record
|
||||||
rx0 : std_logic;
|
rx0 : std_logic;
|
||||||
rx1 : std_logic;
|
rx1 : std_logic;
|
||||||
|
|
@ -280,7 +279,7 @@ begin
|
||||||
-- Can we not fit one more block of data in RX buffer?
|
-- Can we not fit one more block of data in RX buffer?
|
||||||
rx_fifo_critical <= (unsigned(rx_fifo_usedw) >= ((2**(rx_fifo_usedw'length-1) - gpif_buf_size)));
|
rx_fifo_critical <= (unsigned(rx_fifo_usedw) >= ((2**(rx_fifo_usedw'length-1) - gpif_buf_size)));
|
||||||
-- Do we have room for one more block of data in the TX buffer?
|
-- Do we have room for one more block of data in the TX buffer?
|
||||||
tx_fifo_enough <= (unsigned(tx_fifo_usedw) < ((2**(tx_fifo_usedw'length-1) - gpif_buf_size * 4))) and
|
tx_fifo_enough <= (unsigned(tx_fifo_usedw) < ((2**(tx_fifo_usedw'length) - gpif_buf_size))) and
|
||||||
(unsigned(tx_meta_fifo_usedw) < ((2**(tx_meta_fifo_usedw'length-1) - 4)));
|
(unsigned(tx_meta_fifo_usedw) < ((2**(tx_meta_fifo_usedw'length-1) - 4)));
|
||||||
end if;
|
end if;
|
||||||
end process calculate_fifo_waterlines;
|
end process calculate_fifo_waterlines;
|
||||||
|
|
|
||||||
27
hdl/fpga/platforms/common/bladerf/vhdl/fx3_gpif_p.vhd
Normal file
27
hdl/fpga/platforms/common/bladerf/vhdl/fx3_gpif_p.vhd
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
-- Copyright (c) 2024 Nuand LLC
|
||||||
|
--
|
||||||
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
-- of this software and associated documentation files (the "Software"), to deal
|
||||||
|
-- in the Software without restriction, including without limitation the rights
|
||||||
|
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
-- copies of the Software, and to permit persons to whom the Software is
|
||||||
|
-- furnished to do so, subject to the following conditions:
|
||||||
|
--
|
||||||
|
-- The above copyright notice and this permission notice shall be included in
|
||||||
|
-- all copies or substantial portions of the Software.
|
||||||
|
--
|
||||||
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
-- THE SOFTWARE.
|
||||||
|
library ieee;
|
||||||
|
use ieee.std_logic_1164.all;
|
||||||
|
|
||||||
|
package fx3_gpif_p is
|
||||||
|
-- GPIF buf sizes for USB high-speed and super-speed
|
||||||
|
constant GPIF_BUF_SIZE_HS : natural := 1024;
|
||||||
|
constant GPIF_BUF_SIZE_SS : natural := 2048;
|
||||||
|
end package fx3_gpif_p;
|
||||||
|
|
@ -462,6 +462,18 @@ if [[ ${flow} == "full" ]]; then
|
||||||
sha256sum $RBF > $RBF.sha256sum
|
sha256sum $RBF > $RBF.sha256sum
|
||||||
MD5SUM=$(cat $RBF.md5sum | awk '{ print $1 }')
|
MD5SUM=$(cat $RBF.md5sum | awk '{ print $1 }')
|
||||||
SHA256SUM=$(cat $RBF.sha256sum | awk '{ print $1 }')
|
SHA256SUM=$(cat $RBF.sha256sum | awk '{ print $1 }')
|
||||||
|
|
||||||
|
GIT_HASH=$(git rev-parse --short HEAD)
|
||||||
|
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
GIT_DIRTY=$(git diff --quiet && echo "clean" || echo "dirty")
|
||||||
|
|
||||||
|
cat << EOF > git_info.txt
|
||||||
|
Git Information:
|
||||||
|
Commit Hash: $GIT_HASH
|
||||||
|
Branch: $GIT_BRANCH
|
||||||
|
Working Directory: $GIT_DIRTY
|
||||||
|
EOF
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -473,6 +485,10 @@ if [[ ${flow} == "full" ]]; then
|
||||||
echo " MD5: $MD5SUM"
|
echo " MD5: $MD5SUM"
|
||||||
echo " SHA256: $SHA256SUM"
|
echo " SHA256: $SHA256SUM"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " Git Information:"
|
||||||
|
echo " Commit: $GIT_HASH ($GIT_DIRTY)"
|
||||||
|
echo " Branch: $GIT_BRANCH"
|
||||||
|
echo ""
|
||||||
cat "$BUILD_OUTPUT_DIR/$BUILD_NAME.fit.summary" | sed -e 's/^\(.\)/ \1/g'
|
cat "$BUILD_OUTPUT_DIR/$BUILD_NAME.fit.summary" | sed -e 's/^\(.\)/ \1/g'
|
||||||
echo "##########################################################################"
|
echo "##########################################################################"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ project(libbladeRF C)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
set(VERSION_INFO_MAJOR 2)
|
set(VERSION_INFO_MAJOR 2)
|
||||||
set(VERSION_INFO_MINOR 5)
|
set(VERSION_INFO_MINOR 6)
|
||||||
set(VERSION_INFO_PATCH 1)
|
set(VERSION_INFO_PATCH 0)
|
||||||
set(LIBBLADERF_VERSION
|
set(LIBBLADERF_VERSION
|
||||||
${VERSION_INFO_MAJOR}.${VERSION_INFO_MINOR}.${VERSION_INFO_PATCH})
|
${VERSION_INFO_MAJOR}.${VERSION_INFO_MINOR}.${VERSION_INFO_PATCH})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ int16_t *init(struct bladerf *dev, int16_t num_samples, bladerf_format format,
|
||||||
* restricted to multiples of any particular size.
|
* restricted to multiples of any particular size.
|
||||||
*
|
*
|
||||||
* The value for `num_samples` has no major restrictions here, while the
|
* The value for `num_samples` has no major restrictions here, while the
|
||||||
* `buffer_size` below must be a multiple of 1024.
|
* `buffer_size` below must be a multiple of 2048.
|
||||||
*/
|
*/
|
||||||
int16_t *samples;
|
int16_t *samples;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ static int init_sync(struct bladerf *dev)
|
||||||
* received.
|
* received.
|
||||||
*/
|
*/
|
||||||
const unsigned int num_buffers = 16;
|
const unsigned int num_buffers = 16;
|
||||||
const unsigned int buffer_size = 8192; /* Must be a multiple of 1024 */
|
const unsigned int buffer_size = 8192; /* Must be a multiple of 2048 */
|
||||||
const unsigned int num_transfers = 8;
|
const unsigned int num_transfers = 8;
|
||||||
const unsigned int timeout_ms = 3500;
|
const unsigned int timeout_ms = 3500;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ int16_t *init(struct bladerf *dev, int16_t num_samples)
|
||||||
* restricted to multiples of any particular size.
|
* restricted to multiples of any particular size.
|
||||||
*
|
*
|
||||||
* The value for `num_samples` has no major restrictions here, while the
|
* The value for `num_samples` has no major restrictions here, while the
|
||||||
* `buffer_size` below must be a multiple of 1024.
|
* `buffer_size` below must be a multiple of 2048.
|
||||||
*/
|
*/
|
||||||
int16_t *samples;
|
int16_t *samples;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
*
|
*
|
||||||
* https://github.com/Nuand/bladeRF/blob/master/doc/development/versioning.md
|
* https://github.com/Nuand/bladeRF/blob/master/doc/development/versioning.md
|
||||||
*/
|
*/
|
||||||
#define LIBBLADERF_API_VERSION (0x02050100)
|
#define LIBBLADERF_API_VERSION (0x02060000)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -2724,7 +2724,7 @@ int CALL_CONV bladerf_get_timestamp(struct bladerf *dev,
|
||||||
* data stream. This must be greater than the
|
* data stream. This must be greater than the
|
||||||
* `num_xfers` parameter.
|
* `num_xfers` parameter.
|
||||||
* @param[in] buffer_size The size of the underlying stream buffers, in
|
* @param[in] buffer_size The size of the underlying stream buffers, in
|
||||||
* samples. This value must be a multiple of 1024.
|
* samples. This value must be a multiple of 2048.
|
||||||
* Note that samples are only transferred when a
|
* Note that samples are only transferred when a
|
||||||
* buffer of this size is filled.
|
* buffer of this size is filled.
|
||||||
* @param[in] num_transfers The number of active USB transfers that may be
|
* @param[in] num_transfers The number of active USB transfers that may be
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@ extern bool bladerf_usb_reset_device_on_open;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Size of a host<->FPGA message in BYTES */
|
/* Size of a host<->FPGA message in BYTES */
|
||||||
#define USB_MSG_SIZE_SS 2048
|
#define USB_MSG_SIZE_SS 8192
|
||||||
#define USB_MSG_SIZE_HS 1024
|
#define USB_MSG_SIZE_HS 4096
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
USB_TARGET_DEVICE,
|
USB_TARGET_DEVICE,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
static const struct compat fw_compat[] = {
|
static const struct compat fw_compat[] = {
|
||||||
/* Firmware requires >= FPGA */
|
/* Firmware requires >= FPGA */
|
||||||
|
{ VERSION(2, 5, 0), VERSION(0, 16, 0) },
|
||||||
{ VERSION(2, 4, 0), VERSION(0, 6, 0) },
|
{ VERSION(2, 4, 0), VERSION(0, 6, 0) },
|
||||||
{ VERSION(2, 3, 2), VERSION(0, 6, 0) },
|
{ VERSION(2, 3, 2), VERSION(0, 6, 0) },
|
||||||
{ VERSION(2, 3, 1), VERSION(0, 6, 0) },
|
{ VERSION(2, 3, 1), VERSION(0, 6, 0) },
|
||||||
|
|
@ -27,6 +28,7 @@ const struct version_compat_table bladerf2_fw_compat_table = {fw_compat, ARRAY_S
|
||||||
|
|
||||||
static const struct compat fpga_compat[] = {
|
static const struct compat fpga_compat[] = {
|
||||||
/* FPGA requires >= Firmware */
|
/* FPGA requires >= Firmware */
|
||||||
|
{ VERSION(0, 16, 0), VERSION(2, 5, 0) },
|
||||||
{ VERSION(0, 15, 3), VERSION(2, 4, 0) },
|
{ VERSION(0, 15, 3), VERSION(2, 4, 0) },
|
||||||
{ VERSION(0, 15, 2), VERSION(2, 4, 0) },
|
{ VERSION(0, 15, 2), VERSION(2, 4, 0) },
|
||||||
{ VERSION(0, 15, 1), VERSION(2, 4, 0) },
|
{ VERSION(0, 15, 1), VERSION(2, 4, 0) },
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ int async_init_stream(struct bladerf_stream **stream,
|
||||||
return BLADERF_ERR_INVAL;
|
return BLADERF_ERR_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (samples_per_buffer < 1024 || samples_per_buffer % 1024 != 0) {
|
if (samples_per_buffer < 2048 || samples_per_buffer % 2048 != 0) {
|
||||||
log_error("samples_per_buffer must be multiples of 1024\n");
|
log_error("samples_per_buffer must be multiples of 2048\n");
|
||||||
return BLADERF_ERR_INVAL;
|
return BLADERF_ERR_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~
|
* ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
*
|
*
|
||||||
* The FPGA handles data in units of "messages." These messages are
|
* The FPGA handles data in units of "messages." These messages are
|
||||||
* 1024 or 2048 bytes for USB 2.0 (Hi-Speed) or USB 3.0 (SuperSpeed),
|
* 1024 or 8192 bytes for USB 2.0 (Hi-Speed) or USB 3.0 (SuperSpeed),
|
||||||
* respectively.
|
* respectively.
|
||||||
*
|
*
|
||||||
* The first 16 bytes of the message form a header, which includes metadata
|
* The first 16 bytes of the message form a header, which includes metadata
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,12 @@ int sync_init(struct bladerf_sync *sync,
|
||||||
return BLADERF_ERR_INVAL;
|
return BLADERF_ERR_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buffer_size < 2048) {
|
||||||
|
log_warning("Requested samples per buffer (%zu) is less than 2048. "
|
||||||
|
"Clamping to 2048.\n", buffer_size);
|
||||||
|
buffer_size = 2048;
|
||||||
|
}
|
||||||
|
|
||||||
/* bladeRF GPIF DMA requirement */
|
/* bladeRF GPIF DMA requirement */
|
||||||
if ((bytes_per_sample * buffer_size) % 4096 != 0) {
|
if ((bytes_per_sample * buffer_size) % 4096 != 0) {
|
||||||
assert(!"Invalid buffer size");
|
assert(!"Invalid buffer size");
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ add_subdirectory(test_quick_retune)
|
||||||
add_subdirectory(test_repeated_stream)
|
add_subdirectory(test_repeated_stream)
|
||||||
add_subdirectory(test_rx_discont)
|
add_subdirectory(test_rx_discont)
|
||||||
add_subdirectory(test_scheduled_retune)
|
add_subdirectory(test_scheduled_retune)
|
||||||
|
add_subdirectory(test_streaming)
|
||||||
add_subdirectory(test_sync)
|
add_subdirectory(test_sync)
|
||||||
add_subdirectory(test_timestamps)
|
add_subdirectory(test_timestamps)
|
||||||
add_subdirectory(test_tune_timing)
|
add_subdirectory(test_tune_timing)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ int16_t *init(struct bladerf *dev, int16_t num_samples, bladerf_format format,
|
||||||
* restricted to multiples of any particular size.
|
* restricted to multiples of any particular size.
|
||||||
*
|
*
|
||||||
* The value for `num_samples` has no major restrictions here, while the
|
* The value for `num_samples` has no major restrictions here, while the
|
||||||
* `buffer_size` below must be a multiple of 1024.
|
* `buffer_size` below must be a multiple of 2048.
|
||||||
*/
|
*/
|
||||||
int16_t *samples;
|
int16_t *samples;
|
||||||
|
|
||||||
|
|
|
||||||
17
host/libraries/libbladeRF_test/test_streaming/CMakeLists.txt
Normal file
17
host/libraries/libbladeRF_test/test_streaming/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(libbladeRF_test_streaming C)
|
||||||
|
|
||||||
|
set(INCLUDES
|
||||||
|
${libbladeRF_SOURCE_DIR}/include)
|
||||||
|
if(MSVC)
|
||||||
|
set(INCLUDES ${INCLUDES} ${MSVC_C99_INCLUDES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SRC
|
||||||
|
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
|
||||||
|
src/main.c)
|
||||||
|
|
||||||
|
include_directories(${INCLUDES} ${CURL_INCLUDE_DIR} include)
|
||||||
|
add_executable(${PROJECT_NAME} ${SRC})
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} libbladerf_shared m)
|
||||||
329
host/libraries/libbladeRF_test/test_streaming/src/main.c
Normal file
329
host/libraries/libbladeRF_test/test_streaming/src/main.c
Normal file
|
|
@ -0,0 +1,329 @@
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <libbladeRF.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "conversions.h"
|
||||||
|
|
||||||
|
#define INT12_MAX 2047
|
||||||
|
#define BUFFER_SIZE_ALIGNMENT 1024
|
||||||
|
|
||||||
|
#define CHECK_STATUS(fn) \
|
||||||
|
do { \
|
||||||
|
status = (fn); \
|
||||||
|
if (status != 0) { \
|
||||||
|
fprintf(stderr, "Error at %s:%d (%s): %s\n", \
|
||||||
|
__FILE__, __LINE__, __func__, bladerf_strerror(status)); \
|
||||||
|
goto error; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool tx;
|
||||||
|
bool rx;
|
||||||
|
bool mimo;
|
||||||
|
size_t num_samples;
|
||||||
|
uint64_t sample_rate;
|
||||||
|
int16_t *tx_samples;
|
||||||
|
int16_t *rx_samples;
|
||||||
|
bladerf_format format;
|
||||||
|
struct bladerf_metadata tx_meta;
|
||||||
|
struct bladerf_metadata rx_meta;
|
||||||
|
size_t num_buffers;
|
||||||
|
size_t buffer_size;
|
||||||
|
size_t num_transfers;
|
||||||
|
size_t timeout_ms;
|
||||||
|
} test_config;
|
||||||
|
|
||||||
|
void print_config(const test_config *config, const char *device_string, const char *fpga_file) {
|
||||||
|
printf("\nConfiguration Summary:\n");
|
||||||
|
printf("---------------------\n");
|
||||||
|
printf("Device: %s\n", device_string ? device_string : "any");
|
||||||
|
printf("FPGA file: %s\n", fpga_file ? fpga_file : "Not specified");
|
||||||
|
printf("TX enabled: %s\n", config->tx ? "Yes" : "No");
|
||||||
|
printf("RX enabled: %s\n", config->rx ? "Yes" : "No");
|
||||||
|
printf("MIMO enabled: %s\n", config->mimo ? "Yes" : "No");
|
||||||
|
printf("Format: %s\n", config->format == BLADERF_FORMAT_SC16_Q11_META ? "SC16 Q11 META" : "SC16 Q11");
|
||||||
|
printf("Sample rate: %.3f MHz\n", config->sample_rate / 1e6);
|
||||||
|
printf("# of samples: %zu\n", config->num_samples);
|
||||||
|
printf("Buffer size: %zu\n", config->buffer_size);
|
||||||
|
printf("# of buffers: %zu\n", config->num_buffers);
|
||||||
|
printf("# of transfers: %zu\n", config->num_transfers);
|
||||||
|
printf("---------------------\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Define suffix table for engineering notation
|
||||||
|
static const struct numeric_suffix freq_suffixes[] = {
|
||||||
|
{ "K", 1000 },
|
||||||
|
{ "k", 1000 },
|
||||||
|
{ "M", 1000000 },
|
||||||
|
{ "m", 1000000 },
|
||||||
|
{ "G", 1000000000 },
|
||||||
|
{ "g", 1000000000 },
|
||||||
|
};
|
||||||
|
|
||||||
|
void print_bladerf_flag_statuses(uint32_t flags) {
|
||||||
|
printf("BladeRF Flag Statuses:\n");
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_STATUS_OVERRUN:", !!(flags & BLADERF_META_STATUS_OVERRUN));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_STATUS_UNDERRUN:", !!(flags & BLADERF_META_STATUS_UNDERRUN));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_TX_BURST_START:", !!(flags & BLADERF_META_FLAG_TX_BURST_START));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_TX_BURST_END:", !!(flags & BLADERF_META_FLAG_TX_BURST_END));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_TX_NOW:", !!(flags & BLADERF_META_FLAG_TX_NOW));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_TX_UPDATE_TIMESTAMP:", !!(flags & BLADERF_META_FLAG_TX_UPDATE_TIMESTAMP));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_RX_NOW:", !!(flags & BLADERF_META_FLAG_RX_NOW));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_RX_HW_UNDERFLOW:", !!(flags & BLADERF_META_FLAG_RX_HW_UNDERFLOW));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_RX_HW_MINIEXP1:", !!(flags & BLADERF_META_FLAG_RX_HW_MINIEXP1));
|
||||||
|
printf("%-40s %d\n", "BLADERF_META_FLAG_RX_HW_MINIEXP2:", !!(flags & BLADERF_META_FLAG_RX_HW_MINIEXP2));
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_help() {
|
||||||
|
printf("Usage: test_streaming [options]\n");
|
||||||
|
printf("Options:\n");
|
||||||
|
printf(" -d, --device <device> Specify the device string\n");
|
||||||
|
printf(" -f, --fpga <file> Specify the FPGA file\n");
|
||||||
|
printf(" -v, --verbosity Enable verbose logging\n");
|
||||||
|
printf(" -t, --tx Enable TX test\n");
|
||||||
|
printf(" -r, --rx Enable RX test\n");
|
||||||
|
printf(" -m, --mimo Enable MIMO test\n");
|
||||||
|
printf(" -e, --meta Enable META test\n");
|
||||||
|
printf(" -s, --samplerate <rate> Specify the sample rate\n");
|
||||||
|
printf(" -n, --num-samples <count> Specify the number of samples\n");
|
||||||
|
printf(" -b, --buffer-size <size> Specify the buffer size (multiple of 2048)\n");
|
||||||
|
printf(" -h, --help Display this help message\n");
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Description:\n");
|
||||||
|
printf("The streaming test allows for cross testing between MIMO, SISO, TX, RX, meta,\n");
|
||||||
|
printf("and non-meta configurations.\n");
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Example: TX a CW at 50MSPS and at a frequency of (915MHz+50MHz/16) with meta enabled\n");
|
||||||
|
printf("./output/libbladeRF_test_streaming -te -s 50M\n");
|
||||||
|
printf("\n");
|
||||||
|
printf("Example: TX and RX at 25MSPS and at a frequency of (915MHz+25MHz/16) without meta enabled\n");
|
||||||
|
printf("./output/libbladeRF_test_streaming -tr -s 25M\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
struct bladerf *dev = NULL;
|
||||||
|
const char *fpga_file = NULL;
|
||||||
|
const char *device_string = NULL;
|
||||||
|
int c;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
test_config config = {
|
||||||
|
.tx = false,
|
||||||
|
.rx = false,
|
||||||
|
.mimo = false,
|
||||||
|
.sample_rate = 61.44e6,
|
||||||
|
.num_samples = 5 * 61.44e6,
|
||||||
|
.tx_samples = NULL,
|
||||||
|
.format = BLADERF_FORMAT_SC16_Q11,
|
||||||
|
.num_buffers = 512,
|
||||||
|
.buffer_size = 4096,
|
||||||
|
.num_transfers = 64,
|
||||||
|
.timeout_ms = 1000,
|
||||||
|
.tx_meta.flags = BLADERF_META_FLAG_TX_BURST_START |
|
||||||
|
BLADERF_META_FLAG_TX_NOW |
|
||||||
|
BLADERF_META_FLAG_TX_BURST_END,
|
||||||
|
.rx_meta.flags = BLADERF_META_FLAG_RX_NOW,
|
||||||
|
};
|
||||||
|
|
||||||
|
bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_INFO);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int option_index = 0;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"device", required_argument, 0, 'd'},
|
||||||
|
{"fpga", required_argument, 0, 'f'},
|
||||||
|
{"verbosity", no_argument, 0, 'v'},
|
||||||
|
{"tx", no_argument, 0, 't'},
|
||||||
|
{"rx", no_argument, 0, 'r'},
|
||||||
|
{"mimo", no_argument, 0, 'm'},
|
||||||
|
{"meta", no_argument, 0, 'e'},
|
||||||
|
{"samplerate", required_argument, 0, 's'},
|
||||||
|
{"num-samples", required_argument, 0, 'n'},
|
||||||
|
{"buffer-size", required_argument, 0, 'b'},
|
||||||
|
{"help", no_argument, 0, 'h'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
c = getopt_long(argc, argv, "d:f:vtrmes:n:b:h", long_options, &option_index);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'd':
|
||||||
|
device_string = optarg;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
fpga_file = optarg;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_VERBOSE);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
config.tx = true;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
config.rx = true;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
config.mimo = true;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
config.num_samples = str2uint64_suffix(
|
||||||
|
optarg, 1, UINT64_MAX, freq_suffixes,
|
||||||
|
sizeof(freq_suffixes) / sizeof(freq_suffixes[0]), &ok);
|
||||||
|
if (!ok) {
|
||||||
|
fprintf(stderr, "Invalid number of samples: %s\n", optarg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
size_t requested_size = strtoull(optarg, NULL, 0);
|
||||||
|
config.buffer_size = ((requested_size + BUFFER_SIZE_ALIGNMENT - 1) / BUFFER_SIZE_ALIGNMENT) * BUFFER_SIZE_ALIGNMENT;
|
||||||
|
if (requested_size % BUFFER_SIZE_ALIGNMENT != 0) {
|
||||||
|
fprintf(stderr, "Requested buffer size rounded up to %zu\n", config.buffer_size);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
config.format = BLADERF_FORMAT_SC16_Q11_META;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
config.sample_rate = str2uint64_suffix(
|
||||||
|
optarg, 0, UINT64_MAX, freq_suffixes,
|
||||||
|
sizeof(freq_suffixes) / sizeof(freq_suffixes[0]), &ok);
|
||||||
|
if (!ok) {
|
||||||
|
fprintf(stderr, "Invalid sample rate: %s\n", optarg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
case '?':
|
||||||
|
print_help();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
default:
|
||||||
|
printf("?? getopt returned character code 0%o ??\n", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.tx && !config.rx) {
|
||||||
|
fprintf(stderr, "[Error] TX or RX must be specified.\n");
|
||||||
|
print_help();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_config(&config, device_string, fpga_file);
|
||||||
|
|
||||||
|
// Allocate memory for samples (2* for IQ components and 2* for MIMO)
|
||||||
|
config.tx_samples = malloc(4 * config.num_samples * sizeof(int16_t));
|
||||||
|
config.rx_samples = malloc(4 * config.num_samples * sizeof(int16_t));
|
||||||
|
if (config.tx_samples == NULL || config.rx_samples == NULL) {
|
||||||
|
fprintf(stderr, "Failed to allocate memory for samples\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Opening device: %s\n", (device_string == NULL) ? "any" : device_string);
|
||||||
|
CHECK_STATUS(bladerf_open(&dev, device_string));
|
||||||
|
|
||||||
|
if (fpga_file != NULL) {
|
||||||
|
printf("Loading the FPGA image...\n");
|
||||||
|
CHECK_STATUS(bladerf_load_fpga(dev, fpga_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Setting sample rate to %0.3f MHz...\n", config.sample_rate / 1e6);
|
||||||
|
CHECK_STATUS(bladerf_set_sample_rate(dev, BLADERF_CHANNEL_RX(0), config.sample_rate, NULL));
|
||||||
|
CHECK_STATUS(bladerf_set_sample_rate(dev, BLADERF_CHANNEL_TX(0), config.sample_rate, NULL));
|
||||||
|
|
||||||
|
printf("Setting frequency to 915 MHz...\n");
|
||||||
|
CHECK_STATUS(bladerf_set_frequency(dev, BLADERF_CHANNEL_RX(0), 915e6));
|
||||||
|
CHECK_STATUS(bladerf_set_frequency(dev, BLADERF_CHANNEL_TX(0), 915e6));
|
||||||
|
|
||||||
|
CHECK_STATUS(bladerf_set_gain(dev, BLADERF_CHANNEL_TX(0), 30));
|
||||||
|
CHECK_STATUS(bladerf_set_gain(dev, BLADERF_CHANNEL_RX(0), 0));
|
||||||
|
|
||||||
|
for (size_t i = 0; i < config.num_samples; i++) {
|
||||||
|
double angle = (2.0 * M_PI * (i % 16)) / 16.0;
|
||||||
|
config.tx_samples[2 * i] = (int16_t)round(INT12_MAX * cos(angle)); // I component
|
||||||
|
config.tx_samples[2 * i + 1] = (int16_t)round(INT12_MAX * sin(angle)); // Q component
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.mimo) {
|
||||||
|
for (size_t i = 0; i < config.num_samples; i++) {
|
||||||
|
double angle = (2.0 * M_PI * (i % 16)) / 16.0;
|
||||||
|
config.tx_samples[4 * i + 0] = (int16_t)round(INT12_MAX * cos(angle)); // Ch0 I
|
||||||
|
config.tx_samples[4 * i + 1] = (int16_t)round(INT12_MAX * sin(angle)); // Ch0 Q
|
||||||
|
config.tx_samples[4 * i + 2] = (int16_t)round(INT12_MAX * cos(angle)); // Ch1 I
|
||||||
|
config.tx_samples[4 * i + 3] = (int16_t)round(INT12_MAX * sin(angle)); // Ch1 Q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.tx) {
|
||||||
|
printf("Streaming TX...\n");
|
||||||
|
CHECK_STATUS(bladerf_sync_config(
|
||||||
|
dev, (config.mimo == true) ? BLADERF_TX_X2 : BLADERF_TX_X1,
|
||||||
|
config.format, config.num_buffers, config.buffer_size,
|
||||||
|
config.num_transfers, config.timeout_ms));
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_TX(0), true));
|
||||||
|
if (config.mimo)
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_TX(1), true));
|
||||||
|
CHECK_STATUS(bladerf_sync_tx(dev, config.tx_samples, config.num_samples,
|
||||||
|
&config.tx_meta, 5000));
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_TX(0), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.rx) {
|
||||||
|
printf("Streaming RX...\n");
|
||||||
|
CHECK_STATUS(bladerf_sync_config(
|
||||||
|
dev, (config.mimo == true) ? BLADERF_RX_X2 : BLADERF_RX_X1,
|
||||||
|
config.format, config.num_buffers, config.buffer_size,
|
||||||
|
config.num_transfers, config.timeout_ms));
|
||||||
|
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_RX(0), true));
|
||||||
|
if (config.mimo)
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_RX(1), true));
|
||||||
|
|
||||||
|
/* Retrieve the current timestamp */
|
||||||
|
config.rx_meta.flags = 0;
|
||||||
|
status = bladerf_get_timestamp(dev, BLADERF_RX, &config.rx_meta.timestamp);
|
||||||
|
if (status != 0) {
|
||||||
|
fprintf(stderr, "Failed to get current RX timestamp: %s\n",
|
||||||
|
bladerf_strerror(status));
|
||||||
|
} else {
|
||||||
|
printf("Current RX timestamp: 0x%016" PRIx64 "\n", config.rx_meta.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Schedule first RX to be 0.1s in the future */
|
||||||
|
config.rx_meta.timestamp += config.sample_rate / 10;
|
||||||
|
printf("Scheduling RX for 0x%016" PRIx64 "\n", config.rx_meta.timestamp);
|
||||||
|
|
||||||
|
status = bladerf_sync_rx(dev, config.rx_samples, config.num_samples,
|
||||||
|
&config.rx_meta, config.timeout_ms);
|
||||||
|
if (status != 0) {
|
||||||
|
fprintf(stderr, "RX failed: %s\n", bladerf_strerror(status));
|
||||||
|
} else if (config.rx_meta.status & BLADERF_META_STATUS_OVERRUN) {
|
||||||
|
fprintf(stderr, "Overrun detected. %u valid samples were read.\n",
|
||||||
|
config.rx_meta.actual_count);
|
||||||
|
print_bladerf_flag_statuses(config.rx_meta.status);
|
||||||
|
} else {
|
||||||
|
printf("RX'd %u samples at t=0x%016" PRIx64 "\n", config.rx_meta.actual_count,
|
||||||
|
config.rx_meta.timestamp);
|
||||||
|
}
|
||||||
|
CHECK_STATUS(bladerf_enable_module(dev, BLADERF_CHANNEL_RX(0), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (config.tx_samples)
|
||||||
|
free(config.tx_samples);
|
||||||
|
if (config.rx_samples)
|
||||||
|
free(config.rx_samples);
|
||||||
|
if (dev)
|
||||||
|
bladerf_close(dev);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
@ -746,8 +746,8 @@ available parameters.
|
||||||
`bitmode` state
|
`bitmode` state
|
||||||
|
|
||||||
`samples` Number of samples per buffer to use in the
|
`samples` Number of samples per buffer to use in the
|
||||||
asynchronous stream. Must be divisible by 1024 and
|
asynchronous stream. Must be divisible by 2048 and
|
||||||
>= 1024.
|
>= 2048.
|
||||||
|
|
||||||
`buffers` Number of sample buffers to use in the asynchronous
|
`buffers` Number of sample buffers to use in the asynchronous
|
||||||
stream. The min value is 4.
|
stream. The min value is 4.
|
||||||
|
|
@ -935,8 +935,8 @@ available parameters.
|
||||||
retransmitting file contents. 0 implies no delay.
|
retransmitting file contents. 0 implies no delay.
|
||||||
|
|
||||||
`samples` Number of samples per buffer to use in the
|
`samples` Number of samples per buffer to use in the
|
||||||
asynchronous stream. Must be divisible by 1024 and
|
asynchronous stream. Must be divisible by 2048 and
|
||||||
>= 1024.
|
>= 2048.
|
||||||
|
|
||||||
`buffers` Number of sample buffers to use in the asynchronous
|
`buffers` Number of sample buffers to use in the asynchronous
|
||||||
stream. The min value is 4.
|
stream. The min value is 4.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue