Altera_Forum
Honored Contributor
11 years agoveilog code for demux unwanted latch at demux output problem
hey guys!! here is my code for 1:16 demux in verilog (quartus 2)
module demux(sel, din , dout0 , dout1 ,dout2 , dout3 , dout4 , dout5 ,dout6 ,dout7 ,
dout8 ,dout9 , dout10 , dout1 , dout12 , dout13 , dout14 , dout15);
input din;
input sel;
output dout0 ,dout1 ,dout2 ,dout3 ,dout4 ,dout5 ,dout6 ,dout7,
dout8, dout9, dout10, dout11 ,dout12 ,dout13 , dout14 ,dout15;
reg dout0 ,dout1,dout2 ,dout3 ,dout4 ,dout5 ,dout6 ,dout7,
dout8 ,dout9 ,dout10 ,dout11 ,dout12 ,dout13 ,dout14 ,dout15 ;
always @(sel or din) begin
case(sel)
4'b0000: dout0 = din ;
4'b0001: dout1 = din ;
4'b0010: dout2 = din ;
4'b0011: dout3 = din ;
4'b0100: dout4 = din ;
4'b0101: dout5 = din ;
4'b0110: dout6 = din ;
4'b0111: dout7 = din ;
4'b1000: dout8 = din ;
4'b1001: dout9 = din ;
4'b1010: dout10 = din ;
4'b1011: dout11 = din ;
4'b1100: dout12 = din ;
4'b1101: dout13 = din;
4'b1110: dout14 = din;
4'b1111: dout15 = din;
endcase
end
endmodule after compilation i get this warning : [h=3]verilog hdl always construct warning at <location>: inferring latch(es) for variable "<name>", which holds its previous value in one or more paths through the always construct[/h] how can i write this code without getting this warning because i do not want any latches there... any help is welcome.