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.

[SOLVED] using all conditions in if else statement

Status
Not open for further replies.

syedshan

Advanced Member level 1
Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Activity points
5,134
Dear all,

Hope every member of the forum is in best of health and peace

I was wondering that using all possible cases in if-else is necessary to avoid any parasitic latch. But When we have no other condition but to retain the value then what
to do since I think it will also cause the parasitic latch to occur...Please see the following code
Code:
reg [x:0] address;
always@(posedge clk)
if(rst) address <= 10'd0;
else 
if(m_en)
address <= address + 1'b1;
else address <= address;

In this case. since address is itself a reg, hence I understand no need to place the 'address <= address' with else but what else should I do so that I can avoid hidden latch.
Also what difference that latch can create...

Many thanks and Regards,
Shan
 

Hi,

reg is the only legal type on the left-hand side of an always block,and hence address should be of type reg

Please make this point clear in your mind

"Just making (address) or for that matter any net of type reg DOESENT mean that it will infer a register"


Also,avoid inferring latches when you want to implement some combinational logic inside always block...doesent mean you need to have all possible conditions for sequential always block.

Thanks,
Manoj
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top