Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog combinational logic implementation, assign or always?

Status
Not open for further replies.

u931803

Newbie level 3
Newbie level 3
Joined
Apr 6, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
33
Verilog combinational logic coding style, assign or always?

Hello guys,

Today I had a discussion about Verilog coding style with a senior engineer

I personal prefer write combinational logic using assign
For example, assign cnt_w = incr ? cnt_r + 1 : cnt_r;

However, he said combinational logic should be coded using always for the following reason
1. Continuous assignment slows down simulation speed
2. Synthesis tool can optimize always better than assign
3. All assign can be realized by always, but not all always can be realized by assign

I agree with the first reason
But I wonder if the second is true with contemporary synthesis tools such as design compiler
Also I think assign and always are convertible both ways (except, of course, if you use for loop)

Does anyone have and idea?

Thanks a lot
 

As a general statement, I don't believe any of those statements are correct.

  1. For the same algorithm, code written in the highest level of abstraction will simulate the fastest. This might be at the expense of accurately modeling the propagation of physical delays or X's.
  2. Again, the level of abstraction determines the level of difficulty for a synthesis tool to optimize your code. If you were to write the same code above as an always block, a synthesis tool would see it as equivalent.
    Code:
    always @(incr or cnt_r) if (incr) 
                                             cnt_w = cnt_r + 1;
                                      else
                                      cnt_w =  cnt_r;
  3. It is certainly easier to write some code with an always block using procedural code, but not impossible.
 

As a general statement, I don't believe any of those statements are correct.

  1. For the same algorithm, code written in the highest level of abstraction will simulate the fastest. This might be at the expense of accurately modeling the propagation of physical delays or X's.
  2. Again, the level of abstraction determines the level of difficulty for a synthesis tool to optimize your code. If you were to write the same code above as an always block, a synthesis tool would see it as equivalent.
    Code:
    always @(incr or cnt_r) if (incr) 
                                             cnt_w = cnt_r + 1;
                                      else
                                      cnt_w =  cnt_r;
  3. It is certainly easier to write some code with an always block using procedural code, but not impossible.

Thanks for you reply

That's what I thought, they should be the same as long as the intended underlying circuits are the same
He said that he attended a training course and the tutor with decent knowledge in synthesis tool pointed out synthesis tool tends to optimize always better than assign
But it was years ago, I am just wondering if this statement is still true or if it's actually never true
 

Our design rule is to write the code in the clearest way, which means both are accepted, if that make the code simplest and readable.
I means a assign with multiple and or xor, could be not clear instead a if (a=xxxx &....).
During the code review, this could requested to change the code and a LEC tool will confirm the no functional modification.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top