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.

which style is better

Status
Not open for further replies.

alpacinoliu

Member level 3
Joined
Nov 14, 2004
Messages
58
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
464
I:
assign out = (sel)?a:b;

II:
always @(sel or a or b) begin
if (sel)
out = a;
else
out = b;
end

somebody tell me I ,However others tell me II;
which is better or same. why?

thanks in advance
 

You know that there two kinds of models in Verilog descriptions, one is called "behavioral model" and the other one is called "logical model". It's usually recommended to use "logical model" in designs. In my opinion, both of them are "behavioral model", that means how this functional is sythesized is not controlled by you, but depends on the synthesizing tool you use. So, I think both of them are OK, or both of them are not OK. It's not important, becasue they are the same, except that you have another choise -- a logical model, which tell the synnthesizer how to implement this logic explicitly.
 
Yes, both give the same results.
I use method #1 because it's compact.
Method #2 is good if work for a stuffy company that pays you for each line of code you write. ;)
 

cevitamic said:
You know that there two kinds of models in Verilog descriptions, one is called "behavioral model" and the other one is called "logical model". It's usually recommended to use "logical model" in designs. In my opinion, both of them are "behavioral model", that means how this functional is sythesized is not controlled by you, but depends on the synthesizing tool you use. So, I think both of them are OK, or both of them are not OK. It's not important, becasue they are the same, except that you have another choise -- a logical model, which tell the synnthesizer how to implement this logic explicitly.

hi cevitamic
you can describe the function of codes above in the "logical model".
thank you
 

both gives the same result.....so y u want to write long statement for (II).....
 

As said both give the same results. However the first model is prefered because no sensitivity list is used and you can avoid errors by forgetting to put signals in the list.
If the code is more complex with nested if statements then the second model is more readable and thus better to use.
I think in the second model the <= should be used and not the =
 

It is not sequential circuit. It is natural to use "=", not "<=".

I use style I when the multi selection signals is one hot encoded. On the others, the style II is used.
But I use case statement instead of if-else.
It it the reason that case statement is no priority normally.

Regards,
Jarod
 

I suggest style II.
for this struture is easy to understand. and it accords with hardware implementation principle of logic circuits
 

hi,

see there r 3 models in verilog

data flow modelling
behavioural
structural


I st one what u have given is data flow
II nd one is behavioural

the result i.e the hardware of both style is same,
but most of the designers use behavioural modelling ( easy to understand , if u r not sure abt
internal design of a system use this modelling )
but for ur system i.e MUX I st type is good.

cheers,

venus
 

Hi,
Don't you think more registers will be inferred in the behavioral style of modelling?
 

if it is a combinational logic go for the above style else go for the procedural style.
 

hi,
first one will give you minimised circuit while second one can give priority based structure.

with regards,
kul.
 

I use the 1st one. because the code is less.
The two method is synthesized into the same circuit.
 

II is better, because II is more readable and easy to be understood.

alpacinoliu said:
I:
assign out = (sel)?a:b;

II:
always @(sel or a or b) begin
if (sel)
out = a;
else
out = b;
end

somebody tell me I ,However others tell me II;
which is better or same. why?

thanks in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top