ch3-Case

2019-10-24

unique,unique0 case

​ All case statements can be qualified by unique or unique0 keywords to perform violation checks like we saw in if-else-if construct.

unique and unique0 ensure that there is no overlapping case items and hence can be evaluated in parallel. If there are overlapping case items, then a violation is reported.

  • If more than one case item is found to match the given expression, then a violation is reported and the first matching expression is executed
  • If no case item is found to match the given expression, then a violation is reported only for unqiue

unique0 does not report a violation if no items match the expression

priority case

类似priority if,如果匹配到零个分支,报错;匹配到第一个分支就退出。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
module tb;
bit [1:0] abc;

initial begin
abc = 0;

// First match is executed
priority case (abc)
0 : $display ("Found to be 0");
0 : $display ("Again found to be 0");
2 : $display ("Found to be 2");
endcase
end
endmodule

Simulation Log

1
2
3
ncsim> run
Found to be 0
ncsim: *W,RNQUIE: Simulation is complete.

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!