Chapter 7 System Functions and Tasks

7.1 $ onehot,$ onehot0


                                            Figure 7.1 $onehot and $onehot0

$onehot and $onehot0 are fairly self explanatory and are explained in Figure 7.1. Note that $onehot or $onehot0 will fail if the expression is 'Z' or 'X'. Figure 7.1 depicts a simple application. For the confirmation of any one bus grant, there can only be one bus grant. As shown, this is easily done with $onehot.

 7.2 $ isunknown


                                                        Figure 7.2 $isunknown

$isuncnown passes if the expression is unknown ('X' or 'Z'). In other words, if the expression is not unknown, the property will fail! So if you really want to fail to detect an unknown ('X' or 'Z'), you must negate the result of $isunknown. Simple but easy to miss.

The simulation log in Figure 7.2 illustrates this concept. The attribute 'ucheck' states that if 'bgack' is 'true', 'busgnt' is unknown. What? This is just to show what happens if you use $isunknown instead of 'not'.

 7.2.1 Apply $isunknown


                                                Figure 7.3 $isunknown application

Figure 7.3 shows two simple applications. The first is the same as what we just discussed, but with a "not".

@(posedge clk) bgack |-> not ($isunknown(busgnt));
It says that if bgack is true (high) then busgnt must not be in an unknown state. Note again that $isunknown returns true when detecting unknown. So, if you want to fail, you have to negate the result. This is shown in the simulation log above. The second application (bottom of Figure 7.3) says that if 'adrStrobe' is high, then the control signal cannot be unknown.

 7.3 $ countones


                                            Figure 7.4 $countones - basics and applications

$countones is very simple but powerful. Note that system functions can be used in procedural blocks as well as concurrent properties/assertions.

Figure 7.4 shows an application that declares that only 1 bus grant (busgnt) can be activated on the bus if the bus grant acknowledgement (bgack) is present. Note that in this example we use $countones in the program block. Also note that the assertion will fail if the entire 'busgnt' is unknown ('X') or tri-stated ('Z'). Figure 7.5 shows a very simple way to check the validity of a Gray code.

 

                                            Figure 7.5 $countones application

7.3.1 $countones (as boolean)


                                            Figure 7.6 $countones as a boolean

7.4 $ assertoff,$ asserton,$ assertkill

In many cases, if you want to achieve global control of assertions at the module and instance level. Recall that 'disable iff' provides local control directly at the source of the assertion. As shown in Figure 7.7, $assertoff temporarily turns off the execution of all assertions. Note that the assertion will not be terminated if the assertion is executing when $assertoff is executed. Restart assertion execution on subsequent calls to $asserton. $assertkill will kill all assertions in your design, including assertions that have already been executed. It does not start automatically when the next assertion starts executing. It will only start execution on the subsequent $asserton. $asserton: This is the default value. Assertions need to be restarted after $assertoff or $assertkill.


                          Figure 7.7 $assertoff, $asserton, $assertkill - Basics

The following is a typical application deployed by a project to control the execution of assertions (if required) during resets or during exceptions (Figure 7.8).

 

                                                Figure 7.8 Assertion Control Application

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325855413&siteId=291194637