UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Newbie yinbinjun
Newbie
305 Views
Registered: ‎12-10-2018

waring [Synth 8-327] inferring latch for variable 'next_s_reg'

reg   [3:0]     curr_s;        		//FSM current state
reg   [3:0]     next_s;        		//FSM next state

always @(posedge clk_r or negedge rst_n)
begin
    if(!rst_n)
        curr_s <= idle_s;
    else  begin 
        curr_s <= next_s;
    end
end
// FSM second level
always @(*)
begin
    case (curr_s)
            idle_s    : begin
                        if( PS2PL_signal[2:0] == 3'b001 )	
                            next_s = load_BN_s; // waring inferring latch
                        else if( PS2PL_signal[2:0] == 3'b010 )
                            next_s = load_WF_s;
                        else next_s = idle_s; 					
                    end
            load_BN_s : begin 
                        if( loadBN_cnt == ParaLoadBN )  
                            next_s = load_WF_s;
                        else next_s = load_BN_s;         							
                    end	
            load_WF_s : begin 
                         if( loadWF_cnt == ParaLoadWF ) 
                             next_s = calc_AB_s;
                         else next_s = load_WF_s;                                     
                    end          			
            calc_AB_s : begin
			 if( DMA_cnt < ParaAllOutMapDMA && conv_cnt == ParaCNNCalc )
				next_s = calc_BA_s;
                         else if( DMA_cnt == ParaAllOutMapDMA && conv_cnt == ParaCNNCalc) 
				next_s = idle_s;
			 else next_s = calc_AB_s;      
                    end 
            calc_BA_s : begin 
			 if( DMA_cnt < ParaAllOutMapDMA && conv_cnt == ParaCNNCalc )
				next_s = calc_AB_s;
                         else if( DMA_cnt == ParaAllOutMapDMA && conv_cnt == ParaCNNCalc) 
				next_s = idle_s;
			 else next_s = calc_BA_s;                          
                    end	
        default   next_s <= idle_s;
    endcase		
end		

 

 

0 Kudos
6 Replies
Scholar drjohnsmith
Scholar
293 Views
Registered: ‎07-09-2009

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

try defining defining state machines as a single item, not a clocked and a none clocked process,
0 Kudos
Newbie yinbinjun
Newbie
290 Views
Registered: ‎12-10-2018

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

you mean that I need to split the state machine?

0 Kudos
Newbie yinbinjun
Newbie
287 Views
Registered: ‎12-10-2018

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

you mean that I need to split the state machine?
0 Kudos
Scholar drjohnsmith
Scholar
283 Views
Registered: ‎07-09-2009

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

the opposite, you currently have to parts, the clocked and the un clocked process,
0 Kudos
Scholar markcurry
Scholar
206 Views
Registered: ‎09-16-2009

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

I can't spot the latch - you look to have all conditions covered.  In any event, a catch-all solution to this is to always assign a "default" assignment near the beginning of your combinational procedural block 

// FSM second level
always @(*)
begin
   next_s = curr_s;  // Or some other "default" assignment -this "default" means when all else fails, stay in the same state.
   // add other state machine output "default" outputs here too 
   case (curr_s)
...

 

This suggestions is an alternative to drjohnsmith's suggestions of recoding as one always block.

Regards,

Mark

0 Kudos
Newbie yinbinjun
Newbie
191 Views
Registered: ‎12-10-2018

Re: waring [Synth 8-327] inferring latch for variable 'next_s_reg'

I have solved this problem
change
default next_s <= idle_s;