简体   繁体   English

SystemVerilog Verilog中的非数组移位运算符?

[英]Unarray shift operator in SystemVerilog Verilog?

I ran into this line in a SystemVerilog sim, I've googled around but I'm not sure what it's doing: 我在SystemVerilog sim卡中遇到了这一行,我在Google上搜索了一下,但是不知道它在做什么:

data_w = { >> 32 { { >> { data } } } };

Any clarification would be much appreciated! 任何澄清将不胜感激! Thanks! 谢谢!

It is called streaming. 这称为流式传输。 It exists in SystemVerilog; 它存在于SystemVerilog中。 not Verilog. 不是Verilog。 For a full explanation, refer to IEEE Std 1800-2012 § 11.4.14 Streaming operators (pack/unpack) 有关完整说明,请参阅IEEE Std 1800-2012§11.4.14 流运算符(打包/解包)

The slice_size determines the size of each block, measured in bits. slice_size确定每个块的大小,以位为单位。 If a slice_size is not specified, the default is 1. If specified, it may be a constant integral expression or a simple type. 如果未指定slice_size ,则默认值为1。如果已指定,则它可以是常量整数表达式或简单类型。 If a type is used, the block size shall be the number of bits in that type. 如果使用一种类型,则块大小应为该类型的位数。 If a constant integral expression is used, it shall be an error for the value of the expression to be zero or negative. 如果使用常量整数表达式,则表达式的值为零或负数将是一个错误。

The stream_operator << or >> determines the order in which blocks of data are streamed: >> causes blocks of data to be streamed in left-to-right order, while << causes blocks of data to be streamed in right-to-left order. stream_operator <<>>确定流数据块的顺序: >>使数据块以从左到右的顺序流式传输,而<<使数据块以从右到右的顺序流式传输。左订单。 Left-to-right streaming using >> shall cause the slice_size to be ignored and no re-ordering performed. 使用>>的从左到右流将导致slice_size被忽略并且不执行任何重新排序。 Right-to-left streaming using << shall reverse the order of blocks in the stream, preserving the order of bits within each block. 使用<<从右到左流式传输应逆转流中各块的顺序,并保留每个块内的比特顺序。 For right-to-left streaming using << , the stream is sliced into blocks with the specified number of bits, starting with the right-most bit. 对于使用<<从右到左的流,将流切成具有指定位数的块(从最右边的位开始)。 If as a result of slicing the last (left-most) block has fewer bits than the block size, the last block has the size of the remaining bits; 如果切片的结果是,最后一个(最左边的)块的位数少于该块的大小,则最后一个块的剩余位数为该块的大小; there is no padding or truncation. 没有填充或截断。

Examples form IEEE Std 1800-2012 § 11.4.14.2 Re-ordering of the generic stream 来自IEEE Std 1800-2012§11.4.14.2的示例通用流的重新排序

 int j = { "A", "B", "C", "D" }; { >> {j}} // generates stream "A" "B" "C" "D" { << byte {j}} // generates stream "D" "C" "B" "A" (little endian) { << 16 {j}} // generates stream "C" "D" "A" "B" { << { 8'b0011_0101 }} // generates stream 'b1010_1100 (bit reverse) { << 4 { 6'b11_0101 }} // generates stream 'b0101_11 { >> 4 { 6'b11_0101 }} // generates stream 'b1101_01 (same) { << 2 { { << { 4'b1101 }} }} // generates stream 'b1110 

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

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