Subject: RE: [sv-bc] Re: SV31A LRM interpretation for: unique case
From: Michael McNamara (mac@verisity.com)
Date: Thu Feb 19 2004 - 01:18:17 PST
While I have not been following the debate to this point, as a former
designer, the value I see in unique casex is that I do not generate a
priority decoder.
As Stuart points out, this example indeed requires a priority decoder
as 1101 would activate two case items.
Recoding the example as to remove this likley unintended overlap gives
us:
unique casex (value)
'b111x, 'b11x1: $display( "case item 1 executed" );
'b0111: $display( "case item 2 executed" );
endcase
Arguably this could be viewed as mapping to:
unique casex (value)
'b111x: $display( "case item 1 executed" );
'b11x1: $display( "case item 1 executed" );
'b0111: $display( "case item 2 executed" );
endcase
and then we are not a unique case, as 'b1111 would indeed trigger the
first two case items. HOWEVER - they do the same thing. BUT they do
generate side effects (there might be two prints to the log file...).
However, if in truth the logic one desired was
if (value[3]&value[2]&(value[1]|value[0]))
$display("case item 1 executed")
if (!value[3]&value[2]&value[1]&value[0])
$display("case item 2 executed")
then we are safe as we have as desired, not generated a priority
decoder; and are assured that only one or the other $display would be
executed.
-- On Feb 18 2004 at 10:33, Stuart Sutherland sent a message:
> To: David.Rich@synopsys.com, dlindner@cadence.com, sv-bc@eda.org, sharp@cadence.com, ricksull@cadence.com
> Subject: "RE: [sv-bc] Re: SV31A LRM interpretation for: unique case"
> Dave,
>
> One of the example previously given had multiple case items that could
> satisfy the same branch.
> ----------
> Example 1: Using "unique casex"
>
> Assume "reg [3:0] value;" is equal to "4'b1111" when the following "unique
> casex" is executed:
>
>
>
> unique casex (value)
>
> 'b111x, 'b11x1: $display( "case item 1 executed" ); //1st case
> item - has multiple true case expressions
>
> 'b1101: $display( "case item 2 executed" ); //2nd
> case item - has no true case expression
>
> endcase
>
> ----------
>
> The given value of the case expression would only satisfy one branch of the
> code. If I understand correctly, your change means that this will still
> generate an error, because two case items are true for the same branch of
> code. Is that your intent?
>
> Note that in that example, if value were 'b1101, then two branches could be
> true, which would--and should--be an error.
>
> Stu
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> Stuart Sutherland
> stuart@sutherland-hdl.com
> 503-692-0898
>
>
>
> _____
>
> From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On
> Behalf Of Dave Rich
> Sent: Wednesday, February 18, 2004 12:20 AM
> To: Dave Lindner
> Cc: sv-bc@server.eda.org; Steven Sharp; Rick Sullivan
> Subject: Re: [sv-bc] Re: SV31A LRM interpretation for: unique case
>
>
> Dave,
>
> Yes I agree with your interpretation.
>
> I suggest the following errata for Section 8.4
>
> "A unique case shall guarantee no overlapping case valuesitems, allowing the
> case items to be evaluated in parallel."
>
> Dave
>
>
> Dave Lindner wrote:
>
>
>
>
> SystemVerilog LRM says:
>
> "A unique case shall guarantee no overlapping case values, allowing the case
> items to be evaluated in parallel."
>
>
>
>
>
> Did you really mean matching multiple case values is an error,
>
> or multiple matching case items is an error, which makes more sense?
>
>
>
>
>
> What happens when:
>
> There is one case item that has multiple true case expressions, and
>
> all other case items have false case expressions.
>
>
>
> We believe that this scenario, demonstrated in Example 1 should not throw a
> "unique" run-time error in the simulator.
>
> Is our interpretation correct?
>
>
>
>
>
> Example 1: Using "unique casex"
>
> Assume "reg [3:0] value;" is equal to "4'b1111" when the following "unique
> casex" is executed:
>
>
>
> unique casex (value)
>
> 'b111x, 'b11x1: $display( "case item 1 executed" ); //1st case
> item - has multiple true case expressions
>
> 'b1101: $display( "case item 2 executed" ); //2nd
> case item - has no true case expression
>
> endcase
>
>
>
> With value set to "4'b1111":
>
> The first case item has multiple true case expressions.
>
> All other case items have false case expressions.
>
> We believe that this is not an error, based upon the following consistency
> argument, demonstrated in Example 2, which uses the "unique if" construct:
>
>
>
>
>
> Example 2: Using "unique if"
>
> Assume "reg [3:0] value, a, b;" are all equal to "4'b1111",
>
> and "reg [3:0] c;" is equal to "4'b1101", when the when the following
> "unique if" is executed:
>
>
>
> unique if ((value == a) || (value==b)) //1st "unique if" condition - is
> true in multiple ways
>
> $display( "if clause 1 executed" );
>
> else if (value == c) //2nd "unique if" condition
> - is false
>
> $display( "if clause 2 executed" );
>
>
>
> With value, a, b, c set to the above values:
>
> The first "unique if" condition is true in multiple ways.
>
> No other "unique if" condition is true.
>
> We know that this should not throw a "unique" run-time error in the
> simulator.
>
> Therefore the "unique casex" analogy should not throw a run time error.
>
>
>
>
>
>
> --
>
> --
>
> David.Rich@Synopsys.com
>
> Technical Marketing Consultant and/or
>
> Principal Product Engineer
>
> http://www.SystemVerilog.org
>
> tele: 650-584-4026
>
> cell: 510-589-2625
>
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD><TITLE></TITLE>
> <META http-equiv=Content-Type content="text/html; charset=us-ascii">
> <META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
> <BODY text=#000000 bgColor=#ffffff>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004><FONT face="Courier New"
> color=#0000ff size=2>Dave,</FONT></SPAN></DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004><FONT face="Courier New"
> color=#0000ff size=2></FONT></SPAN> </DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004><FONT face="Courier New"
> color=#0000ff size=2>One of the example previously given had multiple case
> items that could satisfy the same branch.</FONT></SPAN></DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004><FONT face="Courier New"
> color=#0000ff size=2>----------</FONT></SPAN></DIV>
> <DIV><FONT face="Courier New" color=#0000ff size=2>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Example 1: Using “unique
> casex”</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Assume “reg [3:0] value;” is equal to “4’b1111” when the
> following “unique casex” is executed:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">unique casex (value)</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> ’b111x, ‘b11x1:
> $display( “case item 1 executed” );
> //1<SUP>st</SUP> case item – has multiple true case
> expressions</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">
> ’b1101:
> $display( “case item 2 executed”
> ); //2<SUP>nd</SUP> case item – has no true case
> expression</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">endcase</SPAN></FONT></P></FONT></DIV>
> <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN
> class=666431418-18022004>----------</SPAN></FONT></DIV>
> <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN
> class=666431418-18022004></SPAN></FONT> </DIV>
> <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN
> class=666431418-18022004>The given value of the case expression would only
> satisfy one branch of the code. </SPAN></FONT><FONT face="Courier New"
> color=#0000ff size=2><SPAN class=666431418-18022004><SPAN
> class=666431418-18022004><FONT face="Courier New" color=#0000ff size=2>If I
> understand correctly, your change means that this will still generate an error,
> because two case items are true for the same branch of code. Is that your
> intent?</FONT></SPAN></DIV>
> <DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004></SPAN> </DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004>Note that in that
> example, if value were 'b1101, then two branches could be true, which would--and
> should--be an error.</SPAN></DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004></SPAN> </DIV>
> <DIV dir=ltr align=left><SPAN class=666431418-18022004>Stu</SPAN></DIV>
> <DIV></SPAN></FONT><FONT size=2>~~~~~~~~~~~~~~~~~~~~~~~~~<BR>Stuart
> Sutherland<BR>stuart@sutherland-hdl.com<BR>503-692-0898</FONT> </DIV></DIV>
> <DIV> </DIV><BR>
> <BLOCKQUOTE dir=ltr
> style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
> <HR tabIndex=-1>
> <FONT face=Tahoma size=2><B>From:</B> owner-sv-bc@server.eda.org
> [mailto:owner-sv-bc@server.eda.org] <B>On Behalf Of </B>Dave
> Rich<BR><B>Sent:</B> Wednesday, February 18, 2004 12:20 AM<BR><B>To:</B> Dave
> Lindner<BR><B>Cc:</B> sv-bc@server.eda.org; Steven Sharp; Rick
> Sullivan<BR><B>Subject:</B> Re: [sv-bc] Re: SV31A LRM interpretation for:
> unique case<BR></FONT><BR></DIV>
> <DIV></DIV>Dave,<BR><BR>Yes I agree with your interpretation.<BR><BR>I suggest
> the following errata for Section 8.4<BR><BR><FONT face="Times New Roman"
> size=2><SPAN style="FONT-SIZE: 11pt">"A unique case shall guarantee no
> overlapping case <STRIKE>values</STRIKE><FONT color=blue><U>items</U></FONT>,
> allowing the case items to be evaluated in
> parallel."<BR><BR>Dave<BR><BR></SPAN></FONT><BR>Dave Lindner wrote:<BR>
> <BLOCKQUOTE
> cite=mid9186D1CF264F564C81B42C75972344E6119369@exmbx01chel.cadence.com
> type="cite">
> <META content="Microsoft Word 10 (filtered)" name=Generator>
> <STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
> P.MsoNormal {
> FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
> }
> LI.MsoNormal {
> FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
> }
> DIV.MsoNormal {
> FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
> }
> A:link {
> COLOR: blue; TEXT-DECORATION: underline
> }
> SPAN.MsoHyperlink {
> COLOR: blue; TEXT-DECORATION: underline
> }
> A:visited {
> COLOR: purple; TEXT-DECORATION: underline
> }
> SPAN.MsoHyperlinkFollowed {
> COLOR: purple; TEXT-DECORATION: underline
> }
> SPAN.EmailStyle17 {
> COLOR: windowtext; FONT-FAMILY: Arial
> }
> DIV.Section1 {
> page: Section1
> }
> </STYLE>
>
> <DIV class=Section1>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">SystemVerilog LRM says:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">“A unique case shall guarantee no overlapping case
> values, allowing the case items to be evaluated in
> parallel.”</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Did you really mean matching multiple case values is
> an error,</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">or multiple matching case items is an error, which
> makes more sense?</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">What happens when:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> There is one case item that has
> multiple true case expressions, and</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> all other case items have false case
> expressions.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">We believe that this scenario, demonstrated in
> Example 1 should <B><SPAN style="FONT-WEIGHT: bold">not</SPAN></B> throw a
> “unique” run-time error in the simulator.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Is our interpretation correct?</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Example 1: Using “unique
> casex”</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Assume “reg [3:0] value;” is equal to “4’b1111” when
> the following “unique casex” is executed:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">unique casex (value)</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> ’b111x, ‘b11x1:
> $display( “case item 1 executed” );
> //1<SUP>st</SUP> case item – has multiple true case
> expressions</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">
> ’b1101:
> $display( “case item 2 executed”
> ); //2<SUP>nd</SUP> case item – has no true case
> expression</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">endcase</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">With value set to “4’b1111”: </SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">The first case item has multiple true case
> expressions.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">All other case items have false case
> expressions.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">We believe that this is <B><SPAN
> style="FONT-WEIGHT: bold">not</SPAN></B> an error, based upon the following
> consistency argument, demonstrated in Example 2, which uses the “unique if”
> construct:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Example 2: Using “unique
> if”</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Assume “reg [3:0] value, a, b;” are all equal to
> “4’b1111”,</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">and “reg [3:0] c;” is equal to “4’b1101”, when the
> when the following “unique if” is executed:</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">unique if ((value == a) ||
> (value==b)) //1<SUP>st</SUP> “unique if” condition – is
> true in multiple ways</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> $display( “if clause 1 executed”
> ); </SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">else if (value == c)
>
> //2<SUP>nd</SUP> “unique if” condition – is false</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"> $display( “if clause 2 executed”
> );</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">With value, a, b, c set to the above
> values: </SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">The first “unique if” condition is true in multiple
> ways.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">No other “unique if” condition is
> true.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">We know that this should <B><SPAN
> style="FONT-WEIGHT: bold">not</SPAN></B> throw a “unique” run-time error in
> the simulator.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt">Therefore the “unique casex” analogy should <B><SPAN
> style="FONT-WEIGHT: bold">not</SPAN></B> throw a run time
> error.</SPAN></FONT></P>
> <P class=MsoNormal><FONT face="Times New Roman" size=2><SPAN
> style="FONT-SIZE: 11pt"></SPAN></FONT> </P>
> <P class=MsoNormal><FONT face=Arial size=2><SPAN
> style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT> </P></DIV></BLOCKQUOTE><BR><PRE class=moz-signature cols="100">--
> --
> <A class=moz-txt-link-abbreviated href="mailto:David.Rich@Synopsys.com">David.Rich@Synopsys.com</A>
> Technical Marketing Consultant and/or
> Principal Product Engineer
> <A class=moz-txt-link-freetext href="http://www.SystemVerilog.org">http://www.SystemVerilog.org>
> tele: 650-584-4026
> cell: 510-589-2625
>
> </PRE></BLOCKQUOTE></BODY></HTML>
This archive was generated by hypermail 2b28 : Thu Feb 19 2004 - 01:31:05 PST