From e4517deef3f0ed18112c08ecbbd7baef9dedaa74 Mon Sep 17 00:00:00 2001 From: Samuel O'Brien Date: Fri, 24 Jul 2020 16:14:08 -0500 Subject: sim: Support Timed Streams The only difference between a standard and timed stream is that the first data packet of a timed stream contains a timestamp. This commit adds the necessary fields to StreamSpec to accomplish this. Signed-off-by: Samuel O'Brien --- mpm/python/usrp_mpm/simulator/chdr_stream.py | 3 +++ mpm/python/usrp_mpm/simulator/noc_block_regs.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mpm/python/usrp_mpm/simulator/chdr_stream.py b/mpm/python/usrp_mpm/simulator/chdr_stream.py index f63fba050..7147a98b5 100644 --- a/mpm/python/usrp_mpm/simulator/chdr_stream.py +++ b/mpm/python/usrp_mpm/simulator/chdr_stream.py @@ -195,6 +195,9 @@ class ChdrOutputStream: if num_samps_left == 0: break header.seq_num = seq_num + timestamp = self.stream_spec.init_timestamp \ + if seq_num == 0 and self.stream_spec.is_timed \ + else None packet = ChdrPacket(self.chdr_w, header, bytes(0)) packet_samples = self.stream_spec.packet_samples if num_samps_left is not None: diff --git a/mpm/python/usrp_mpm/simulator/noc_block_regs.py b/mpm/python/usrp_mpm/simulator/noc_block_regs.py index b488ed43f..de6bd22a0 100644 --- a/mpm/python/usrp_mpm/simulator/noc_block_regs.py +++ b/mpm/python/usrp_mpm/simulator/noc_block_regs.py @@ -26,6 +26,8 @@ REGS_PER_PORT = 16 REG_RX_MAX_WORDS_PER_PKT = 0x28 REG_RX_CMD_NUM_WORDS_HI = 0x1C REG_RX_CMD_NUM_WORDS_LO = 0x18 +REG_RX_CMD_TIME_LO = 0x20 +REG_RX_CMD_TIME_HI = 0x24 REG_RX_CMD = 0x14 RX_CMD_CONTINUOUS = 0x2 @@ -207,10 +209,14 @@ class NocBlockRegs: self.get_stream_spec().set_num_words_hi(value) elif reg == REG_RX_CMD_NUM_WORDS_LO: self.get_stream_spec().set_num_words_lo(value) + elif reg == REG_RX_CMD_TIME_HI: + self.get_stream_spec().set_timestamp_hi(value) + elif reg == REG_RX_CMD_TIME_LO: + self.get_stream_spec().set_timestamp_lo(value) elif reg == REG_RX_CMD: if value & (1 << 31) != 0: - self.log.warn("Timed Streams are not supported. Starting immediately") value = value & ~(1 << 31) # Clear the flag + self.get_stream_spec().is_timed = True if value == RX_CMD_STOP: sep_block_id = self.resolve_ep_towards_outputs((self.get_radio_port(), chan)) self.stop_tx_stream(sep_block_id) -- cgit v1.2.3