Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

Demultiplexer with latched value

Altera_Forum
Honored Contributor II
1,838 Views

I am using a demultiplexer with six output registers. The code is pretty simple.  

 

process(X,sel) begin case sel is when "000"=> A <=X; when "001" => B <=X; when "010" => C <=X; when "011" => D <= X; when "100" => E <= X; when "101" => F <= X; when others =>null; end case; end process; 

 

I do not reset output regisers since I want to preserve them. That is why I get the following warnings. 

 

 

 

--- Quote Start ---  

Warning (10631): VHDL Process Statement warning at demux.vhd(21): inferring latch(es) for signal or variable "C", which holds its previous value in one or more paths through the process 

--- Quote End ---  

 

 

 

 

--- Quote Start ---  

Warning: Found 9 node(s) in clock paths which may be acting as ripple and/or gated clocks -- node(s) analyzed as buffer(s) resulting in clock skew 

--- Quote End ---  

 

 

Why is wrong to have latched output registers?  

 

What do I need to do to remove them?
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
951 Views

Hi, 

Have a read of http://www.altera.com/literature/hb/qts/qts_qii51007.pdf page 42 it explains why latches are a bad idea. In short FPGAs are built out of storage elements that are all connected to a common clock.
0 Kudos
Altera_Forum
Honored Contributor II
951 Views

Thanks Uk Fixer. I found a solution added a clock to sensitivity list.

0 Kudos
Altera_Forum
Honored Contributor II
951 Views

In fact, demultiplexers aren't often used. Instead, a decoder providing clock-enable signals is preferred. 

 

Nevertheless, your VHDL code must assign every signal in order to avoid parasite latches. 

 

 

 

process(X,sel) begin case sel is when "000"=> A<=X; B<=(others=>'0'); C<=(others=>'0'); D<=(others=>'0'); E<=(others=>'0'); F<=(others=>'0'); when "001" => A<=(others=>'0'); B<=X; C<=(others=>'0'); D<=(others=>'0'); E<=(others=>'0'); F<=(others=>'0'); when "010" => A<=(others=>'0'); B<=(others=>'0'); C<=X; D<=(others=>'0'); E<=(others=>'0'); F<=(others=>'0'); when "011" => A<=(others=>'0'); B<=(others=>'0'); C<=(others=>'0'); D<=X; E<=(others=>'0'); F<=(others=>'0'); when "100" => A<=(others=>'0'); B<=(others=>'0'); C<=(others=>'0'); D<=(others=>'0'); E<=X; F<=(others=>'0'); when "101" => A<=(others=>'0'); B<=(others=>'0'); C<=(others=>'0'); D<=(others=>'0'); E<=(others=>'0'); F<=X; end case; end process;
0 Kudos
Altera_Forum
Honored Contributor II
951 Views

parrado wrote: 

 

--- Quote Start ---  

your VHDL code must assign every signal in order to avoid parasite latches 

--- Quote End ---  

 

 

It does not have to. As I wrote , I needed to retain the values on each itteration of next register being sent to output.  

 

that is why , i could not issue statements such as 

B<=(others=>'0'); 

 

It would reset tha value of corresponding output pins to zero, which I don't want. 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
951 Views

Yeah, you have used the first approach. 

 

 

--- Quote Start ---  

 

Instead, a decoder providing clock-enable signals is preferred. 

 

--- Quote End ---  

0 Kudos
Reply