aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/include
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/microblaze/include')
-rw-r--r--firmware/microblaze/include/.gitignore2
-rw-r--r--firmware/microblaze/include/Makefile.am30
-rw-r--r--firmware/microblaze/include/compiler.h25
-rw-r--r--firmware/microblaze/include/net/.gitignore2
-rw-r--r--firmware/microblaze/include/net/Makefile.am23
-rw-r--r--firmware/microblaze/include/net/eth_mac_addr.h29
-rw-r--r--firmware/microblaze/include/net/padded_eth_hdr.h37
-rw-r--r--firmware/microblaze/include/net/socket_address.h41
-rw-r--r--firmware/microblaze/include/usrp2_clock_bits.h55
-rw-r--r--firmware/microblaze/include/usrp2_fpga_regs.h80
-rw-r--r--firmware/microblaze/include/usrp2_i2c_addr.h78
-rw-r--r--firmware/microblaze/include/usrp2_types.h105
-rw-r--r--firmware/microblaze/include/vrt/bits.h92
-rw-r--r--firmware/microblaze/include/vrt/types.h138
14 files changed, 737 insertions, 0 deletions
diff --git a/firmware/microblaze/include/.gitignore b/firmware/microblaze/include/.gitignore
new file mode 100644
index 000000000..b336cc7ce
--- /dev/null
+++ b/firmware/microblaze/include/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/firmware/microblaze/include/Makefile.am b/firmware/microblaze/include/Makefile.am
new file mode 100644
index 000000000..6afbbcd12
--- /dev/null
+++ b/firmware/microblaze/include/Makefile.am
@@ -0,0 +1,30 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = net
+
+noinst_HEADERS = \
+ usrp2_fpga_regs.h \
+ usrp2_i2c_addr.h \
+ usrp2_clock_bits.h \
+ usrp2_types.h \
+ vrt/bits.h \
+ vrt/types.h
diff --git a/firmware/microblaze/include/compiler.h b/firmware/microblaze/include/compiler.h
new file mode 100644
index 000000000..4fa9b49f8
--- /dev/null
+++ b/firmware/microblaze/include/compiler.h
@@ -0,0 +1,25 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Ettus Research LLC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_COMPILER_H
+#define INCLUDED_COMPILER_H
+
+// FIXME gcc specific.
+#define _AL4 __attribute__((aligned (4)))
+
+
+#endif /* INCLUDED_COMPILER_H */
diff --git a/firmware/microblaze/include/net/.gitignore b/firmware/microblaze/include/net/.gitignore
new file mode 100644
index 000000000..282522db0
--- /dev/null
+++ b/firmware/microblaze/include/net/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/firmware/microblaze/include/net/Makefile.am b/firmware/microblaze/include/net/Makefile.am
new file mode 100644
index 000000000..32b0bf9dc
--- /dev/null
+++ b/firmware/microblaze/include/net/Makefile.am
@@ -0,0 +1,23 @@
+#
+# Copyright 2010 Ettus Research LLC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+include $(top_srcdir)/Makefile.common
+
+noinst_HEADERS = \
+ eth_mac_addr.h \
+ padded_eth_hdr.h \
+ socket_address.h
diff --git a/firmware/microblaze/include/net/eth_mac_addr.h b/firmware/microblaze/include/net/eth_mac_addr.h
new file mode 100644
index 000000000..b44fb68f7
--- /dev/null
+++ b/firmware/microblaze/include/net/eth_mac_addr.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009 Ettus Research LLC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_ETH_MAC_ADDR_H
+#define INCLUDED_ETH_MAC_ADDR_H
+
+#include <stdint.h>
+
+// Ethernet MAC address
+
+typedef struct {
+ uint8_t addr[6];
+} eth_mac_addr_t;
+
+#endif /* INCLUDED_ETH_MAC_ADDR_H */
diff --git a/firmware/microblaze/include/net/padded_eth_hdr.h b/firmware/microblaze/include/net/padded_eth_hdr.h
new file mode 100644
index 000000000..df816734f
--- /dev/null
+++ b/firmware/microblaze/include/net/padded_eth_hdr.h
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,2010 Ettus Research LLC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_PADDED_ETH_HDR_H
+#define INCLUDED_PADDED_ETH_HDR_H
+
+#include <compiler.h>
+#include <net/eth_mac_addr.h>
+
+/*!
+ * \brief Standard 14-byte ethernet header plus two leading bytes of padding.
+ *
+ * This is what a buffer contains in line 1 when using the "slow mode"
+ */
+typedef struct {
+ uint16_t pad;
+ eth_mac_addr_t dst;
+ eth_mac_addr_t src;
+ uint16_t ethertype;
+} _AL4 padded_eth_hdr_t;
+
+
+#endif /* INCLUDED_PADDED_ETH_HDR_H */
diff --git a/firmware/microblaze/include/net/socket_address.h b/firmware/microblaze/include/net/socket_address.h
new file mode 100644
index 000000000..336f30a0c
--- /dev/null
+++ b/firmware/microblaze/include/net/socket_address.h
@@ -0,0 +1,41 @@
+/* -*- c -*- */
+/*
+ * Copyright 2010 Ettus Research LLC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_SOCKET_ADDRESS_H
+#define INCLUDED_SOCKET_ADDRESS_H
+
+#include <lwip/ip_addr.h>
+
+// port and address are in network byte order
+
+typedef struct socket_address {
+ unsigned short port;
+ struct ip_addr addr;
+} socket_address_t;
+
+static inline struct socket_address
+make_socket_address(struct ip_addr addr, int port)
+{
+ struct socket_address r;
+ r.port = port;
+ r.addr = addr;
+ return r;
+}
+
+
+
+#endif /* INCLUDED_SOCKET_ADDRESS_H */
diff --git a/firmware/microblaze/include/usrp2_clock_bits.h b/firmware/microblaze/include/usrp2_clock_bits.h
new file mode 100644
index 000000000..d2052e941
--- /dev/null
+++ b/firmware/microblaze/include/usrp2_clock_bits.h
@@ -0,0 +1,55 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_USRP2_CLOCK_BITS_H
+#define INCLUDED_USRP2_CLOCK_BITS_H
+
+#define _MC_WE_LOCK 0x0001
+#define _MC_MIMO_CLK_INPUT 0x0002 // else SMA input
+
+/*
+ * Derived masks (use these):
+ *
+ * We get our input from 1 of three places:
+ * Our free running oscilator, our SMA connector, or from the MIMO connector
+ */
+#define MC_WE_DONT_LOCK 0x0000
+#define MC_WE_LOCK_TO_SMA (_MC_WE_LOCK | 0)
+#define MC_WE_LOCK_TO_MIMO (_MC_WE_LOCK | _MC_MIMO_CLK_INPUT)
+
+/*
+ * Independent of the source of the clock, we may or may not drive our
+ * clock onto the mimo connector. Note that there are dedicated clock
+ * signals in each direction, so disaster doesn't occurs if we're
+ * unnecessarily providing clock.
+ */
+#define MC_PROVIDE_CLK_TO_MIMO 0x0004
+
+#define MC_REF_CLK_MASK 0x0f
+
+#define MC_PPS_SOURCE_SMA (0x00 << 4)
+#define MC_PPS_SOURCE_MIMO (0x01 << 4)
+
+#define MC_PPS_POLARITY_NEG (0x00 << 5)
+#define MC_PPS_POLARITY_POS (0x01 << 5)
+
+#endif /* INCLUDED_USRP2_CLOCK_BITS_H */
diff --git a/firmware/microblaze/include/usrp2_fpga_regs.h b/firmware/microblaze/include/usrp2_fpga_regs.h
new file mode 100644
index 000000000..b0f83df60
--- /dev/null
+++ b/firmware/microblaze/include/usrp2_fpga_regs.h
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_USRP2_FPGA_REGS_H
+#define INCLUDED_USSRP2_FPGA_REGS_H
+
+#include "usrp2_cdefs.h"
+
+__U2_BEGIN_DECLS
+
+// ----------------------------------------------------------------
+
+#define DSP_CORE_TX_BASE 128
+
+// DUC center frequency tuning word (phase increment)
+#define FR_TX_FREQ_0 (0 + DSP_CORE_TX_BASE)
+
+// I & Q output scaling, 16.0 format ((I_SCALE << 16) | Q_SCALE)
+#define FR_TX_SCALE_0 (1 + DSP_CORE_TX_BASE)
+
+// Tx interpolation rate (set to 1 less than desired rate)
+#define FR_TX_INTERP_RATE_0 (2 + DSP_CORE_TX_BASE)
+
+// Write 1 (actually anything) to clear tx state
+#define FR_TX_CLEAR_STATE_0 (3 + DSP_CORE_TX_BASE)
+
+// ----------------------------------------------------------------
+
+#define DSP_CORE_RX_BASE 160
+
+// DDC center frequency tuning word (phase increment)
+#define FR_RX_FREQ_0 (0 + DSP_CORE_RX_BASE)
+
+// I & Q input scaling, 16.0 format ((I_SCALE << 16) | Q_SCALE)
+#define FR_RX_SCALE_0 (1 + DSP_CORE_RX_BASE)
+
+// Rx decimation rate (set to 1 less than desired rate)
+#define FR_RX_DECIM_RATE_0 (2 + DSP_CORE_RX_BASE)
+
+// The next two registers concatenated are the Rx command register.
+//
+// Writing FR_RX_TIME_TO_RX_0 writes the concatenated value into the
+// cmd queue. Thus, if you're writing both, be sure to write
+// FR_RX_QTY_0 first.
+//
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | Timestamp |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+#define FR_RX_TIME_TO_RX (3 + DSP_CORE_RX_BASE)
+
+// 23-bits 9-bits
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | number_of_lines | lines_per_frame |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+#define FR_RX_QTY_0 (4 + DSP_CORE_RX_BASE)
+
+// write a 1 (anything actually) to clear the overrun
+#define FR_RX_CLR_OVERRUN_0 (5 + DSP_CORE_RX_BASE)
+
+
+__U2_END_DECLS
+
+#endif /* INCLUDED_USRP2_FPGA_REGS_H */
diff --git a/firmware/microblaze/include/usrp2_i2c_addr.h b/firmware/microblaze/include/usrp2_i2c_addr.h
new file mode 100644
index 000000000..46f5a7556
--- /dev/null
+++ b/firmware/microblaze/include/usrp2_i2c_addr.h
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_USRP2_I2C_ADDR_H
+#define INCLUDED_USRP2_I2C_ADDR_H
+
+// I2C addresses
+
+#define I2C_DEV_EEPROM 0x50 // 24LC02[45]: 7-bits 1010xxx
+
+#define I2C_ADDR_MBOARD (I2C_DEV_EEPROM | 0x0)
+#define I2C_ADDR_TX_A (I2C_DEV_EEPROM | 0x4)
+#define I2C_ADDR_RX_A (I2C_DEV_EEPROM | 0x5)
+
+
+// format of USRP2 motherboard rom
+// 00: 0x00 h/w rev (LSB)
+// 01: 0x00 h/w rev (MSB)
+// 02: 0x00 MAC addr 0
+// 03: 0x50 MAC addr 1
+// 04: 0xC2 MAC addr 2
+// 05: 0x85 MAC addr 3
+// 06: 0x3. MAC addr 4
+// 07: 0x.. MAC addr 5
+
+#define MBOARD_REV_LSB 0x00
+#define MBOARD_REV_MSB 0x01
+#define MBOARD_MAC_ADDR 0x02
+#define MBOARD_IP_ADDR 0x0C
+
+
+// format of daughterboard EEPROM
+// 00: 0xDB code for ``I'm a daughterboard''
+// 01: .. Daughterboard ID (LSB)
+// 02: .. Daughterboard ID (MSB)
+// 03: .. io bits 7-0 direction (bit set if it's an output from m'board)
+// 04: .. io bits 15-8 direction (bit set if it's an output from m'board)
+// 05: .. ADC0 DC offset correction (LSB)
+// 06: .. ADC0 DC offset correction (MSB)
+// 07: .. ADC1 DC offset correction (LSB)
+// 08: .. ADC1 DC offset correction (MSB)
+// ...
+// 1f: .. negative of the sum of bytes [0x00, 0x1e]
+
+#define DB_EEPROM_MAGIC 0x00
+#define DB_EEPROM_MAGIC_VALUE 0xDB
+#define DB_EEPROM_ID_LSB 0x01
+#define DB_EEPROM_ID_MSB 0x02
+#define DB_EEPROM_OE_LSB 0x03
+#define DB_EEPROM_OE_MSB 0x04
+#define DB_EEPROM_OFFSET_0_LSB 0x05 // offset correction for ADC or DAC 0
+#define DB_EEPROM_OFFSET_0_MSB 0x06
+#define DB_EEPROM_OFFSET_1_LSB 0x07 // offset correction for ADC or DAC 1
+#define DB_EEPROM_OFFSET_1_MSB 0x08
+#define DB_EEPROM_CHKSUM 0x1f
+
+#define DB_EEPROM_CLEN 0x20 // length of common portion of eeprom
+
+#define DB_EEPROM_CUSTOM_BASE DB_EEPROM_CLEN // first avail offset for
+ // daughterboard specific use
+
+#endif /* INCLUDED_USRP2_I2C_ADDR_H */
+
diff --git a/firmware/microblaze/include/usrp2_types.h b/firmware/microblaze/include/usrp2_types.h
new file mode 100644
index 000000000..fe45936f0
--- /dev/null
+++ b/firmware/microblaze/include/usrp2_types.h
@@ -0,0 +1,105 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_USRP2_TYPES_H
+#define INCLUDED_USRP2_TYPES_H
+
+#include <stdint.h>
+
+/*!
+ * \brief Fixed point representation of a frequency in Hertz (VITA-49 compatible)
+ *
+ * 64-bit two's complement, with the radix point 20 bits up from the bottom.
+ * Q44.20 format (20 bits to the right of the radix point)
+ *
+ * Values range from +/- 8.79 terahertz with a resolution of 0.95 microhertz.
+ */
+typedef int64_t u2_fxpt_freq_t;
+
+#define U2_FPF_RP 20 // location of radix point in u2_fxpt_freq_t
+
+// macro so we can init structs at compile time
+#define U2_DOUBLE_TO_FXPT_FREQ(f) (int64_t)((f) * (1LL << U2_FPF_RP))
+
+static inline u2_fxpt_freq_t
+u2_double_to_fxpt_freq(double f)
+{
+ return U2_DOUBLE_TO_FXPT_FREQ(f);
+}
+
+static inline int
+u2_fxpt_freq_round_to_int(u2_fxpt_freq_t fx)
+{
+ return (int)((fx+(1<<(U2_FPF_RP-1)))>>U2_FPF_RP);
+}
+
+static inline double
+u2_fxpt_freq_to_double(u2_fxpt_freq_t fx)
+{
+ return ((double) fx) * 1.0/(1 << U2_FPF_RP);
+}
+
+static inline uint32_t
+u2_fxpt_freq_hi(u2_fxpt_freq_t f)
+{
+ return ((f >> 32) & 0xffffffff);
+}
+
+static inline uint32_t
+u2_fxpt_freq_lo(u2_fxpt_freq_t f)
+{
+ return (f & 0xffffffff);
+}
+
+static inline u2_fxpt_freq_t
+u2_fxpt_freq_from_hilo(uint32_t hi, uint32_t lo)
+{
+ return (((u2_fxpt_freq_t) hi) << 32) | lo;
+}
+
+/*!
+ * \brief Fixed point representation of a gain in dB (VITA-49 compatible)
+ *
+ * 16-bit two's complement, with the radix point 7 bits up from the bottom.
+ * Q9.7 format (7 bits to the right of the radix point)
+ */
+typedef int16_t u2_fxpt_gain_t;
+
+#define U2_FPG_RP 7 // location of radix point in u2_fxpt_gain_t
+
+// macro so we can init structs at compile time
+#define U2_DOUBLE_TO_FXPT_GAIN(g) (int16_t)((g) * (1 << U2_FPG_RP))
+
+static inline u2_fxpt_gain_t
+u2_double_to_fxpt_gain(double g)
+{
+ return U2_DOUBLE_TO_FXPT_GAIN(g);
+}
+
+static inline float
+u2_fxpt_gain_to_double(u2_fxpt_gain_t fx)
+{
+ return ((double) fx) * 1.0/(1 << U2_FPG_RP);
+}
+
+static inline int
+u2_fxpt_gain_round_to_int(u2_fxpt_gain_t fx)
+{
+ return (int)((fx+(1<<(U2_FPG_RP-1)))>>U2_FPG_RP);
+}
+
+#endif /* INCLUDED_USRP2_TYPES_H */
diff --git a/firmware/microblaze/include/vrt/bits.h b/firmware/microblaze/include/vrt/bits.h
new file mode 100644
index 000000000..54eeec7b4
--- /dev/null
+++ b/firmware/microblaze/include/vrt/bits.h
@@ -0,0 +1,92 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_VRT_BITS_H
+#define INCLUDED_VRT_BITS_H
+
+#include <stdint.h>
+
+
+/* VRT Header bits */
+
+#define VRTH_PT_MASK (0xf << 28)
+#define VRTH_PT_IF_DATA_NO_SID (0x0 << 28) // IF-Data, no stream id
+#define VRTH_PT_IF_DATA_WITH_SID (0x1 << 28) // IF-Data, w/ stream id
+#define VRTH_PT_EXT_DATA_NO_SID (0x2 << 28)
+#define VRTH_PT_EXT_DATA_WITH_SID (0x3 << 28)
+#define VRTH_PT_IF_CONTEXT (0x4 << 28)
+#define VRTH_PT_EXT_CONTEXT (0x5 << 28)
+
+#define VRTH_HAS_CLASSID (1 << 27)
+#define VRTH_HAS_TRAILER (1 << 26) // Data pkts only
+#define VRTH_START_OF_BURST (1 << 25) // Data (Tx) pkts only
+#define VRTH_END_OF_BURST (1 << 24) // Data (Tx) pkts only
+#define VRTH_TSM (1 << 24) // Context pkts only
+
+#define VRTH_TSI_MASK (0x3 << 22)
+#define VRTH_TSI_NONE (0x0 << 22)
+#define VRTH_TSI_UTC (0x1 << 22)
+#define VRTH_TSI_GPS (0x2 << 22)
+#define VRTH_TSI_OTHER (0x3 << 22)
+
+#define VRTH_TSF_MASK (0x3 << 20)
+#define VRTH_TSF_NONE (0x0 << 20)
+#define VRTH_TSF_SAMPLE_CNT (0x1 << 20)
+#define VRTH_TSF_REAL_TIME_PS (0x2 << 20)
+#define VRTH_TSF_FREE_RUNNING (0x3 << 20)
+
+#define VRTH_PKT_CNT_SHIFT 16
+#define VRTH_PKT_CNT_MASK (0xf << 16)
+
+#define VRTH_PKT_SIZE_MASK 0xffff
+
+
+static inline int
+vrth_pkt_cnt(uint32_t h)
+{
+ return (h & VRTH_PKT_CNT_MASK) >> 16;
+}
+
+static inline int
+vrth_pkt_size(uint32_t h)
+{
+ return h & VRTH_PKT_SIZE_MASK;
+}
+
+/*
+ * Trailer bits
+ */
+#define TR_E (1 << 8)
+
+#define TR_ENABLE(x) ((x) << 20)
+#define TR_STATE(x) ((x) << 8)
+
+// Use these with TR_ENABLE and TR_STATE
+#define TR_CAL_TIME (1 << 11)
+#define TR_VALID_DATA (1 << 10)
+#define TR_REF_LOCK (1 << 9)
+#define TR_AGC (1 << 8)
+#define TR_DETECTED_SIG (1 << 7)
+#define TR_SPECTRAL_INVERSION (1 << 6)
+#define TR_OVER_RANGE (1 << 5)
+#define TR_SAMPLE_LOSS (1 << 4)
+#define TR_USER_3 (1 << 3)
+#define TR_USER_2 (1 << 2)
+#define TR_USER_1 (1 << 1)
+#define TR_USER_0 (1 << 0)
+
+#endif /* INCLUDED_VRT_BITS_H */
diff --git a/firmware/microblaze/include/vrt/types.h b/firmware/microblaze/include/vrt/types.h
new file mode 100644
index 000000000..edfa4ec37
--- /dev/null
+++ b/firmware/microblaze/include/vrt/types.h
@@ -0,0 +1,138 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_VRT_TYPES_H
+#define INCLUDED_VRT_TYPES_H
+
+#include <stdint.h>
+
+/* macros for dealing with fixed point numbers */
+#define _FXPT_C(_type, _x, _rp) ((_type)((_x)*(1ll << _rp)))
+#define _FXPT_TO_INT(_x, _one) (((_x) + ((_one)/2))/(_one))
+#define _FXPT_TO_DOUBLE(_x, _one) ((double)(_x) * (1.0/(_one)))
+
+/***********************************************************************
+ * The VRT Altitude Type (meters)
+ **********************************************************************/
+typedef int32_t vrt_altitude_t;
+#define VRT_ALTITUDE_RP 5
+#define VRT_ALTITUDE_C(_x) _FXPT_C(vrt_altitude_t, _x, VRT_ALTITUDE_RP)
+
+static inline vrt_altitude_t
+double_to_vrt_altitude(double num){
+ return VRT_ALTITUDE_C(num);
+}
+
+static inline int32_t
+vrt_altitude_round_to_int(vrt_altitude_t fx){
+ return _FXPT_TO_INT(fx, VRT_ALTITUDE_C(1));
+}
+
+static inline double
+vrt_altitude_to_double(vrt_altitude_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_ALTITUDE_C(1));
+}
+
+/***********************************************************************
+ * The VRT Geolocation Angle Type (degrees)
+ **********************************************************************/
+typedef int32_t vrt_geo_angle_t;
+#define VRT_GEO_ANGLE_RP 22
+#define VRT_GEO_ANGLE_C(_x) _FXPT_C(vrt_geo_angle_t, _x, VRT_GEO_ANGLE_RP)
+
+static inline vrt_geo_angle_t
+double_to_vrt_geo_angle(double num){
+ return VRT_GEO_ANGLE_C(num);
+}
+
+static inline int16_t
+vrt_geo_angle_round_to_int(vrt_geo_angle_t fx){
+ return _FXPT_TO_INT(fx, VRT_GEO_ANGLE_C(1));
+}
+
+static inline double
+vrt_geo_angle_to_double(vrt_geo_angle_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_GEO_ANGLE_C(1));
+}
+
+/***********************************************************************
+ * The VRT Frequency Type (Hz)
+ **********************************************************************/
+typedef int64_t vrt_freq_t;
+#define VRT_FREQ_RP 20
+#define VRT_FREQ_C(_x) _FXPT_C(vrt_freq_t, _x, VRT_FREQ_RP)
+
+static inline vrt_freq_t
+double_to_vrt_freq(double num){
+ return VRT_FREQ_C(num);
+}
+
+static inline int64_t
+vrt_freq_round_to_int(vrt_freq_t fx){
+ return _FXPT_TO_INT(fx, VRT_FREQ_C(1));
+}
+
+static inline double
+vrt_freq_to_double(vrt_freq_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_FREQ_C(1));
+}
+
+/***********************************************************************
+ * The VRT Gain Type (dB)
+ **********************************************************************/
+typedef int16_t vrt_gain_t;
+#define VRT_GAIN_RP 7
+#define VRT_GAIN_C(_x) _FXPT_C(vrt_gain_t, _x, VRT_GAIN_RP)
+
+static inline vrt_gain_t
+double_to_vrt_gain(double num){
+ return VRT_GAIN_C(num);
+}
+
+static inline int16_t
+vrt_gain_round_to_int(vrt_gain_t fx){
+ return _FXPT_TO_INT(fx, VRT_GAIN_C(1));
+}
+
+static inline double
+vrt_gain_to_double(vrt_gain_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_GAIN_C(1));
+}
+
+/***********************************************************************
+ * The VRT Temperature Type (Celcius)
+ **********************************************************************/
+typedef int16_t vrt_temp_t;
+#define VRT_TEMP_RP 6
+#define VRT_TEMP_C(_x) _FXPT_C(vrt_temp_t, _x, VRT_TEMP_RP)
+
+static inline vrt_temp_t
+double_to_vrt_temp(double num){
+ return VRT_TEMP_C(num);
+}
+
+static inline int16_t
+vrt_temp_round_to_int(vrt_temp_t fx){
+ return _FXPT_TO_INT(fx, VRT_TEMP_C(1));
+}
+
+static inline double
+vrt_temp_to_double(vrt_temp_t fx){
+ return _FXPT_TO_DOUBLE(fx, VRT_TEMP_C(1));
+}
+
+#endif /* INCLUDED_VRT_TYPES_H */