Re: Using iff example - very bad coding style!


Subject: Re: Using iff example - very bad coding style!
From: Clifford E. Cummings (cliffc@sunburst-design.com)
Date: Tue Dec 11 2001 - 10:49:38 PST


At 09:38 AM 12/11/01 -0800, you wrote:

>Mac,
>
>The example should be:
>
>always @(posedge clock)
> if (reset and !load) count <= count + 1;
>
>always @(posedge clock iff load == 1) //synchronous reset
> if (!reset) count <= 0;
> else count <= d; //gated input

Heavens, No!

Making multiple assignments to the same variable from two different always
blocks should be highly discouraged (I highly discourage this coding style
in all of my training classes). This coding style is subject to race
conditions and is quite confusing, not to mention that if load == 0, the
second always block will not permit synchronous resets to occur.

>or
>
>always @(posedge clock)
> if (reset and !load) count <= count + 1;
>
>always @(posedge clock iff load == 1 or negedge reset) //asynchronous reset
> if (!reset) count <= 0;
> else if (load) count <= d; //gated input

Many of the same problems.

>The reason for the check on load here is that reset could have
>transitioned from 1 to X and load could have been 0.
>
>Alec

Synopsys gives warnings about unknown wired logic type, then builds two
flipflops with outputs anded together. This is really ugly!

Challenge: if anybody thinks they have a model that requires assignments to
the same variable from more than one always block, send it to me, I will
re-code it and send it back to you.

Regards - Cliff

//*****************************************************************//
// Cliff Cummings Phone: 503-641-8446 //
// Sunburst Design, Inc. FAX: 503-641-8486 //
// 14314 SW Allen Blvd. E-mail: cliffc@sunburst-design.com //
// PMB 501 Web: www.sunburst-design.com //
// Beaverton, OR 97005 //
// //
// Expert Verilog, Synthesis and Verification Training //
//*****************************************************************//



This archive was generated by hypermail 2b28 : Tue Dec 11 2001 - 10:49:59 PST