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.

combinatorial logic coding style question

Status
Not open for further replies.

Spud

Newbie level 1
Joined
Apr 22, 2008
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
Hello all,

I am new to here. I've read some threads that very helpful to me and I'm confused about a question.
As for combinatorial logic coding, the following coding style is suggested instead of assignment statements. Please see below simple clk switch procedure:
------------------------------------------------------------------
always @ ( func_en )
begin
if ( func_en )
begin
output <= clk1;
end
else
begin
output <= clk2;
end
end
------------------------------------------------------------------

instead of

------------------------------------------------------------------
wire output = func_en ? clk1 : clk2;
------------------------------------------------------------------
My question is that should clk1 & clk2 need to be added to sensitivity list ? because
Quartus always warns me about that.

My another question is about combinatorial logic coding style, too.
Please explains to me if the following three procedure generates the same
logic or not? Which coding style is better? thanks for reading this post and
for your replies.
-1. --------------------------------------------------------------
wire output_clk = clk1 ^ clk2;
------------------------------------------------------------------
-2. --------------------------------------------------------------
always @ ( clk1 or clk2 )
begin
output_clk = clk1 ^ clk;
end

-3. --------------------------------------------------------------
always @ ( clk1 or clk2 )
begin
if ( clk1 & clk2 )
begin
output_clk <= 0;
end
else if ( clk1 & ~clk2 )
begin
output_clk <= 1;
end
else if ( ~clk1 & clk2 )
begin
output_clk <= 1;
end
else
begin
output_clk <= 0;
end
end
------------------------------------------------------------------
 

yhaaaaaaa U need to add clk1 and clk2 to ur sensitivity list otherwise the synthesis tool infers latch for output because of the changes in clk1 & clk2 not evaluate the circuit operation
 

if you do not write clk1 and clk2 in sensitivity list.. then hardware generated will be right and synthesis will be right. but in simulation you will get the wrong out put. and your synthesis and simulation result will be differ.

there are some constructs which are ignored by the synthesis tool.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top