[sv-bc] Question about stream unpacking

From: Paul Graham <pgraham@oasys-ds.com>
Date: Tue Jul 27 2010 - 14:08:11 PDT

LRM 11.4.14.3 says:

    If the source expression contains more bits than are needed,
    the appropriate number of bits shall be consumed from its left
    (most significant) end.

Later there are two examples (including my $display statements):

    int a, b, c;
    {>>{ a, b, c }} = 96'b1; // OK: unpack a = 0, b = 0, c = 1
    $display("a = %x, b = %x, c = %x", a, b, c);
    {>>{ a, b, c }} = 100'b1; // OK: unpack as above (4 bits unread)
    $display("a = %x, b = %x, c = %x", a, b, c);

In the second assignment, the rhs has more bits than is neeed (100 vs 96). The rule above says that the bits should be taken from the msb of the expression. Following this rule I would expect to get a=0, b=0, c=0. Yet the comment "unpack as above" suggests that the second assignment behaves the same as the first. And a leading simulator also treats the two assignments the same:

# a = 00000000, b = 00000000, c = 00000001
# a = 00000000, b = 00000000, c = 00000001

Maybe the rule hinges on the meaning of "appropriate"?

Paul

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jul 27 14:08:26 2010

This archive was generated by hypermail 2.1.8 : Tue Jul 27 2010 - 14:11:19 PDT