Adding FSM to Processor RTL-Processor Design Series-Final Edition

Adding FSM to Processor RTL-Processor Design Series-Final Edition

Article content

That is why

Article content


Article content
Reset Detector 
always@(posedge clk)
begin
 if(sys_rst)
   state <= idle;
 else
   state <= next_state; 
end        
Article content
 idle: begin
     IR         = 32'h0;
     PC         = 0;
     next_state = fetch_inst;
   end
 
  fetch_inst: begin
    IR          =  inst_mem[PC];   
    next_state  = dec_exec_inst;
  end        
 dec_exec_inst: begin
    decode_inst();
    decode_condflag();
    next_state  = delay_next_inst;   
  end        

With this we have decoded the instruction, we will be giving a delay for next instruction to be loaded

which we will discuss soon!

Article content
  next_inst: begin
      next_state = sense_halt;
      if(jmp_flag == 1'b1)
        PC = `isrc;
      else
        PC = PC + 1;
  end        
sense_halt: begin
    if(stop == 1'b0)
      next_state = fetch_inst;
    else if(sys_rst == 1'b1)
      next_state = idle;
    else
      next_state = sense_halt;
 end        
//////////////////next state decoder + output decoder
 
always@(*) * because it is a combinational block
begin
  case(state)
   idle: begin
     IR         = 32'h0;
     PC         = 0;
     next_state = fetch_inst;
   end
 
  fetch_inst: begin
    IR          =  inst_mem[PC];   
    next_state  = dec_exec_inst;
  end
  
  dec_exec_inst: begin
    decode_inst();
    decode_condflag();
    next_state  = delay_next_inst;   
  end
  
  
  delay_next_inst:begin

  end
  
  next_inst: begin
      next_state = sense_halt;
      if(jmp_flag == 1'b1)
        PC = `isrc;
      else
        PC = PC + 1;
  end
  
  
 sense_halt: begin
    if(stop == 1'b0)
      next_state = fetch_inst;
    else if(sys_rst == 1'b1)
      next_state = idle;
    else
      next_state = sense_halt;
 end
  
  default : next_state = idle;
  
  endcase
  
end
         

Integrating delay in above combinational circuit will not work..

Because it is sequential so we will create a new always clock block with positive edge of clock

Article content

Now we know that next instruction will be fetched after count of 4

Article content
  delay_next_inst:begin
  if(count < 4)
       next_state  = delay_next_inst;       
     else
       next_state  = next_inst;
  end        
 
always@(posedge clk)
begin
case(state)
 
 idle : begin
    count <= 0;
 end
 
 fetch_inst: begin
   count <= 0;
 end
 
 dec_exec_inst : begin
   count <= 0;    
 end  
 
 delay_next_inst: begin
   count  <= count + 1;
 end
 
  next_inst : begin
    count <= 0;
 end
 
  sense_halt : begin
    count <= 0;
 end
 
 default : count <= 0;
 
  
endcase        

With this edition we end the Processor Design series..

What is the CFBR

Like
Reply
Chinna Venkata Narayana Reddy Seelam

Jr. R&D Engineer @Synopsys | Ex-STMicroelectronics | Physical Verification | PDK | CAD | Sign-Off | VLSI Voyager | AI Maestro | VIT'25 | LinkedIn Limits on connections So Please DM me @Whatsaap (9063958119)

1y

#CFBR

To view or add a comment, sign in

More articles by Anoushka Tripathi

Insights from the community

Others also viewed

Explore topics