简体   繁体   English

字节屏蔽 AxiStream:如何使用 tkeep systemverilog 屏蔽 tdata

[英]Byte Masking AxiStream: How to mask tdata with tkeep systemverilog

In AxiStream the tkeep value in each transfer denotes the valid bytes in the tdata field of the same transfer.在 AxiStream 中,每次传输中的 tkeep 值表示同一传输的 tdata 字段中的有效字节。 In systemverilog i want to use tkeep to mask (set to 0) the invalid bits in the tdata field.在 systemverilog 中,我想使用 tkeep 来屏蔽(设置为 0)tdata 字段中的无效位。

If tkeep denoted invalid bits then I could simply do:如果 tkeep 表示无效位,那么我可以简单地做:

masked_tdata = tdata & tkeep;

However tkeep denotes valid bytes.但是 tkeep 表示有效字节。

Is there an elegant way to perform this "Byte Masking" operation in SystemVerilog (Does not have to be synthesizable as this is part of a testbench).在 SystemVerilog 中是否有一种优雅的方式来执行此“字节屏蔽”操作(不必合成,因为这是测试平台的一部分)。

logic[31:0] tdata = 4'hC1FF
logic[3:0] tkeep = 4'b0001;
logic[31:0] masked_tdata;


assign masked_tdata = tdata & tkeep; // evaluates to 0x0001
// what I want it to evaluate to is 0x000F

If by elegant you mean as a single expression, I can't think of one that is more elegant than using for loop.如果优雅是指单个表达式,我想不出比使用for循环更优雅的表达式了。

for(int i;i<$bits(tdata)/8;i++)
  masked_tdata[i*8+:8] = tkeep[i] ? tdata[i*8+:8] : '0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM