Subject: Re: Using iff example - very bad coding style!
From: Michael McNamara (mac@verisity.com)
Date: Tue Dec 11 2001 - 15:01:35 PST
Clifford E. Cummings writes:
> > Alex writes:
> >So, we may merge the two processes, as follows:
> >
> >always @(posedge clock) //synchronous reset
> > if (!reset) count <= 0;
> > else if (load) count <= d; //gated input
> > else count <= count + 1;
>
> More concise. Easy to understand. A much better coding style, but it does
> not use the new capabilities.
>
> >Similarly, for the asynchronous reset:
> >
> >always @(posedge clock iff (load == 0) and (reset == 1))
> > count <= count +1;
> >
> >always @(negedge reset) //asynchronous reset
> > if (!reset) count <= 0;
> >
> >always @(posedge clock iff (load == 1) and (reset == 1)//gated input
> > count <= d;
>
> Another job interview question!
>
> >or the merged version:
> >
> >always @(posedge clock or negedge reset) //asynchronous reset
> > if (!reset) count <= 0;
> > else if (load) count <= d; //gated input
> > else count <= count + 1;
>
> Again, much more concise. Easy to understand. A better coding style. No
> race analysis required. Also no use of the new construct.
>
> >Alec
>
> Regards - Cliff
So, my vote is that we don't add the new construct.
The difference between a good artist and a great artist is that the
later knows when to stop adding paint.
-mac
This archive was generated by hypermail 2b28 : Tue Dec 11 2001 - 15:04:33 PST