Subject: Re: system task
From: Adam Krolnik (krolnik@lsil.com)
Date: Fri Mar 22 2002 - 08:27:41 PST
Hi Harry;
Here is a list that I have found uses for. Some are syntactic
sugar for ease of writing and readability.
delay(sig, clocks) - return signal value from N clocks ago.
Extremely useful and simplifying ability!
posedge() - detect when a signal has a positive edge.
negedge() - "" negative edge.
stable() - signal has no change.
isunknown() - signal has X's in it ::= ^sig === 1'bx
atmost1() - 0 or 1 signals asserted - similar to $onehot0()
exactly1() - 1 signal asserted - similar to $onehot()
setof(sig, values) - similar to $in()
One reason to like the named functions is that they are
far more readable than this:
assert ((a & (a - 1)) == 0);
vs.
assert ($onehot(a));
Same for a 'onehot or zero' It prevents repetition of the
inputs. Though for onecold, etc. Wouldn't the complement
of the input be sufficient?
assert ($onehot(~acoldone)); // 11011 -> 00100
The use of a in-set function is also a valuable shorthand. I also
agree that many times the out-set is smaller. I have done this
with one function like this:
assert (~$in(cmd, illegal1, illegal2));
But if we don't mind a few more functions, they do add to readability.
What I would really like to see in an in-set function is the ability
to have don't cares. Since there is no way to compare a value
against a don't care value (unless you use a casex statement) this
would be a valuable addition. E.g.
assert ($in(cmd, 3'b1??, 3'b010)); // 2, 4, 5, 6 ,7
Where this is most useful is in real examples:
$in({rf1s_ars_prefetch,rf1s_ars_nullreq,rf1s_ars_invlpg,
rf1s_ars_pa, rf1s_ars_special,rf1s_ars_io,rf1s_ars_lock,
rf1s_ars_write, rf1s_ars_read,rf1s_ars_user,rf1s_ars_imm,
rf1s_ars_fp,rf1s_ars_noex},
13'b100000001?00?, //prefetch
13'b010000????0??, //nullreq
13'b0010?00??010?, //invlpg
13'b0001000???00?, //pa_in_smi
13'b000010001?00?, //MSR read
13'b00?010010?00?, //MSR write
13'b00?010011?00?, //MSR RMW
... ))
$error("illegal AC access.
Here the designer was taking his set of control signals and providing
a list of the legal combinations. Without a don't care comparison
capability, the designer would have to split this up into more
complex code to only check the signal combinations that make
up a command. Note, we have used the ? character for our don't care
value. Either X or Z/? would be sufficient...
If we weren't pushing it, having the function return the number of
matches (how many elements of the set were a match) would be even
more useful instead of just true/false.
I'd like to go into how useful the delay() function is, but that
is better left for another mail...
Adam Krolnik
Verification Mgr.
LSI Logic Corp.
Plano TX. 75074
This archive was generated by hypermail 2b28 : Fri Mar 22 2002 - 08:29:24 PST