RE: [sv-bc] Mantis 1828

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Wed Feb 13 2008 - 10:03:13 PST
Jonathan,

If you use always_ff, then in some synthesis tools you will get a
warning, such as

  Warning: ... Netlist for always_ff block contains a latch. ...

module test(input clk, rst, in0, in2, output logic [2:0] q);
always_ff @(posedge clk or posedge rst)
        if (rst)
                q[2:0] <= 0;
        else begin
                q[2] <= in2;
                q[0] <= in0;
        end
endmodule 

-- Brad

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of
Jonathan Bromley
Sent: Wednesday, February 13, 2008 9:22 AM
To: Bresticker, Shalom; sv-bc@eda.org
Subject: RE: [sv-bc] Mantis 1828

> Another complication on this is a case like the following:
> 
> always @(posedge clk or posedge rst)
> 	if (rst)
> 		q[2:0] <= 0;
> 	else begin
> 		q[2] <= in2;
> 		q[0} <= in0;
> 	end
[...]
> So should always_ff flag an error in such a case?

Since this is my personal second most frequent design mistake (just
behind the opposite one, resetting some but not all of the registers) I
would quite like to see the warning (error?).
I can easily suppress it with a tweak that is completely harmless, and
odd enough to be almost self-documenting:

  always @(posedge clk or posedge rst)
  	if (rst)
  		q[2:0] <= 0;
  	else begin

            q <= q; // suppress warnings about unclocked
                    // registers with a reset

  		q[2] <= in2;
  		q[0} <= in0;
  	end
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223                   Email:
jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573                           Web:
http://www.doulos.com

The contents of this message may contain personal views which are not
the views of Doulos Ltd., unless specifically stated.

--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Feb 13 10:04:25 2008

This archive was generated by hypermail 2.1.8 : Wed Feb 13 2008 - 10:04:58 PST