aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/gen_vrt.py
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/transport/gen_vrt.py')
-rwxr-xr-xhost/lib/transport/gen_vrt.py117
1 files changed, 59 insertions, 58 deletions
diff --git a/host/lib/transport/gen_vrt.py b/host/lib/transport/gen_vrt.py
index 8e0fce9ff..ad87b9972 100755
--- a/host/lib/transport/gen_vrt.py
+++ b/host/lib/transport/gen_vrt.py
@@ -61,20 +61,22 @@ using namespace uhd::transport;
#set $tsf_p = 0b01000
#set $tlr_p = 0b10000
-void vrt::pack_$(suffix)(
- const tx_metadata_t &metadata, //input
- boost::uint32_t *header_buff, //output
- size_t &num_header_words32, //output
- size_t num_payload_words32, //input
- size_t &num_packet_words32, //output
- size_t packet_count, //input
- double tick_rate //input
+static UHD_INLINE void pack_uint64_$(suffix)(boost::uint64_t num, boost::uint32_t *mem){
+ *(reinterpret_cast<boost::uint64_t *>(mem)) = $(XE_MACRO)(num);
+}
+
+void vrt::if_hdr_pack_$(suffix)(
+ boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
){
boost::uint32_t vrt_hdr_flags = 0;
boost::uint8_t pred = 0;
- if (metadata.has_stream_id) pred |= $hex($sid_p);
- if (metadata.has_time_spec) pred |= $hex($tsi_p | $tsf_p);
+ if (if_packet_info.has_sid) pred |= $hex($sid_p);
+ if (if_packet_info.has_cid) pred |= $hex($cid_p);
+ if (if_packet_info.has_tsi) pred |= $hex($tsi_p);
+ if (if_packet_info.has_tsf) pred |= $hex($tsf_p);
+ if (if_packet_info.has_tlr) pred |= $hex($tlr_p);
switch(pred){
#for $pred in range(2**5)
@@ -83,79 +85,71 @@ void vrt::pack_$(suffix)(
#set $flags = 0
########## Stream ID ##########
#if $pred & $sid_p
- header_buff[$num_header_words] = $(XE_MACRO)(metadata.stream_id);
+ packet_buff[$num_header_words] = $(XE_MACRO)(if_packet_info.sid);
#set $num_header_words += 1
#set $flags |= (0x1 << 28);
#end if
########## Class ID ##########
#if $pred & $cid_p
- header_buff[$num_header_words] = 0;
- #set $num_header_words += 1
- header_buff[$num_header_words] = 0;
- #set $num_header_words += 1
+ pack_uint64_$(suffix)(if_packet_info.cid, packet_buff+$num_header_words);
+ #set $num_header_words += 2
#set $flags |= (0x1 << 27);
#end if
########## Integer Time ##########
#if $pred & $tsi_p
- header_buff[$num_header_words] = $(XE_MACRO)(boost::uint32_t(metadata.time_spec.get_full_secs()));
+ packet_buff[$num_header_words] = $(XE_MACRO)(if_packet_info.tsi);
#set $num_header_words += 1
#set $flags |= (0x3 << 22);
#end if
########## Fractional Time ##########
#if $pred & $tsf_p
- header_buff[$num_header_words] = 0;
- #set $num_header_words += 1
- header_buff[$num_header_words] = $(XE_MACRO)(boost::uint32_t(metadata.time_spec.get_tick_count(tick_rate)));
- #set $num_header_words += 1
+ pack_uint64_$(suffix)(if_packet_info.tsf, packet_buff+$num_header_words);
+ #set $num_header_words += 2
#set $flags |= (0x1 << 20);
#end if
########## Trailer ##########
#if $pred & $tlr_p
+ packet_buff[$num_header_words+if_packet_info.num_payload_words32] = $(XE_MACRO)(if_packet_info.tlr);
#set $flags |= (0x1 << 26);
#set $num_trailer_words = 1;
#else
#set $num_trailer_words = 0;
#end if
########## Variables ##########
- num_header_words32 = $num_header_words;
- num_packet_words32 = $($num_header_words + $num_trailer_words) + num_payload_words32;
+ if_packet_info.num_header_words32 = $num_header_words;
+ if_packet_info.num_packet_words32 = $($num_header_words + $num_trailer_words) + if_packet_info.num_payload_words32;
vrt_hdr_flags = $hex($flags);
break;
#end for
}
//set the burst flags
- if (metadata.start_of_burst) vrt_hdr_flags |= $hex(0x1 << 25);
- if (metadata.end_of_burst) vrt_hdr_flags |= $hex(0x1 << 24);
+ if (if_packet_info.sob) vrt_hdr_flags |= $hex(0x1 << 25);
+ if (if_packet_info.eob) vrt_hdr_flags |= $hex(0x1 << 24);
//fill in complete header word
- header_buff[0] = $(XE_MACRO)(boost::uint32_t(0
+ packet_buff[0] = $(XE_MACRO)(boost::uint32_t(0
| vrt_hdr_flags
- | ((packet_count & 0xf) << 16)
- | (num_packet_words32 & 0xffff)
+ | ((if_packet_info.packet_count & 0xf) << 16)
+ | (if_packet_info.num_packet_words32 & 0xffff)
));
}
-void vrt::unpack_$(suffix)(
- rx_metadata_t &metadata, //output
- const boost::uint32_t *header_buff, //input
- size_t &num_header_words32, //output
- size_t &num_payload_words32, //output
- size_t num_packet_words32, //input
- size_t &packet_count, //output
- double tick_rate //input
-){
- //clear the metadata
- metadata = rx_metadata_t();
- boost::uint32_t secs = 0, ticks = 0;
+static UHD_INLINE void unpack_uint64_$(suffix)(boost::uint64_t &num, const boost::uint32_t *mem){
+ num = $(XE_MACRO)(*reinterpret_cast<const boost::uint64_t *>(mem));
+}
+void vrt::if_hdr_unpack_$(suffix)(
+ const boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
+){
//extract vrt header
- boost::uint32_t vrt_hdr_word = $(XE_MACRO)(header_buff[0]);
+ boost::uint32_t vrt_hdr_word = $(XE_MACRO)(packet_buff[0]);
size_t packet_words32 = vrt_hdr_word & 0xffff;
- packet_count = (vrt_hdr_word >> 16) & 0xf;
+ if_packet_info.packet_count = (vrt_hdr_word >> 16) & 0xf;
//failure cases
- if (packet_words32 == 0 or num_packet_words32 < packet_words32)
+ if (packet_words32 == 0 or if_packet_info.num_packet_words32 < packet_words32)
throw std::runtime_error("bad vrt header or packet fragment");
if (vrt_hdr_word & (0x7 << 29))
throw std::runtime_error("unsupported vrt packet type");
@@ -174,41 +168,48 @@ void vrt::unpack_$(suffix)(
#set $num_header_words = 1
########## Stream ID ##########
#if $pred & $sid_p
- metadata.has_stream_id = true;
- metadata.stream_id = $(XE_MACRO)(header_buff[$num_header_words]);
+ if_packet_info.has_sid = true;
+ if_packet_info.sid = $(XE_MACRO)(packet_buff[$num_header_words]);
#set $num_header_words += 1
+ #else
+ if_packet_info.has_sid = false;
#end if
########## Class ID ##########
#if $pred & $cid_p
- #set $num_header_words += 1
- #set $num_header_words += 1
+ if_packet_info.has_cid = true;
+ unpack_uint64_$(suffix)(if_packet_info.cid, packet_buff+$num_header_words);
+ #set $num_header_words += 2
+ #else
+ if_packet_info.has_cid = false;
#end if
########## Integer Time ##########
#if $pred & $tsi_p
- #set $has_time_spec = True
- secs = $(XE_MACRO)(header_buff[$num_header_words]);
+ if_packet_info.has_tsi = true;
+ if_packet_info.tsi = $(XE_MACRO)(packet_buff[$num_header_words]);
#set $num_header_words += 1
+ #else
+ if_packet_info.has_tsi = false;
#end if
########## Fractional Time ##########
#if $pred & $tsf_p
- #set $has_time_spec = True
- #set $num_header_words += 1
- ticks = $(XE_MACRO)(header_buff[$num_header_words]);
- #set $num_header_words += 1
- #end if
- #if $has_time_spec
- metadata.has_time_spec = true;
- metadata.time_spec = time_spec_t(secs, ticks, tick_rate);
+ if_packet_info.has_tsf = true;
+ unpack_uint64_$(suffix)(if_packet_info.tsf, packet_buff+$num_header_words);
+ #set $num_header_words += 2
+ #else
+ if_packet_info.has_tsf = false;
#end if
########## Trailer ##########
#if $pred & $tlr_p
+ if_packet_info.has_tlr = true;
+ if_packet_info.tlr = $(XE_MACRO)(packet_buff[$num_header_words+packet_words32]);
#set $num_trailer_words = 1;
#else
+ if_packet_info.has_tlr = false;
#set $num_trailer_words = 0;
#end if
########## Variables ##########
- num_header_words32 = $num_header_words;
- num_payload_words32 = packet_words32 - $($num_header_words + $num_trailer_words);
+ if_packet_info.num_header_words32 = $num_header_words;
+ if_packet_info.num_payload_words32 = packet_words32 - $($num_header_words + $num_trailer_words);
break;
#end for
}