hdl: bladeRF: nios_gpio_t, fifo_t, bladerf_p.vhd
Add bladerf_p.vhd package, which handles nios_gpio packing and unpacking between bits and record elements. This consolidates bit-to-function mapping, making it easier to modify the mapping in the future. This package also defines the FIFO record types and the nios_system component for easier re-use.
This commit is contained in:
parent
01cdbc78f5
commit
3b670ca799
7 changed files with 654 additions and 400 deletions
|
|
@ -9,6 +9,7 @@ proc compile_bladerf { root } {
|
|||
vcom -work nuand -2008 [file join $root ./vhdl/fx3.vhd]
|
||||
vcom -work nuand -2008 [file join $root ./vhdl/bladerf_debug_p.vhd]
|
||||
vcom -work nuand -2008 [file join $root ./vhdl/ramp.vhd]
|
||||
vcom -work nuand -2008 [file join $root ./vhdl/bladerf_p.vhd]
|
||||
vcom -work nuand -2008 [file join $root ./vhdl/bladerf.vhd]
|
||||
|
||||
vcom -work nuand -2008 [file join $root ./vhdl/tb/bladerf_tb.vhd]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ set altera_ip [file normalize [file join $here ../../ip/altera]]
|
|||
set adi_ip [file normalize [file join $here ../../ip/analogdevicesinc]]
|
||||
set nuand_ip [file normalize [file join $here ../../ip/nuand]]
|
||||
|
||||
# Platform packages
|
||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf_p.vhd]]
|
||||
|
||||
# Top level entity and pin constraints
|
||||
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf.vhd]]
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
|
|||
vcom -work nuand -2008 ../vhdl/fx3_gpif.vhd
|
||||
|
||||
vcom -work nuand -2008 ../vhdl/bladerf.vhd
|
||||
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd
|
||||
vcom -work nuand -2008 ../vhdl/bladerf-hosted.vhd
|
||||
|
||||
vcom -work nuand -2008 ../vhdl/tb/bladerf_tb.vhd
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ library altera_mf ;
|
|||
use altera_mf.altera_mf_components.all ;
|
||||
|
||||
library work ;
|
||||
use work.bladerf_p.all;
|
||||
use work.fifo_readwrite_p.all;
|
||||
use work.adsb_decoder_p.all ;
|
||||
|
||||
architecture adsb_bladerf of bladerf is
|
||||
|
|
@ -35,63 +37,23 @@ architecture adsb_bladerf of bladerf is
|
|||
attribute noprune : boolean ;
|
||||
attribute keep : boolean ;
|
||||
|
||||
component nios_system is
|
||||
port (
|
||||
clk_clk : in std_logic := 'X'; -- clk
|
||||
reset_reset_n : in std_logic := 'X'; -- reset_n
|
||||
dac_MISO : in std_logic := 'X'; -- MISO
|
||||
dac_MOSI : out std_logic; -- MOSI
|
||||
dac_SCLK : out std_logic; -- SCLK
|
||||
dac_SS_n : out std_logic_vector(1 downto 0); -- SS_n
|
||||
spi_MISO : in std_logic := 'X'; -- MISO
|
||||
spi_MOSI : out std_logic; -- MOSI
|
||||
spi_SCLK : out std_logic; -- SCLK
|
||||
spi_SS_n : out std_logic; -- SS_n
|
||||
oc_i2c_scl_pad_o : out std_logic;
|
||||
oc_i2c_scl_padoen_o : out std_logic;
|
||||
oc_i2c_sda_pad_i : in std_logic;
|
||||
oc_i2c_sda_pad_o : out std_logic;
|
||||
oc_i2c_sda_padoen_o : out std_logic;
|
||||
oc_i2c_arst_i : in std_logic;
|
||||
oc_i2c_scl_pad_i : in std_logic;
|
||||
gpio_export : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X');
|
||||
xb_gpio_out_port : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_dir_export : out std_logic_vector(31 downto 0);
|
||||
command_serial_in : in std_logic ;
|
||||
command_serial_out : out std_logic ;
|
||||
correction_rx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
correction_tx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
rx_tamer_ts_sync_in : in std_logic;
|
||||
rx_tamer_ts_sync_out : out std_logic ;
|
||||
rx_tamer_ts_pps : in std_logic ;
|
||||
rx_tamer_ts_clock : in std_logic ;
|
||||
rx_tamer_ts_reset : in std_logic;
|
||||
rx_tamer_ts_time : out std_logic_vector(63 downto 0) ;
|
||||
tx_tamer_ts_sync_in : in std_logic;
|
||||
tx_tamer_ts_sync_out : out std_logic ;
|
||||
tx_tamer_ts_pps : in std_logic ;
|
||||
tx_tamer_ts_clock : in std_logic ;
|
||||
tx_tamer_ts_reset : in std_logic;
|
||||
tx_tamer_ts_time : out std_logic_vector(63 downto 0);
|
||||
vctcxo_tamer_tune_ref : in std_logic;
|
||||
vctcxo_tamer_vctcxo_clock : in std_logic
|
||||
);
|
||||
end component;
|
||||
|
||||
alias sys_rst is fx3_ctl(7) ;
|
||||
alias tx_clock is c4_tx_clock ;
|
||||
alias rx_clock is lms_rx_clock_out ;
|
||||
|
||||
constant NUM_MIMO_STREAMS : natural := 1;
|
||||
|
||||
-- Can be set from libbladeRF using bladerf_set_rx_mux()
|
||||
type rx_mux_mode_t is (RX_MUX_NORMAL, RX_MUX_12BIT_COUNTER, RX_MUX_32BIT_COUNTER, RX_MUX_ENTROPY, RX_MUX_DIGITAL_LOOPBACK) ;
|
||||
|
||||
signal rx_mux_sel : unsigned(2 downto 0) ;
|
||||
signal rx_mux_mode : rx_mux_mode_t ;
|
||||
|
||||
signal \80MHz\ : std_logic ;
|
||||
signal \80MHz locked\ : std_logic ;
|
||||
|
||||
signal nios_gpio : std_logic_vector(31 downto 0) ;
|
||||
signal nios_gpio : nios_gpio_t;
|
||||
signal nios_gpo_slv : std_logic_vector(31 downto 0);
|
||||
|
||||
signal nios_xb_gpio_in : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_out : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_dir : std_logic_vector(31 downto 0) ;
|
||||
|
|
@ -108,47 +70,14 @@ architecture adsb_bladerf of bladerf is
|
|||
signal i2c_sda_out : std_logic ;
|
||||
signal i2c_sda_oen : std_logic ;
|
||||
|
||||
type fifo_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(127 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(9 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(11 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : fifo_t ;
|
||||
|
||||
type meta_fifo_rx_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(127 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(4 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(6 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : rx_fifo_t ;
|
||||
signal tx_sample_fifo : tx_fifo_t ;
|
||||
signal rx_loopback_fifo : loopback_fifo_t ;
|
||||
signal tx_meta_fifo : meta_fifo_tx_t ;
|
||||
signal rx_meta_fifo : meta_fifo_rx_t ;
|
||||
|
||||
signal sys_rst_sync : std_logic ;
|
||||
signal sys_rst_80M : std_logic ;
|
||||
|
||||
signal usb_speed : std_logic ;
|
||||
signal usb_speed_rx : std_logic ;
|
||||
|
|
@ -188,7 +117,6 @@ architecture adsb_bladerf of bladerf is
|
|||
signal fx3_ctl_oe : std_logic_vector(12 downto 0) ;
|
||||
|
||||
signal rx_overflow_led : std_logic ;
|
||||
signal rx_overflow_count : unsigned(63 downto 0) ;
|
||||
|
||||
signal lms_rx_data_reg : signed(11 downto 0) ;
|
||||
signal lms_rx_iq_select_reg : std_logic ;
|
||||
|
|
@ -208,8 +136,6 @@ architecture adsb_bladerf of bladerf is
|
|||
signal nios_sclk : std_logic;
|
||||
signal nios_ss_n : std_logic_vector(1 downto 0);
|
||||
|
||||
signal xb_mode : std_logic_vector(1 downto 0);
|
||||
|
||||
signal correction_valid : std_logic;
|
||||
|
||||
signal correction_rx_phase : signed(15 downto 0);--to_signed(integer(round(real(2**Q_SCALE) * PHASE_OFFSET)),DC_WIDTH);
|
||||
|
|
@ -221,7 +147,6 @@ architecture adsb_bladerf of bladerf is
|
|||
constant FPGA_DC_CORRECTION : signed(15 downto 0) := to_signed(integer(0), 16);
|
||||
|
||||
signal fx3_pclk_pll : std_logic ;
|
||||
signal fx3_pll_locked : std_logic ;
|
||||
|
||||
signal timestamp_req : std_logic ;
|
||||
signal timestamp_ack : std_logic ;
|
||||
|
|
@ -254,14 +179,14 @@ begin
|
|||
port map (
|
||||
inclk0 => c4_clock,
|
||||
c0 => \80MHz\,
|
||||
locked => \80MHz locked\
|
||||
locked => open
|
||||
) ;
|
||||
|
||||
U_fx3_pll : entity work.fx3_pll
|
||||
port map (
|
||||
inclk0 => fx3_pclk,
|
||||
c0 => fx3_pclk_pll,
|
||||
locked => fx3_pll_locked
|
||||
locked => open
|
||||
) ;
|
||||
|
||||
-- Cross domain synchronizer chains
|
||||
|
|
@ -271,7 +196,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed
|
||||
) ;
|
||||
|
||||
|
|
@ -281,7 +206,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed_rx
|
||||
) ;
|
||||
|
||||
|
|
@ -292,7 +217,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(8+i),
|
||||
async => nios_gpio.o.rx_mux_sel(i),
|
||||
sync => rx_mux_sel(i)
|
||||
) ;
|
||||
end generate ;
|
||||
|
|
@ -303,7 +228,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_fx3
|
||||
) ;
|
||||
|
||||
|
|
@ -313,12 +238,10 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_rx
|
||||
) ;
|
||||
|
||||
xb_mode <= nios_gpio(31 downto 30);
|
||||
|
||||
U_sys_reset_sync : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
|
|
@ -329,6 +252,16 @@ begin
|
|||
sync => sys_rst_sync
|
||||
) ;
|
||||
|
||||
U_80M_reset_sync : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
OUTPUT_LEVEL => '1'
|
||||
) port map (
|
||||
clock => \80MHz\,
|
||||
async => sys_rst,
|
||||
sync => sys_rst_80M
|
||||
) ;
|
||||
|
||||
U_rx_clock_reset : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
|
|
@ -376,6 +309,9 @@ begin
|
|||
rx_meta_fifo.wclock <= rx_clock ;
|
||||
rx_meta_fifo.rclock <= fx3_pclk_pll ;
|
||||
U_rx_meta_fifo : entity work.rx_meta_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => META_FIFO_RX_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => rx_meta_fifo.aclr,
|
||||
data => rx_meta_fifo.wdata,
|
||||
|
|
@ -663,8 +599,8 @@ begin
|
|||
|
||||
fx3_ctl_in <= fx3_ctl ;
|
||||
|
||||
command_serial_in <= fx3_uart_txd when sys_rst_sync = '0' else '1' ;
|
||||
fx3_uart_rxd <= command_serial_out when sys_rst_sync = '0' else 'Z' ;
|
||||
command_serial_in <= fx3_uart_txd when sys_rst_80M = '0' else '1' ;
|
||||
fx3_uart_rxd <= command_serial_out when sys_rst_80M = '0' else 'Z' ;
|
||||
|
||||
-- NIOS control system for si5338, vctcxo trim and lms control
|
||||
U_nios_system : component nios_system
|
||||
|
|
@ -679,7 +615,7 @@ begin
|
|||
spi_MOSI => lms_sdio,
|
||||
spi_SCLK => lms_sclk,
|
||||
spi_SS_n => lms_sen,
|
||||
gpio_export => nios_gpio,
|
||||
gpio_export => nios_gpo_slv,
|
||||
xb_gpio_in_port => nios_xb_gpio_in,
|
||||
xb_gpio_out_port => nios_xb_gpio_out,
|
||||
xb_gpio_dir_export => nios_xb_gpio_dir,
|
||||
|
|
@ -710,12 +646,18 @@ begin
|
|||
vctcxo_tamer_vctcxo_clock => c4_clock
|
||||
) ;
|
||||
|
||||
-- Unpack the Nios general-purpose outputs into a record
|
||||
nios_gpio.o <= unpack(nios_gpo_slv);
|
||||
|
||||
-- Readback of Nios general-purpose outputs
|
||||
nios_gpio.i.gpo_readback <= nios_gpio.o;
|
||||
|
||||
xb_gpio_direction : process(all)
|
||||
begin
|
||||
for i in 0 to 31 loop
|
||||
if (xb_gpio_dir(i) = '1') then
|
||||
nios_xb_gpio_in(i) <= nios_xb_gpio_out(i);
|
||||
if (xb_mode = "10" and i + 1 = 2) then
|
||||
if (nios_gpio.o.xb_mode = "10" and i + 1 = 2) then
|
||||
exp_gpio(i+1) <= nios_ss_n(1);
|
||||
elsif (i + 1 /= 1) then
|
||||
exp_gpio(i+1) <= nios_xb_gpio_out(i);
|
||||
|
|
@ -731,18 +673,18 @@ begin
|
|||
end loop ;
|
||||
end process ;
|
||||
|
||||
nios_gpio(20 downto 19) <= nios_ss_n;
|
||||
nios_gpio(22 downto 21) <= xb_mode;
|
||||
nios_gpio.i.nios_ss_n <= nios_ss_n;
|
||||
nios_gpio.i.xb_mode2 <= nios_gpio.o.xb_mode;
|
||||
|
||||
dac_cs_selection : process(all)
|
||||
begin
|
||||
dac_sclk <= nios_sclk ;
|
||||
dac_sdi <= nios_sdio ;
|
||||
nios_sdo <= dac_sdo ;
|
||||
if( xb_mode = "00" ) then
|
||||
if( nios_gpio.o.xb_mode = "00" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
dac_csx <= nios_ss_n(0);
|
||||
elsif( xb_mode = "10" ) then
|
||||
elsif( nios_gpio.o.xb_mode = "10" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
if (nios_ss_n(1 downto 0) = "10") then --
|
||||
dac_csx <= '0';
|
||||
|
|
@ -776,17 +718,17 @@ begin
|
|||
end if ;
|
||||
end process ;
|
||||
|
||||
led(1) <= led1_blink when nios_gpio(15) = '0' else not nios_gpio(12);
|
||||
led(1) <= led1_blink when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(1);
|
||||
led(2) <= '1' ;
|
||||
led(3) <= rx_overflow_led when nios_gpio(15) = '0' else not nios_gpio(14);
|
||||
led(3) <= rx_overflow_led when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(3);
|
||||
|
||||
lms_reset <= nios_gpio(0) ;
|
||||
lms_reset <= nios_gpio.o.lms_reset;
|
||||
|
||||
lms_rx_enable <= nios_gpio(1) ;
|
||||
lms_tx_enable <= nios_gpio(2) ;
|
||||
lms_rx_enable <= nios_gpio.o.lms_rx_enable;
|
||||
lms_tx_enable <= nios_gpio.o.lms_tx_enable;
|
||||
|
||||
lms_tx_v <= nios_gpio(4 downto 3) ;
|
||||
lms_rx_v <= nios_gpio(6 downto 5) ;
|
||||
lms_tx_v <= nios_gpio.o.lms_tx_v;
|
||||
lms_rx_v <= nios_gpio.o.lms_rx_v;
|
||||
|
||||
-- CTS and the SPI CSx are tied to the same signal. When we are in reset, allow for SPI accesses
|
||||
fx3_uart_cts <= '1' when sys_rst_sync = '0' else 'Z' ;
|
||||
|
|
@ -843,4 +785,3 @@ begin
|
|||
) ;
|
||||
|
||||
end architecture ; -- arch
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ library ieee ;
|
|||
use ieee.math_complex.all ;
|
||||
|
||||
library work;
|
||||
use work.bladerf_p.all;
|
||||
use work.fifo_readwrite_p.all;
|
||||
|
||||
architecture atsc_tx of bladerf is
|
||||
|
|
@ -32,69 +33,28 @@ architecture atsc_tx of bladerf is
|
|||
attribute noprune : boolean ;
|
||||
attribute keep : boolean ;
|
||||
|
||||
component nios_system is
|
||||
port (
|
||||
clk_clk : in std_logic := 'X'; -- clk
|
||||
reset_reset_n : in std_logic := 'X'; -- reset_n
|
||||
dac_MISO : in std_logic := 'X'; -- MISO
|
||||
dac_MOSI : out std_logic; -- MOSI
|
||||
dac_SCLK : out std_logic; -- SCLK
|
||||
dac_SS_n : out std_logic_vector(1 downto 0); -- SS_n
|
||||
spi_MISO : in std_logic := 'X'; -- MISO
|
||||
spi_MOSI : out std_logic; -- MOSI
|
||||
spi_SCLK : out std_logic; -- SCLK
|
||||
spi_SS_n : out std_logic; -- SS_n
|
||||
oc_i2c_scl_pad_o : out std_logic;
|
||||
oc_i2c_scl_padoen_o : out std_logic;
|
||||
oc_i2c_sda_pad_i : in std_logic;
|
||||
oc_i2c_sda_pad_o : out std_logic;
|
||||
oc_i2c_sda_padoen_o : out std_logic;
|
||||
oc_i2c_arst_i : in std_logic;
|
||||
oc_i2c_scl_pad_i : in std_logic;
|
||||
gpio_export : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X');
|
||||
xb_gpio_out_port : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_dir_export : out std_logic_vector(31 downto 0);
|
||||
command_serial_in : in std_logic ;
|
||||
command_serial_out : out std_logic ;
|
||||
correction_rx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
correction_tx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
rx_tamer_ts_sync_in : in std_logic;
|
||||
rx_tamer_ts_sync_out : out std_logic ;
|
||||
rx_tamer_ts_pps : in std_logic ;
|
||||
rx_tamer_ts_clock : in std_logic ;
|
||||
rx_tamer_ts_reset : in std_logic;
|
||||
rx_tamer_ts_time : out std_logic_vector(63 downto 0) ;
|
||||
tx_tamer_ts_sync_in : in std_logic;
|
||||
tx_tamer_ts_sync_out : out std_logic ;
|
||||
tx_tamer_ts_pps : in std_logic ;
|
||||
tx_tamer_ts_clock : in std_logic ;
|
||||
tx_tamer_ts_reset : in std_logic;
|
||||
tx_tamer_ts_time : out std_logic_vector(63 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
alias sys_rst is fx3_ctl(7) ;
|
||||
alias tx_clock is c4_tx_clock ;
|
||||
alias rx_clock is lms_rx_clock_out ;
|
||||
|
||||
constant NUM_MIMO_STREAMS : natural := 1;
|
||||
|
||||
-- Can be set from libbladeRF using bladerf_set_rx_mux()
|
||||
type rx_mux_mode_t is (RX_MUX_NORMAL, RX_MUX_12BIT_COUNTER, RX_MUX_32BIT_COUNTER, RX_MUX_ENTROPY, RX_MUX_DIGITAL_LOOPBACK) ;
|
||||
|
||||
signal rx_mux_sel : unsigned(2 downto 0) ;
|
||||
signal rx_mux_mode : rx_mux_mode_t ;
|
||||
|
||||
signal \80MHz\ : std_logic ;
|
||||
signal \80MHz locked\ : std_logic ;
|
||||
|
||||
signal nios_gpio : std_logic_vector(31 downto 0) := x"0000_00d7" ;
|
||||
signal nios_gpio : nios_gpio_t;
|
||||
signal nios_gpo_slv : std_logic_vector(31 downto 0) := x"0000_00d7";
|
||||
|
||||
signal nios_xb_gpio_in : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_out : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_dir : std_logic_vector(31 downto 0) ;
|
||||
signal xb_gpio_dir : std_logic_vector(31 downto 0) ;
|
||||
|
||||
|
||||
signal correction_rx_phase_gain : std_logic_vector(31 downto 0);
|
||||
signal correction_tx_phase_gain : std_logic_vector(31 downto 0);
|
||||
|
||||
|
|
@ -106,68 +66,14 @@ architecture atsc_tx of bladerf is
|
|||
signal i2c_sda_out : std_logic ;
|
||||
signal i2c_sda_oen : std_logic ;
|
||||
|
||||
type fifo_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(31 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(11 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(11 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : fifo_t ;
|
||||
signal tx_sample_fifo : fifo_t ;
|
||||
|
||||
type meta_fifo_tx_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(31 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(4 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(127 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(2 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : rx_fifo_t ;
|
||||
signal tx_sample_fifo : tx_fifo_t ;
|
||||
signal rx_loopback_fifo : loopback_fifo_t ;
|
||||
signal tx_meta_fifo : meta_fifo_tx_t ;
|
||||
|
||||
type meta_fifo_rx_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(127 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(4 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(6 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_meta_fifo : meta_fifo_rx_t ;
|
||||
|
||||
signal sys_rst_sync : std_logic ;
|
||||
signal sys_rst_80M : std_logic ;
|
||||
|
||||
signal usb_speed : std_logic ;
|
||||
signal usb_speed_rx : std_logic ;
|
||||
|
|
@ -221,10 +127,8 @@ architecture atsc_tx of bladerf is
|
|||
signal fx3_ctl_oe : std_logic_vector(12 downto 0) ;
|
||||
|
||||
signal tx_underflow_led : std_logic ;
|
||||
signal tx_underflow_count : unsigned(63 downto 0) ;
|
||||
|
||||
signal rx_overflow_led : std_logic ;
|
||||
signal rx_overflow_count : unsigned(63 downto 0) ;
|
||||
|
||||
signal lms_rx_data_reg : signed(11 downto 0) ;
|
||||
signal lms_rx_iq_select_reg : std_logic ;
|
||||
|
|
@ -244,8 +148,6 @@ architecture atsc_tx of bladerf is
|
|||
signal nios_sclk : std_logic;
|
||||
signal nios_ss_n : std_logic_vector(1 downto 0);
|
||||
|
||||
signal xb_mode : std_logic_vector(1 downto 0);
|
||||
|
||||
signal correction_valid : std_logic;
|
||||
|
||||
signal correction_tx_phase : signed(15 downto 0);--to_signed(integer(round(real(2**Q_SCALE) * PHASE_OFFSET)),DC_WIDTH);
|
||||
|
|
@ -259,7 +161,6 @@ architecture atsc_tx of bladerf is
|
|||
constant FPGA_DC_CORRECTION : signed(15 downto 0) := to_signed(integer(0), 16);
|
||||
|
||||
signal fx3_pclk_pll : std_logic ;
|
||||
signal fx3_pll_locked : std_logic ;
|
||||
|
||||
signal timestamp_req : std_logic ;
|
||||
signal timestamp_ack : std_logic ;
|
||||
|
|
@ -288,14 +189,14 @@ begin
|
|||
port map (
|
||||
inclk0 => c4_clock,
|
||||
c0 => \80MHz\,
|
||||
locked => \80MHz locked\
|
||||
locked => open
|
||||
) ;
|
||||
|
||||
U_fx3_pll : entity work.fx3_pll
|
||||
port map (
|
||||
inclk0 => fx3_pclk,
|
||||
c0 => fx3_pclk_pll,
|
||||
locked => fx3_pll_locked
|
||||
locked => open
|
||||
) ;
|
||||
|
||||
-- Cross domain synchronizer chains
|
||||
|
|
@ -305,7 +206,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed
|
||||
) ;
|
||||
|
||||
|
|
@ -315,7 +216,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed_rx
|
||||
) ;
|
||||
|
||||
|
|
@ -325,7 +226,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => tx_clock,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed_tx
|
||||
) ;
|
||||
|
||||
|
|
@ -336,7 +237,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(8+i),
|
||||
async => nios_gpio.o.rx_mux_sel(i),
|
||||
sync => rx_mux_sel(i)
|
||||
) ;
|
||||
end generate ;
|
||||
|
|
@ -347,7 +248,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_fx3
|
||||
) ;
|
||||
|
||||
|
|
@ -357,7 +258,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => tx_clock,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_tx
|
||||
) ;
|
||||
|
||||
|
|
@ -367,12 +268,10 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_rx
|
||||
) ;
|
||||
|
||||
xb_mode <= nios_gpio(31 downto 30);
|
||||
|
||||
U_sys_reset_sync : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
|
|
@ -383,6 +282,16 @@ begin
|
|||
sync => sys_rst_sync
|
||||
) ;
|
||||
|
||||
U_80M_reset_sync : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
OUTPUT_LEVEL => '1'
|
||||
) port map (
|
||||
clock => \80MHz\,
|
||||
async => sys_rst,
|
||||
sync => sys_rst_80M
|
||||
) ;
|
||||
|
||||
U_tx_reset : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
|
|
@ -428,6 +337,9 @@ begin
|
|||
tx_sample_fifo.wclock <= fx3_pclk_pll ;
|
||||
tx_sample_fifo.rclock <= tx_clock ;
|
||||
U_tx_sample_fifo : entity work.tx_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => TX_FIFO_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => tx_sample_fifo.aclr,
|
||||
data => tx_sample_fifo.wdata,
|
||||
|
|
@ -449,6 +361,9 @@ begin
|
|||
tx_meta_fifo.wclock <= fx3_pclk_pll ;
|
||||
tx_meta_fifo.rclock <= tx_clock ;
|
||||
U_tx_meta_fifo : entity work.tx_meta_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => META_FIFO_TX_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => tx_meta_fifo.aclr,
|
||||
data => tx_meta_fifo.wdata,
|
||||
|
|
@ -469,6 +384,9 @@ begin
|
|||
rx_sample_fifo.wclock <= rx_clock ;
|
||||
rx_sample_fifo.rclock <= fx3_pclk_pll ;
|
||||
U_rx_sample_fifo : entity work.rx_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => RX_FIFO_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => rx_sample_fifo.aclr,
|
||||
data => rx_sample_fifo.wdata,
|
||||
|
|
@ -490,6 +408,9 @@ begin
|
|||
rx_meta_fifo.wclock <= rx_clock ;
|
||||
rx_meta_fifo.rclock <= fx3_pclk_pll ;
|
||||
U_rx_meta_fifo : entity work.rx_meta_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => META_FIFO_RX_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => rx_meta_fifo.aclr,
|
||||
data => rx_meta_fifo.wdata,
|
||||
|
|
@ -554,6 +475,13 @@ begin
|
|||
|
||||
-- Sample bridges
|
||||
U_fifo_writer : entity work.fifo_writer
|
||||
generic map (
|
||||
NUM_STREAMS => NUM_MIMO_STREAMS,
|
||||
FIFO_USEDW_WIDTH => rx_sample_fifo.wused'length,
|
||||
FIFO_DATA_WIDTH => rx_sample_fifo.wdata'length,
|
||||
META_FIFO_USEDW_WIDTH => rx_meta_fifo.wused'length,
|
||||
META_FIFO_DATA_WIDTH => rx_meta_fifo.wdata'length
|
||||
)
|
||||
port map (
|
||||
clock => rx_clock,
|
||||
reset => rx_reset,
|
||||
|
|
@ -578,7 +506,7 @@ begin
|
|||
in_samples => rx_samples,
|
||||
|
||||
overflow_led => rx_overflow_led,
|
||||
overflow_count => rx_overflow_count,
|
||||
overflow_count => open,
|
||||
overflow_duration => x"ffff"
|
||||
) ;
|
||||
|
||||
|
|
@ -609,6 +537,14 @@ begin
|
|||
);
|
||||
|
||||
U_fifo_reader : entity work.fifo_reader
|
||||
generic map (
|
||||
NUM_STREAMS => NUM_MIMO_STREAMS,
|
||||
FIFO_READ_THROTTLE => 1, -- TODO: can this be 0 ?
|
||||
FIFO_USEDW_WIDTH => tx_sample_fifo.rused'length,
|
||||
FIFO_DATA_WIDTH => tx_sample_fifo.rdata'length,
|
||||
META_FIFO_USEDW_WIDTH => tx_meta_fifo.rused'length,
|
||||
META_FIFO_DATA_WIDTH => tx_meta_fifo.rdata'length
|
||||
)
|
||||
port map (
|
||||
clock => tx_clock,
|
||||
reset => tx_reset,
|
||||
|
|
@ -632,7 +568,7 @@ begin
|
|||
out_samples => open,
|
||||
|
||||
underflow_led => tx_underflow_led,
|
||||
underflow_count => tx_underflow_count,
|
||||
underflow_count => open,
|
||||
underflow_duration => x"ffff"
|
||||
) ;
|
||||
|
||||
|
|
@ -778,6 +714,7 @@ begin
|
|||
begin
|
||||
if( sys_rst_sync = '1' ) then
|
||||
fx3_gpif <= (others =>'Z') ;
|
||||
fx3_gpif_in <= (others =>'0') ;
|
||||
elsif( rising_edge(fx3_pclk_pll) ) then
|
||||
fx3_gpif_in <= fx3_gpif ;
|
||||
if( fx3_gpif_oe = '1' ) then
|
||||
|
|
@ -794,8 +731,8 @@ begin
|
|||
|
||||
fx3_ctl_in <= fx3_ctl ;
|
||||
|
||||
command_serial_in <= fx3_uart_txd when sys_rst_sync = '0' else '1' ;
|
||||
fx3_uart_rxd <= command_serial_out when sys_rst_sync = '0' else 'Z' ;
|
||||
command_serial_in <= fx3_uart_txd when sys_rst_80M = '0' else '1' ;
|
||||
fx3_uart_rxd <= command_serial_out when sys_rst_80M = '0' else 'Z' ;
|
||||
|
||||
-- NIOS control system for si5338, vctcxo trim and lms control
|
||||
U_nios_system : component nios_system
|
||||
|
|
@ -810,7 +747,7 @@ begin
|
|||
spi_MOSI => lms_sdio,
|
||||
spi_SCLK => lms_sclk,
|
||||
spi_SS_n => lms_sen,
|
||||
gpio_export => nios_gpio,
|
||||
gpio_export => nios_gpo_slv,
|
||||
xb_gpio_in_port => nios_xb_gpio_in,
|
||||
xb_gpio_out_port => nios_xb_gpio_out,
|
||||
xb_gpio_dir_export => nios_xb_gpio_dir,
|
||||
|
|
@ -836,15 +773,23 @@ begin
|
|||
tx_tamer_ts_pps => '0',
|
||||
tx_tamer_ts_clock => tx_clock,
|
||||
tx_tamer_ts_reset => tx_ts_reset,
|
||||
unsigned(tx_tamer_ts_time) => tx_timestamp
|
||||
unsigned(tx_tamer_ts_time) => tx_timestamp,
|
||||
vctcxo_tamer_tune_ref => ref_vctcxo_tune,
|
||||
vctcxo_tamer_vctcxo_clock => c4_clock
|
||||
) ;
|
||||
|
||||
xb_gpio_direction_proc : for i in 0 to 31 generate
|
||||
process(xb_gpio_dir, nios_xb_gpio_out, nios_xb_gpio_in, xb_mode, nios_ss_n)
|
||||
-- Unpack the Nios general-purpose outputs into a record
|
||||
nios_gpio.o <= unpack(nios_gpo_slv);
|
||||
|
||||
-- Readback of Nios general-purpose outputs
|
||||
nios_gpio.i.gpo_readback <= nios_gpio.o;
|
||||
|
||||
xb_gpio_direction : process(all)
|
||||
begin
|
||||
for i in 0 to 31 loop
|
||||
if (xb_gpio_dir(i) = '1') then
|
||||
nios_xb_gpio_in(i) <= nios_xb_gpio_out(i);
|
||||
if (xb_mode = "10" and i + 1 = 2) then
|
||||
if (nios_gpio.o.xb_mode = "10" and i + 1 = 2) then
|
||||
exp_gpio(i+1) <= nios_ss_n(1);
|
||||
elsif (i + 1 /= 1) then
|
||||
exp_gpio(i+1) <= nios_xb_gpio_out(i);
|
||||
|
|
@ -857,22 +802,22 @@ begin
|
|||
exp_gpio(i + 1) <= 'Z';
|
||||
end if;
|
||||
end if;
|
||||
end loop ;
|
||||
end process;
|
||||
end generate ;
|
||||
|
||||
nios_gpio(20 downto 19) <= nios_ss_n;
|
||||
nios_gpio(22 downto 21) <= xb_mode;
|
||||
nios_gpio.i.nios_ss_n <= nios_ss_n;
|
||||
nios_gpio.i.xb_mode2 <= nios_gpio.o.xb_mode;
|
||||
|
||||
process(all)
|
||||
begin
|
||||
if( xb_mode = "00" ) then
|
||||
if( nios_gpio.o.xb_mode = "00" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
dac_sclk <= nios_sclk;
|
||||
dac_csx <= nios_ss_n(0);
|
||||
nios_sdo <= dac_sdo;
|
||||
dac_sdi <= nios_sdio;
|
||||
-- missing 30-32
|
||||
elsif( xb_mode = "10" ) then
|
||||
elsif( nios_gpio.o.xb_mode = "10" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
if (nios_ss_n(1 downto 0) = "10") then --
|
||||
dac_sclk <= nios_sclk;
|
||||
|
|
@ -903,21 +848,22 @@ begin
|
|||
count := count - 1 ;
|
||||
if( count = 0 ) then
|
||||
count := 100_000_00 ;
|
||||
led(1) <= not led(1) ;
|
||||
led1_blink <= not led1_blink;
|
||||
end if ;
|
||||
end if ;
|
||||
end process ;
|
||||
|
||||
led(2) <= tx_underflow_led ;
|
||||
led(3) <= rx_overflow_led ;
|
||||
led(1) <= led1_blink when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(1);
|
||||
led(2) <= tx_underflow_led when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(2);
|
||||
led(3) <= rx_overflow_led when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(3);
|
||||
|
||||
lms_reset <= nios_gpio(0) ;
|
||||
lms_reset <= nios_gpio.o.lms_reset;
|
||||
|
||||
lms_rx_enable <= nios_gpio(1) ;
|
||||
lms_tx_enable <= nios_gpio(2) ;
|
||||
lms_rx_enable <= nios_gpio.o.lms_rx_enable;
|
||||
lms_tx_enable <= nios_gpio.o.lms_tx_enable;
|
||||
|
||||
lms_tx_v <= nios_gpio(4 downto 3) ;
|
||||
lms_rx_v <= nios_gpio(6 downto 5) ;
|
||||
lms_tx_v <= nios_gpio.o.lms_tx_v;
|
||||
lms_rx_v <= nios_gpio.o.lms_rx_v;
|
||||
|
||||
-- CTS and the SPI CSx are tied to the same signal. When we are in reset, allow for SPI accesses
|
||||
fx3_uart_cts <= '1' when sys_rst_sync = '0' else 'Z' ;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ library ieee ;
|
|||
use ieee.math_complex.all ;
|
||||
|
||||
library work;
|
||||
use work.bladerf_p.all;
|
||||
use work.fifo_readwrite_p.all;
|
||||
|
||||
architecture hosted_bladerf of bladerf is
|
||||
|
|
@ -32,63 +33,6 @@ architecture hosted_bladerf of bladerf is
|
|||
attribute noprune : boolean ;
|
||||
attribute keep : boolean ;
|
||||
|
||||
component nios_system is
|
||||
port (
|
||||
clk_clk : in std_logic := 'X'; -- clk
|
||||
reset_reset_n : in std_logic := 'X'; -- reset_n
|
||||
dac_MISO : in std_logic := 'X'; -- MISO
|
||||
dac_MOSI : out std_logic; -- MOSI
|
||||
dac_SCLK : out std_logic; -- SCLK
|
||||
dac_SS_n : out std_logic_vector(1 downto 0); -- SS_n
|
||||
spi_MISO : in std_logic := 'X'; -- MISO
|
||||
spi_MOSI : out std_logic; -- MOSI
|
||||
spi_SCLK : out std_logic; -- SCLK
|
||||
spi_SS_n : out std_logic; -- SS_n
|
||||
oc_i2c_scl_pad_o : out std_logic;
|
||||
oc_i2c_scl_padoen_o : out std_logic;
|
||||
oc_i2c_sda_pad_i : in std_logic;
|
||||
oc_i2c_sda_pad_o : out std_logic;
|
||||
oc_i2c_sda_padoen_o : out std_logic;
|
||||
oc_i2c_arst_i : in std_logic;
|
||||
oc_i2c_scl_pad_i : in std_logic;
|
||||
gpio_export : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X');
|
||||
xb_gpio_out_port : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_dir_export : out std_logic_vector(31 downto 0);
|
||||
command_serial_in : in std_logic ;
|
||||
command_serial_out : out std_logic ;
|
||||
correction_rx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
correction_tx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
rx_tamer_ts_sync_in : in std_logic;
|
||||
rx_tamer_ts_sync_out : out std_logic ;
|
||||
rx_tamer_ts_pps : in std_logic ;
|
||||
rx_tamer_ts_clock : in std_logic ;
|
||||
rx_tamer_ts_reset : in std_logic;
|
||||
rx_tamer_ts_time : out std_logic_vector(63 downto 0) ;
|
||||
tx_tamer_ts_sync_in : in std_logic;
|
||||
tx_tamer_ts_sync_out : out std_logic ;
|
||||
tx_tamer_ts_pps : in std_logic ;
|
||||
tx_tamer_ts_clock : in std_logic ;
|
||||
tx_tamer_ts_reset : in std_logic;
|
||||
tx_tamer_ts_time : out std_logic_vector(63 downto 0);
|
||||
vctcxo_tamer_tune_ref : in std_logic;
|
||||
vctcxo_tamer_vctcxo_clock : in std_logic;
|
||||
tx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
|
||||
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
|
||||
rx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
|
||||
rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
|
||||
arbiter_request : in std_logic_vector(1 downto 0) := (others => '0');
|
||||
arbiter_granted : out std_logic_vector(1 downto 0) := (others => '0');
|
||||
arbiter_ack : in std_logic_vector(1 downto 0) := (others => '0');
|
||||
agc_dc_i_max_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_i_mid_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_i_min_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_max_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_mid_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_min_export : out std_logic_vector(15 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
alias sys_rst is fx3_ctl(7) ;
|
||||
alias tx_clock is c4_tx_clock ;
|
||||
alias rx_clock is lms_rx_clock_out ;
|
||||
|
|
@ -103,7 +47,9 @@ architecture hosted_bladerf of bladerf is
|
|||
|
||||
signal \80MHz\ : std_logic ;
|
||||
|
||||
signal nios_gpio : std_logic_vector(31 downto 0) ;
|
||||
signal nios_gpio : nios_gpio_t;
|
||||
signal nios_gpo_slv : std_logic_vector(31 downto 0);
|
||||
|
||||
signal nios_xb_gpio_in : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_out : std_logic_vector(31 downto 0) ;
|
||||
signal nios_xb_gpio_dir : std_logic_vector(31 downto 0) ;
|
||||
|
|
@ -120,66 +66,10 @@ architecture hosted_bladerf of bladerf is
|
|||
signal i2c_sda_out : std_logic ;
|
||||
signal i2c_sda_oen : std_logic ;
|
||||
|
||||
type fifo_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(31 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(11 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(11 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : fifo_t ;
|
||||
signal tx_sample_fifo : fifo_t ;
|
||||
signal rx_loopback_fifo : fifo_t ;
|
||||
|
||||
type meta_fifo_tx_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(31 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(4 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(127 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(2 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_sample_fifo : rx_fifo_t ;
|
||||
signal tx_sample_fifo : tx_fifo_t ;
|
||||
signal rx_loopback_fifo : loopback_fifo_t ;
|
||||
signal tx_meta_fifo : meta_fifo_tx_t ;
|
||||
|
||||
type meta_fifo_rx_t is record
|
||||
aclr : std_logic ;
|
||||
|
||||
wclock : std_logic ;
|
||||
wdata : std_logic_vector(127 downto 0) ;
|
||||
wreq : std_logic ;
|
||||
wempty : std_logic ;
|
||||
wfull : std_logic ;
|
||||
wused : std_logic_vector(4 downto 0) ;
|
||||
|
||||
rclock : std_logic ;
|
||||
rdata : std_logic_vector(31 downto 0) ;
|
||||
rreq : std_logic ;
|
||||
rempty : std_logic ;
|
||||
rfull : std_logic ;
|
||||
rused : std_logic_vector(6 downto 0) ;
|
||||
end record ;
|
||||
|
||||
signal rx_meta_fifo : meta_fifo_rx_t ;
|
||||
|
||||
signal sys_rst_sync : std_logic ;
|
||||
|
|
@ -262,8 +152,6 @@ architecture hosted_bladerf of bladerf is
|
|||
signal nios_sclk : std_logic;
|
||||
signal nios_ss_n : std_logic_vector(1 downto 0);
|
||||
|
||||
signal xb_mode : std_logic_vector(1 downto 0);
|
||||
|
||||
signal correction_valid : std_logic;
|
||||
|
||||
signal correction_tx_phase : signed(15 downto 0);--to_signed(integer(round(real(2**Q_SCALE) * PHASE_OFFSET)),DC_WIDTH);
|
||||
|
|
@ -394,7 +282,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed
|
||||
) ;
|
||||
|
||||
|
|
@ -404,7 +292,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed_rx
|
||||
) ;
|
||||
|
||||
|
|
@ -414,7 +302,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => tx_clock,
|
||||
async => nios_gpio(7),
|
||||
async => nios_gpio.o.usb_speed,
|
||||
sync => usb_speed_tx
|
||||
) ;
|
||||
|
||||
|
|
@ -425,7 +313,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(8+i),
|
||||
async => nios_gpio.o.rx_mux_sel(i),
|
||||
sync => rx_mux_sel(i)
|
||||
) ;
|
||||
end generate ;
|
||||
|
|
@ -437,7 +325,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(12),
|
||||
async => nios_gpio.o.agc_en,
|
||||
sync => agc_en
|
||||
) ;
|
||||
|
||||
|
|
@ -448,7 +336,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => fx3_pclk_pll,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_fx3
|
||||
) ;
|
||||
|
||||
|
|
@ -458,7 +346,7 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => tx_clock,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_tx
|
||||
) ;
|
||||
|
||||
|
|
@ -468,12 +356,10 @@ begin
|
|||
) port map (
|
||||
reset => '0',
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(16),
|
||||
async => nios_gpio.o.meta_en,
|
||||
sync => meta_en_rx
|
||||
) ;
|
||||
|
||||
xb_mode <= nios_gpio(31 downto 30);
|
||||
|
||||
U_sys_reset_sync : entity work.reset_synchronizer
|
||||
generic map (
|
||||
INPUT_LEVEL => '1',
|
||||
|
|
@ -570,7 +456,7 @@ begin
|
|||
) port map (
|
||||
reset => rx_reset,
|
||||
clock => rx_clock,
|
||||
async => nios_gpio(5),
|
||||
async => nios_gpio.o.agc_en,
|
||||
sync => agc_band_sel
|
||||
) ;
|
||||
|
||||
|
|
@ -579,6 +465,9 @@ begin
|
|||
tx_sample_fifo.wclock <= fx3_pclk_pll ;
|
||||
tx_sample_fifo.rclock <= tx_clock ;
|
||||
U_tx_sample_fifo : entity work.tx_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => TX_FIFO_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => tx_sample_fifo.aclr,
|
||||
data => tx_sample_fifo.wdata,
|
||||
|
|
@ -601,6 +490,9 @@ begin
|
|||
tx_meta_fifo.wclock <= fx3_pclk_pll ;
|
||||
tx_meta_fifo.rclock <= tx_clock ;
|
||||
U_tx_meta_fifo : entity work.tx_meta_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => META_FIFO_TX_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => tx_meta_fifo.aclr,
|
||||
data => tx_meta_fifo.wdata,
|
||||
|
|
@ -621,6 +513,9 @@ begin
|
|||
rx_sample_fifo.wclock <= rx_clock ;
|
||||
rx_sample_fifo.rclock <= fx3_pclk_pll ;
|
||||
U_rx_sample_fifo : entity work.rx_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => RX_FIFO_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => "not"(pclk_rx_enable),
|
||||
data => rx_sample_fifo.wdata,
|
||||
|
|
@ -642,6 +537,9 @@ begin
|
|||
rx_meta_fifo.wclock <= rx_clock ;
|
||||
rx_meta_fifo.rclock <= fx3_pclk_pll ;
|
||||
U_rx_meta_fifo : entity work.rx_meta_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => META_FIFO_RX_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => "not"(pclk_rx_enable),
|
||||
data => rx_meta_fifo.wdata,
|
||||
|
|
@ -669,6 +567,9 @@ begin
|
|||
rx_loopback_fifo.rreq <= '1' when rx_loopback_enabled = '1' and rx_loopback_fifo.rempty = '0' else '0' ;
|
||||
|
||||
U_rx_loopack_fifo : entity work.lb_fifo
|
||||
generic map (
|
||||
LPM_NUMWORDS => LOOPBACK_FIFO_LENGTH
|
||||
)
|
||||
port map (
|
||||
aclr => rx_loopback_fifo.aclr,
|
||||
data => rx_loopback_fifo.wdata,
|
||||
|
|
@ -761,6 +662,13 @@ begin
|
|||
|
||||
-- Sample bridges
|
||||
U_fifo_writer : entity work.fifo_writer
|
||||
generic map (
|
||||
NUM_STREAMS => NUM_MIMO_STREAMS,
|
||||
FIFO_USEDW_WIDTH => rx_sample_fifo.wused'length,
|
||||
FIFO_DATA_WIDTH => rx_sample_fifo.wdata'length,
|
||||
META_FIFO_USEDW_WIDTH => rx_meta_fifo.wused'length,
|
||||
META_FIFO_DATA_WIDTH => rx_meta_fifo.wdata'length
|
||||
)
|
||||
port map (
|
||||
clock => rx_clock,
|
||||
reset => rx_reset,
|
||||
|
|
@ -897,6 +805,14 @@ begin
|
|||
end process ;
|
||||
|
||||
U_fifo_reader : entity work.fifo_reader
|
||||
generic map (
|
||||
NUM_STREAMS => NUM_MIMO_STREAMS,
|
||||
FIFO_READ_THROTTLE => 1, -- TODO: can this be 0 ?
|
||||
FIFO_USEDW_WIDTH => tx_sample_fifo.rused'length,
|
||||
FIFO_DATA_WIDTH => tx_sample_fifo.rdata'length,
|
||||
META_FIFO_USEDW_WIDTH => tx_meta_fifo.rused'length,
|
||||
META_FIFO_DATA_WIDTH => tx_meta_fifo.rdata'length
|
||||
)
|
||||
port map (
|
||||
clock => tx_clock,
|
||||
reset => tx_reset,
|
||||
|
|
@ -1129,7 +1045,7 @@ begin
|
|||
spi_MOSI => nios_lms_sdio,
|
||||
spi_SCLK => nios_lms_sclk,
|
||||
spi_SS_n => nios_lms_sen,
|
||||
gpio_export => nios_gpio,
|
||||
gpio_export => nios_gpo_slv,
|
||||
xb_gpio_in_port => nios_xb_gpio_in,
|
||||
xb_gpio_out_port => nios_xb_gpio_out,
|
||||
xb_gpio_dir_export => nios_xb_gpio_dir,
|
||||
|
|
@ -1173,12 +1089,18 @@ begin
|
|||
agc_dc_q_min_export => corr_dc_q_min
|
||||
) ;
|
||||
|
||||
-- Unpack the Nios general-purpose outputs into a record
|
||||
nios_gpio.o <= unpack(nios_gpo_slv);
|
||||
|
||||
-- Readback of Nios general-purpose outputs
|
||||
nios_gpio.i.gpo_readback <= nios_gpio.o;
|
||||
|
||||
xb_gpio_direction : process(all)
|
||||
begin
|
||||
for i in 0 to 31 loop
|
||||
if (xb_gpio_dir(i) = '1') then
|
||||
nios_xb_gpio_in(i) <= nios_xb_gpio_out(i);
|
||||
if (xb_mode = "10" and i + 1 = 2) then
|
||||
if (nios_gpio.o.xb_mode = "10" and i + 1 = 2) then
|
||||
exp_gpio(i+1) <= nios_ss_n(1);
|
||||
elsif (i + 1 /= 1) then
|
||||
exp_gpio(i+1) <= nios_xb_gpio_out(i);
|
||||
|
|
@ -1194,18 +1116,18 @@ begin
|
|||
end loop ;
|
||||
end process ;
|
||||
|
||||
nios_gpio(20 downto 19) <= nios_ss_n;
|
||||
nios_gpio(22 downto 21) <= xb_mode;
|
||||
nios_gpio.i.nios_ss_n <= nios_ss_n;
|
||||
nios_gpio.i.xb_mode2 <= nios_gpio.o.xb_mode;
|
||||
|
||||
dac_cs_selection : process(all)
|
||||
begin
|
||||
dac_sclk <= nios_sclk ;
|
||||
dac_sdi <= nios_sdio ;
|
||||
nios_sdo <= dac_sdo ;
|
||||
if( xb_mode = "00" ) then
|
||||
if( nios_gpio.o.xb_mode = "00" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
dac_csx <= nios_ss_n(0);
|
||||
elsif( xb_mode = "10" ) then
|
||||
elsif( nios_gpio.o.xb_mode = "10" ) then
|
||||
xb_gpio_dir <= nios_xb_gpio_dir(31 downto 0);
|
||||
if (nios_ss_n(1 downto 0) = "10") then --
|
||||
dac_csx <= '0';
|
||||
|
|
@ -1239,18 +1161,18 @@ begin
|
|||
end if ;
|
||||
end process ;
|
||||
|
||||
led(1) <= led1_blink when nios_gpio(15) = '0' else not nios_gpio(12);
|
||||
led(2) <= tx_underflow_led when nios_gpio(15) = '0' else not nios_gpio(13);
|
||||
led(3) <= rx_overflow_led when nios_gpio(15) = '0' else not nios_gpio(14);
|
||||
led(1) <= led1_blink when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(1);
|
||||
led(2) <= tx_underflow_led when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(2);
|
||||
led(3) <= rx_overflow_led when nios_gpio.o.led_mode = '0' else not nios_gpio.o.leds(3);
|
||||
|
||||
lms_reset <= nios_gpio(0) ;
|
||||
lms_reset <= nios_gpio.o.lms_reset;
|
||||
|
||||
lms_rx_enable_sig <= nios_gpio(1) ;
|
||||
lms_rx_enable <= nios_gpio(1) ;
|
||||
lms_tx_enable <= nios_gpio(2) ;
|
||||
lms_rx_enable_sig <= nios_gpio.o.lms_rx_enable;
|
||||
lms_rx_enable <= nios_gpio.o.lms_rx_enable;
|
||||
lms_tx_enable <= nios_gpio.o.lms_tx_enable;
|
||||
|
||||
lms_tx_v <= nios_gpio(4 downto 3) ;
|
||||
lms_rx_v <= nios_gpio(6 downto 5) ;
|
||||
lms_tx_v <= nios_gpio.o.lms_tx_v;
|
||||
lms_rx_v <= nios_gpio.o.lms_rx_v;
|
||||
|
||||
-- CTS and the SPI CSx are tied to the same signal. When we are in reset, allow for SPI accesses
|
||||
fx3_uart_cts <= '1' when sys_rst_sync = '0' else 'Z' ;
|
||||
|
|
@ -1320,4 +1242,3 @@ begin
|
|||
) ;
|
||||
|
||||
end architecture ; -- arch
|
||||
|
||||
|
|
|
|||
441
hdl/fpga/platforms/bladerf/vhdl/bladerf_p.vhd
Normal file
441
hdl/fpga/platforms/bladerf/vhdl/bladerf_p.vhd
Normal file
|
|
@ -0,0 +1,441 @@
|
|||
-- Copyright (c) 2017 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;
|
||||
|
||||
library work;
|
||||
use work.common_dcfifo_p.all;
|
||||
|
||||
package bladerf_p is
|
||||
|
||||
-- ========================================================================
|
||||
-- Component declarations for Verilog files
|
||||
-- ========================================================================
|
||||
|
||||
--component system_pll is
|
||||
-- port (
|
||||
-- refclk : in std_logic;
|
||||
-- rst : in std_logic;
|
||||
-- outclk_0 : out std_logic;
|
||||
-- locked : out std_logic
|
||||
-- );
|
||||
--end component;
|
||||
--
|
||||
--component fx3_pll is
|
||||
-- port (
|
||||
-- refclk : in std_logic;
|
||||
-- rst : in std_logic;
|
||||
-- outclk_0 : out std_logic;
|
||||
-- locked : out std_logic
|
||||
-- );
|
||||
--end component;
|
||||
|
||||
component nios_system is
|
||||
port (
|
||||
clk_clk : in std_logic := 'X'; -- clk
|
||||
reset_reset_n : in std_logic := 'X'; -- reset_n
|
||||
dac_MISO : in std_logic := 'X'; -- MISO
|
||||
dac_MOSI : out std_logic; -- MOSI
|
||||
dac_SCLK : out std_logic; -- SCLK
|
||||
dac_SS_n : out std_logic_vector(1 downto 0); -- SS_n
|
||||
spi_MISO : in std_logic := 'X'; -- MISO
|
||||
spi_MOSI : out std_logic; -- MOSI
|
||||
spi_SCLK : out std_logic; -- SCLK
|
||||
spi_SS_n : out std_logic; -- SS_n
|
||||
oc_i2c_scl_pad_o : out std_logic;
|
||||
oc_i2c_scl_padoen_o : out std_logic;
|
||||
oc_i2c_sda_pad_i : in std_logic;
|
||||
oc_i2c_sda_pad_o : out std_logic;
|
||||
oc_i2c_sda_padoen_o : out std_logic;
|
||||
oc_i2c_arst_i : in std_logic;
|
||||
oc_i2c_scl_pad_i : in std_logic;
|
||||
gpio_export : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X');
|
||||
xb_gpio_out_port : out std_logic_vector(31 downto 0);
|
||||
xb_gpio_dir_export : out std_logic_vector(31 downto 0);
|
||||
command_serial_in : in std_logic ;
|
||||
command_serial_out : out std_logic ;
|
||||
correction_rx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
correction_tx_phase_gain_export : out std_logic_vector(31 downto 0);
|
||||
rx_tamer_ts_sync_in : in std_logic;
|
||||
rx_tamer_ts_sync_out : out std_logic ;
|
||||
rx_tamer_ts_pps : in std_logic ;
|
||||
rx_tamer_ts_clock : in std_logic ;
|
||||
rx_tamer_ts_reset : in std_logic;
|
||||
rx_tamer_ts_time : out std_logic_vector(63 downto 0) ;
|
||||
tx_tamer_ts_sync_in : in std_logic;
|
||||
tx_tamer_ts_sync_out : out std_logic ;
|
||||
tx_tamer_ts_pps : in std_logic ;
|
||||
tx_tamer_ts_clock : in std_logic ;
|
||||
tx_tamer_ts_reset : in std_logic;
|
||||
tx_tamer_ts_time : out std_logic_vector(63 downto 0);
|
||||
vctcxo_tamer_tune_ref : in std_logic;
|
||||
vctcxo_tamer_vctcxo_clock : in std_logic;
|
||||
tx_trigger_ctl_in_port : in std_logic_vector(7 downto 0) := (others => '0');
|
||||
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
|
||||
rx_trigger_ctl_in_port : in std_logic_vector(7 downto 0) := (others => '0');
|
||||
rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
|
||||
arbiter_request : in std_logic_vector(1 downto 0) := (others => '0');
|
||||
arbiter_granted : out std_logic_vector(1 downto 0) := (others => '0');
|
||||
arbiter_ack : in std_logic_vector(1 downto 0) := (others => '0');
|
||||
agc_dc_i_max_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_i_mid_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_i_min_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_max_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_mid_export : out std_logic_vector(15 downto 0);
|
||||
agc_dc_q_min_export : out std_logic_vector(15 downto 0)
|
||||
);
|
||||
end component;
|
||||
|
||||
-- ========================================================================
|
||||
-- TYPEDEFS
|
||||
-- ========================================================================
|
||||
|
||||
constant TX_FIFO_WWIDTH : natural := 32; -- write side data width
|
||||
constant TX_FIFO_RWIDTH : natural := 32; -- read side data width
|
||||
constant TX_FIFO_LENGTH : natural := 4096; -- samples
|
||||
|
||||
constant RX_FIFO_WWIDTH : natural := 32; -- write side data width
|
||||
constant RX_FIFO_RWIDTH : natural := 32; -- read side data width
|
||||
constant RX_FIFO_LENGTH : natural := 4096; -- samples
|
||||
|
||||
constant LOOPBACK_FIFO_WWIDTH : natural := 32; -- write side data width
|
||||
constant LOOPBACK_FIFO_RWIDTH : natural := 32; -- read side data width
|
||||
constant LOOPBACK_FIFO_LENGTH : natural := 512; -- samples
|
||||
|
||||
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_LENGTH : natural := 32; -- 32-bit words
|
||||
|
||||
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_LENGTH : natural := 32; -- 32-bit words
|
||||
|
||||
type tx_fifo_t is record
|
||||
aclr : std_logic;
|
||||
|
||||
wclock : std_logic;
|
||||
wdata : std_logic_vector(TX_FIFO_WWIDTH-1 downto 0);
|
||||
wreq : std_logic;
|
||||
wempty : std_logic;
|
||||
wfull : std_logic;
|
||||
wused : std_logic_vector(compute_wrusedw_high(TX_FIFO_LENGTH, "OFF") downto 0);
|
||||
|
||||
rclock : std_logic;
|
||||
rdata : std_logic_vector(TX_FIFO_RWIDTH-1 downto 0);
|
||||
rreq : std_logic;
|
||||
rempty : std_logic;
|
||||
rfull : std_logic;
|
||||
rused : std_logic_vector(compute_rdusedw_high(TX_FIFO_LENGTH, TX_FIFO_WWIDTH,
|
||||
TX_FIFO_RWIDTH, "OFF") downto 0);
|
||||
end record;
|
||||
|
||||
type rx_fifo_t is record
|
||||
aclr : std_logic;
|
||||
|
||||
wclock : std_logic;
|
||||
wdata : std_logic_vector(RX_FIFO_WWIDTH-1 downto 0);
|
||||
wreq : std_logic;
|
||||
wempty : std_logic;
|
||||
wfull : std_logic;
|
||||
wused : std_logic_vector(compute_wrusedw_high(RX_FIFO_LENGTH, "OFF") downto 0);
|
||||
|
||||
rclock : std_logic;
|
||||
rdata : std_logic_vector(RX_FIFO_RWIDTH-1 downto 0);
|
||||
rreq : std_logic;
|
||||
rempty : std_logic;
|
||||
rfull : std_logic;
|
||||
rused : std_logic_vector(compute_rdusedw_high(RX_FIFO_LENGTH, RX_FIFO_WWIDTH,
|
||||
RX_FIFO_RWIDTH, "OFF") downto 0);
|
||||
end record;
|
||||
|
||||
type loopback_fifo_t is record
|
||||
aclr : std_logic;
|
||||
|
||||
wclock : std_logic;
|
||||
wdata : std_logic_vector(LOOPBACK_FIFO_WWIDTH-1 downto 0);
|
||||
wreq : std_logic;
|
||||
wempty : std_logic;
|
||||
wfull : std_logic;
|
||||
wused : std_logic_vector(compute_wrusedw_high(LOOPBACK_FIFO_LENGTH, "OFF") downto 0);
|
||||
|
||||
rclock : std_logic;
|
||||
rdata : std_logic_vector(LOOPBACK_FIFO_RWIDTH-1 downto 0);
|
||||
rreq : std_logic;
|
||||
rempty : std_logic;
|
||||
rfull : std_logic;
|
||||
rused : std_logic_vector(compute_rdusedw_high(LOOPBACK_FIFO_LENGTH, LOOPBACK_FIFO_WWIDTH,
|
||||
LOOPBACK_FIFO_RWIDTH, "OFF") downto 0);
|
||||
end record;
|
||||
|
||||
type meta_fifo_tx_t is record
|
||||
aclr : std_logic;
|
||||
|
||||
wclock : std_logic;
|
||||
wdata : std_logic_vector(META_FIFO_TX_WWIDTH-1 downto 0);
|
||||
wreq : std_logic;
|
||||
wempty : std_logic;
|
||||
wfull : std_logic;
|
||||
wused : std_logic_vector(compute_wrusedw_high(META_FIFO_TX_LENGTH, "OFF") downto 0);
|
||||
|
||||
rclock : std_logic;
|
||||
rdata : std_logic_vector(META_FIFO_TX_RWIDTH-1 downto 0);
|
||||
rreq : std_logic;
|
||||
rempty : std_logic;
|
||||
rfull : std_logic;
|
||||
rused : std_logic_vector(compute_rdusedw_high(META_FIFO_TX_LENGTH, META_FIFO_TX_WWIDTH,
|
||||
META_FIFO_TX_RWIDTH, "OFF") downto 0);
|
||||
end record;
|
||||
|
||||
type meta_fifo_rx_t is record
|
||||
aclr : std_logic;
|
||||
|
||||
wclock : std_logic;
|
||||
wdata : std_logic_vector(META_FIFO_RX_WWIDTH-1 downto 0);
|
||||
wreq : std_logic;
|
||||
wempty : std_logic;
|
||||
wfull : std_logic;
|
||||
wused : std_logic_vector(compute_wrusedw_high(META_FIFO_RX_LENGTH, "OFF") downto 0);
|
||||
|
||||
rclock : std_logic;
|
||||
rdata : std_logic_vector(META_FIFO_RX_RWIDTH-1 downto 0);
|
||||
rreq : std_logic;
|
||||
rempty : std_logic;
|
||||
rfull : std_logic;
|
||||
rused : std_logic_vector(compute_rdusedw_high(META_FIFO_RX_LENGTH, META_FIFO_RX_WWIDTH,
|
||||
META_FIFO_RX_RWIDTH, "OFF") downto 0);
|
||||
end record;
|
||||
|
||||
type nios_gpo_t is record
|
||||
xb_mode : std_logic_vector(1 downto 0);
|
||||
agc_en : std_logic;
|
||||
agc_band_sel : std_logic;
|
||||
meta_en : std_logic;
|
||||
led_mode : std_logic;
|
||||
leds : std_logic_vector(3 downto 1);
|
||||
rx_mux_sel : std_logic_vector(2 downto 0);
|
||||
usb_speed : std_logic;
|
||||
lms_rx_v : std_logic_vector(2 downto 1);
|
||||
lms_tx_v : std_logic_vector(2 downto 1);
|
||||
lms_tx_enable : std_logic;
|
||||
lms_rx_enable : std_logic;
|
||||
lms_reset : std_logic;
|
||||
end record;
|
||||
|
||||
type nios_gpi_t is record
|
||||
-- Why? Are these used by host at all?
|
||||
nios_ss_n : std_logic_vector(1 downto 0);
|
||||
xb_mode2 : std_logic_vector(1 downto 0);
|
||||
|
||||
-- Normal readback of Nios general-purpose outputs
|
||||
gpo_readback : nios_gpo_t;
|
||||
end record;
|
||||
|
||||
type nios_gpio_t is record
|
||||
i : nios_gpi_t;
|
||||
o : nios_gpo_t;
|
||||
end record;
|
||||
|
||||
|
||||
-- ========================================================================
|
||||
-- PACK FUNCTIONS -- pack a human-readable record/type into bits
|
||||
-- ========================================================================
|
||||
|
||||
function pack( x : nios_gpo_t ) return std_logic_vector;
|
||||
function pack( x : nios_gpi_t ) return std_logic_vector;
|
||||
--function pack( x : nios_gpio_t ) return std_logic_vector;
|
||||
|
||||
|
||||
-- ========================================================================
|
||||
-- UNPACK FUNCTIONS -- unpack bits into a human-readable record/type
|
||||
-- ========================================================================
|
||||
|
||||
function unpack( x : std_logic_vector(31 downto 0) ) return nios_gpo_t;
|
||||
|
||||
|
||||
-- ========================================================================
|
||||
-- TYPEDEF RESET CONSTANTS -- deferred to permit use of pack/unpack
|
||||
-- ========================================================================
|
||||
|
||||
constant TX_FIFO_T_DEFAULT : tx_fifo_t;
|
||||
constant RX_FIFO_T_DEFAULT : rx_fifo_t;
|
||||
constant LOOPBACK_FIFO_T_DEFAULT : loopback_fifo_t;
|
||||
constant META_FIFO_TX_T_DEFAULT : meta_fifo_tx_t;
|
||||
constant META_FIFO_RX_T_DEFAULT : meta_fifo_rx_t;
|
||||
|
||||
end package;
|
||||
|
||||
package body bladerf_p is
|
||||
|
||||
-- ========================================================================
|
||||
-- PACK FUNCTIONS
|
||||
-- ========================================================================
|
||||
|
||||
function pack( x : nios_gpo_t ) return std_logic_vector is
|
||||
variable rv : std_logic_vector(31 downto 0) := (others => '0');
|
||||
begin
|
||||
rv(31 downto 30) := x.xb_mode;
|
||||
-- AVAILABLE: x(29 downto 23);
|
||||
-- RESERVED: rv(22 downto 21) := x.xb_mode2; -- Why? Is this even needed?
|
||||
-- RESERVED: rv(20 downto 19) := x.nios_ss_n; -- Why? Is this even needed?
|
||||
--rv(18) := x.agc_en;
|
||||
--rv(17) := x.agc_band_sel;
|
||||
rv(16) := x.meta_en;
|
||||
rv(15) := x.led_mode;
|
||||
rv(14 downto 12) := x.leds;
|
||||
-- AVAILABLE: rv(11)
|
||||
rv(10 downto 8) := x.rx_mux_sel;
|
||||
rv(7) := x.usb_speed;
|
||||
rv(6 downto 5) := x.lms_rx_v;
|
||||
rv(4 downto 3) := x.lms_tx_v;
|
||||
rv(2) := x.lms_tx_enable;
|
||||
rv(1) := x.lms_rx_enable;
|
||||
rv(0) := x.lms_reset;
|
||||
return rv;
|
||||
end function;
|
||||
|
||||
function pack( x : nios_gpi_t ) return std_logic_vector is
|
||||
variable rv : std_logic_vector(31 downto 0) := (others => '0');
|
||||
begin
|
||||
-- Readback of outputs
|
||||
rv := pack(x.gpo_readback);
|
||||
-- Inputs
|
||||
rv(22 downto 21) := x.xb_mode2; -- Why? Is this even needed?
|
||||
rv(20 downto 19) := x.nios_ss_n; -- Why? Is this even needed?
|
||||
return rv;
|
||||
end function;
|
||||
|
||||
|
||||
-- ========================================================================
|
||||
-- UNPACK FUNCTIONS
|
||||
-- ========================================================================
|
||||
|
||||
function unpack( x : std_logic_vector(31 downto 0) ) return nios_gpo_t is
|
||||
variable rv : nios_gpo_t;
|
||||
begin
|
||||
rv.xb_mode := x(31 downto 30);
|
||||
-- AVAILABLE: x(29 downto 23);
|
||||
--rv.xb_mode2 := x(22 downto 21); -- Why? Is this even needed?
|
||||
--rv.nios_ss_n := x(20 downto 19); -- Why? Is this even needed?
|
||||
rv.agc_en := x(12); -- FIXME: overlaps leds(1) ... use x(18) instead?
|
||||
rv.agc_band_sel := x(5); -- FIXME: overlaps lms_rx_v(1) ... use x(17) instead?
|
||||
rv.meta_en := x(16);
|
||||
rv.led_mode := x(15);
|
||||
rv.leds := x(14 downto 12);
|
||||
-- Available: x(11)
|
||||
rv.rx_mux_sel := x(10 downto 8);
|
||||
rv.usb_speed := x(7);
|
||||
rv.lms_rx_v := x(6 downto 5);
|
||||
rv.lms_tx_v := x(4 downto 3);
|
||||
rv.lms_tx_enable := x(2);
|
||||
rv.lms_rx_enable := x(1);
|
||||
rv.lms_reset := x(0);
|
||||
return rv;
|
||||
end function;
|
||||
|
||||
|
||||
-- ========================================================================
|
||||
-- TYPEDEF RESET CONSTANTS
|
||||
-- ========================================================================
|
||||
|
||||
constant TX_FIFO_T_DEFAULT : tx_fifo_t := (
|
||||
aclr => '1',
|
||||
wclock => '0',
|
||||
wdata => (others => '0'),
|
||||
wreq => '0',
|
||||
wempty => '1',
|
||||
wfull => '0',
|
||||
wused => (others => '0'),
|
||||
rclock => '0',
|
||||
rdata => (others => '0'),
|
||||
rreq => '0',
|
||||
rempty => '1',
|
||||
rfull => '0',
|
||||
rused => (others => '0')
|
||||
);
|
||||
|
||||
constant RX_FIFO_T_DEFAULT : rx_fifo_t := (
|
||||
aclr => '1',
|
||||
wclock => '0',
|
||||
wdata => (others => '0'),
|
||||
wreq => '0',
|
||||
wempty => '1',
|
||||
wfull => '0',
|
||||
wused => (others => '0'),
|
||||
rclock => '0',
|
||||
rdata => (others => '0'),
|
||||
rreq => '0',
|
||||
rempty => '1',
|
||||
rfull => '0',
|
||||
rused => (others => '0')
|
||||
);
|
||||
|
||||
constant LOOPBACK_FIFO_T_DEFAULT : loopback_fifo_t := (
|
||||
aclr => '1',
|
||||
wclock => '0',
|
||||
wdata => (others => '0'),
|
||||
wreq => '0',
|
||||
wempty => '1',
|
||||
wfull => '0',
|
||||
wused => (others => '0'),
|
||||
rclock => '0',
|
||||
rdata => (others => '0'),
|
||||
rreq => '0',
|
||||
rempty => '1',
|
||||
rfull => '0',
|
||||
rused => (others => '0')
|
||||
);
|
||||
|
||||
constant META_FIFO_TX_T_DEFAULT : meta_fifo_tx_t := (
|
||||
aclr => '1',
|
||||
wclock => '0',
|
||||
wdata => (others => '0'),
|
||||
wreq => '0',
|
||||
wempty => '1',
|
||||
wfull => '0',
|
||||
wused => (others => '0'),
|
||||
rclock => '0',
|
||||
rdata => (others => '0'),
|
||||
rreq => '0',
|
||||
rempty => '1',
|
||||
rfull => '0',
|
||||
rused => (others => '0')
|
||||
);
|
||||
|
||||
constant META_FIFO_RX_T_DEFAULT : meta_fifo_rx_t := (
|
||||
aclr => '1',
|
||||
wclock => '0',
|
||||
wdata => (others => '0'),
|
||||
wreq => '0',
|
||||
wempty => '1',
|
||||
wfull => '0',
|
||||
wused => (others => '0'),
|
||||
rclock => '0',
|
||||
rdata => (others => '0'),
|
||||
rreq => '0',
|
||||
rempty => '1',
|
||||
rfull => '0',
|
||||
rused => (others => '0')
|
||||
);
|
||||
|
||||
end package body;
|
||||
Loading…
Add table
Add a link
Reference in a new issue