synthesis question

G

googler

Guest
If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
x = a | b;
y = c & d;
x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks.
 
On Jul 26, 12:52 am, googler <pinaki_...@yahoo.com> wrote:
If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
x = a | b;
y = c & d;
x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks.
Hopefully the synthesis tool will generate the same
combinatorial code you intended and match the simulation.

Generally synthesis tools ignore the sensitivity list
for combinatorial blocks but issue warnings if they
think something is missing that would cause a mismatch
between simulation and synthesis.

You don't need x in the sensitivity list because x only
changes during the execution of the block which has
already been triggered by the inputs a, b, c, or d. I
assume that x is not also assigned in another block.
That would give problems in simulation and errors in
synthesis.

The combinatorial logic generated by synthesis would only
depend on the final value of x in the always block, so
while x would briefly be a | b (for zero time) during
simulation, x would always be (a | b) ^ (c & d) for
synthesis.

For synthesis there is no problem with this type
of always block. You would run into problems and
probably get errors if you tried to mix non-blocking
and blocking assignments in such a block. You
would also get a simulation mismatch if your sensitivity
list is not complete (most synthesis tools will not
create sequential logic like latches just due to
the lack of an item in the sensitivity list).

Regards,
Gabor
 
gabor wrote:
On Jul 26, 12:52 am, googler <pinaki_...@yahoo.com> wrote:
If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
x = a | b;
y = c & d;
x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks.

....

The combinatorial logic generated by synthesis would only
depend on the final value of x in the always block, so
while x would briefly be a | b (for zero time) during
simulation, x would always be (a | b) ^ (c & d) for
synthesis.
....

I didn't think this would actually work, since x is a function of
itself, but I spent one minute to put it through Synplify and it does
synthesize just as Gabor reports: x = (a|b) ^ c&d.

However, it's not great style. It might be better to write it this way:

always @(*)
begin
x_temp = a | b;
y = c & d;
x = x_temp ^ y;
end

-Kevin
 
On Jul 28, 11:55 am, Kevin Neilson
<kevin_neil...@removethiscomcast.net> wrote:
gabor wrote:
On Jul 26, 12:52 am, googler <pinaki_...@yahoo.com> wrote:
If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
      x = a | b;
      y = c & d;
      x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks..

...

The combinatorial logic generated by synthesis would only
depend on the final value of x in the always block, so
while x would briefly be a | b (for zero time) during
simulation, x would always be (a | b) ^ (c & d) for
synthesis.

...

I didn't think this would actually work, since x is a function of
itself, but I spent one minute to put it through Synplify and it does
synthesize just as Gabor reports:  x = (a|b) ^ c&d.

However, it's not great style.  It might be better to write it this way:

always @(*)
  begin
        x_temp = a | b;
        y      = c & d;
        x      = x_temp ^ y;
  end

-Kevin- Hide quoted text -

- Show quoted text -
None of the tools we ran it through complained, and that includes
Magma (synthesis), Spyglass (for checking RTL) and some FV tool. Still
I was told that this is not the right way of coding. Hence I posted
the question to get others' opinion on this. Personally, however, I
would expect a synthesis tool to be able to understand the code in
question (since x is not changed anywhere outside the always block).
 
googler wrote:
(snip)

always @(a or b or c or d)
begin
x = a | b;
y = c & d;
x = x ^ y;
end
(snip)

None of the tools we ran it through complained, and that includes
Magma (synthesis), Spyglass (for checking RTL) and some FV tool. Still
I was told that this is not the right way of coding. Hence I posted
the question to get others' opinion on this. Personally, however, I
would expect a synthesis tool to be able to understand the code in
question (since x is not changed anywhere outside the always block).
When writing code there are always two considerations:

The program that has to read it and people that have
to read it. In this case, I believe it is legal code,
and should not confuse the tools. It is still worth
considering other people reading the code, unless you
are intentionally writing obfuscated code.

http://www.ioccc.org/

-- glen
 
On Jul 26, 5:52 am, googler <pinaki_...@yahoo.com> wrote:
If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
x = a | b;
y = c & d;
x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks.
My first time posting here!
I would never write code like this. Not because i know is bad but i
suspect it may be bad coding-style. I am a little confused as to
what you are trying to accomplish by assigning x twice? Would the
following code clear it up for you?

always_comb begin
//x = a | b;
y = c & d;
x = (a|b) ^ y;
end
 
On Jul 31, 1:32 am, "ssmit...@gmail.com" <ssmit...@gmail.com> wrote:
On Jul 26, 5:52 am, googler <pinaki_...@yahoo.com> wrote:



If I have a combinational 'always' block like this..

reg x, y;

always @(a or b or c or d)
begin
      x = a | b;
      y = c & d;
      x = x ^ y;
end

then my question is, is there anything wrong with the above in terms
of performing synthesis? I mean, we are assigning to x in the first
statement and then it is also present on the RHS of the third
statement, so by any chance, is there a possibility that a synthesis
tool will take this as a combinational loop (although it is not
present in the sensitivity list)? Or, will x be not used in synthesis
by the tool as it does not appear in the sensitivity list? Or even if
it works in some cases/tools, is it a good practice in general? Thanks.

My first time posting  here!
I would never write code like this. Not because i know is bad but i
suspect it may be bad coding-style.  I am a little confused as to
what  you are trying to accomplish by assigning x twice?  Would the
following code clear it up for you?

always_comb begin
  //x = a | b;
  y = c & d;
  x = (a|b) ^ y;
end
You can also use " always @ (*) " !!!! Since your X and Y change only
inside the block, and not any where outside, it should not cause any
problem. But it is definitely a bad coding style.

A Latch is inferred only when a particular variable is not assigned
any value in all possible executions on the block. So this does not
make a latch.

-Krishna Praveen M. R.
 

Welcome to EDABoard.com

Sponsor

Back
Top