A specific cominational function can be coded in several ways. (See examples below)
(1) Will different HDL implementations be synthesized differently?
(2) If (1) is true, are there any guidelines of which coding style is better?
for example - Find First Set
module FFS_1(input wire [2:0] i, output wire [1:0] o);
assign o = (i==0)?2'bxx:(i==1)?2'b01:(i<4)?2b'10:2'b11;
module FFS_2(input wire [2:0] i, output reg [1:0] o);
integer j, found;
found = 0;
o = 2'bx;
for (j=2; j>0; j=j-1)
if (i[j] && !found)
found = 1;
o = j;
Both modules are pure combinational logic and describe the exact same function (find first set bit with DC for input=0). Will the two have the same gate level implementation?
Of course, this is only an example of a simple function (3b-->2b) so any student can use karnaugh maps to minimize. But I can think of a much more complicated example - change the input vector to be 100 bits wide, another input indicates a cyclic shift to apply to the input vecor, and the output are the indices of the 10 first set bits. This function is much easier to describe using an always block, it's easier to code, easier to read, and easier to change in case the function has to be changed. This is a 107b-->70b function... Will both styles result with same gate level? Can I expect one coding style to be better than the other (area/timing/etc.)?
Of course, I'm only talking about the combinational parts, if I use more/less flops I won't expect same results, but my question is about the logic in between. Are there any guidelines?
Thanks in advance