Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Are these two SystemVerilog statements equivalent and do they work as I expect them to?

Plexiglas1

Newbie
Newbie level 4
Joined
Feb 19, 2025
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
I'm trying to minimize logic and make the (ASIC) synthesis tool merge the 2'b11 case's logic with the previous ones, as I don't care about that case.
I know I can make the second-to-last statement the default, but that might not be optimal in terms of logic in the general case.
This is a minimal example of what I'm trying to do, so don't worry about the specifics of this concrete example.
Are the statements equivalent and are they doing what I want them to?

Code:
case(cond)
  2'b00: result = v1;
  2'b01: result = v2;
  2'b10: result = v3;
  default: result = 'x;
endcase

unique case(cond)
  2'b00: result = v1;
  2'b01: result = v2;
  2'b10: result = v3;
endcase
 
Solution
Use unique0 if you don't care if other enum values are used. All three keywords unique, unique0, and priority, tell the synthesis tool tell the synthesis tool that alll other case items are don't cares.
Actually, for the code you wrote the first case statement would be equivalent to both a unique case and a priority case statement. You are stating that all case items have been specified and all other unspecified expressions are a don't care. SystemVerilog would generate a warning if an unmatched expression ever occurs.
 
give it a try with our synthesis tool of choice with a MWE. if you have a mux4 in your library, all these tricks might yield the same gate count and you wasted brain power but saved nothing. (I assume you know how to avoid latches for your case stmt, so that shouldn't play a role.)
 
...if you have a mux4 in your library, all these tricks might yield the same gate count and you wasted brain power but saved nothing.
That's why this is a minimal case and I'm talking about the general case.
For example: you have an enum with 17 values, and only want cases for 5 of them while the rest of them should be "don't care".
--- Updated ---

Actually, now I realize I don't always want to use the unique case, because it throws warnings in the simulation when other enum values are used, even if I don't care about them in this block of code.
So I'm left with the second part of the question, does 'x in the default case optimize in cases such as I described above?
 
Last edited:
Use unique0 if you don't care if other enum values are used. All three keywords unique, unique0, and priority, tell the synthesis tool tell the synthesis tool that alll other case items are don't cares.
 
Solution
Use unique0 if you don't care if other enum values are used. All three keywords unique, unique0, and priority, tell the synthesis tool tell the synthesis tool that alll other case items are don't cares.
Oh yeah, forgot about unique0.
Thanks for the help!
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top