2015-07-24 6 views
0

Когда я моделирую приведенный ниже модуль в Modelsim, я не видел никакой выходной волны для cikis, пожалуйста, дайте мне знать, что пошло не так с этим FSM и скамье.verilog, FSM, конечный автомат, ошибка

У меня есть 3 входа и 1 выход для модуля.

module sayici_fsm(clock, reset,cikis, out); 

    input wire clock; 
    input wire reset; 

    output reg [2:0] cikis; 
    output wire  out; 

    localparam durum0 = 3'd0, 
       durum1 = 3'd1, 
       durum2 = 3'd2, 
       durum3 = 3'd3, 
       durum4 = 3'd4, 
       durum5 = 3'd5, 
       durum6 = 3'd6, 
       durum7 = 3'd7; 

    reg [2:0] currentstate; 
    reg [2:0] nextstate; 

    assign out = (durum1& durum3); 

    always @(*) begin 
     cikis = 3'b000; 
     case (currentstate) 
      durum0: 
      begin 
       cikis = 3'b000; 
      end 
      durum1: 
      begin 
       cikis = 3'b000; 
      end 
      durum2: 
      begin 
       cikis = 3'b010; 
      end 
      durum3: 
      begin 
       cikis = 3'b100; 
      end 
      durum4: 
      begin 
       cikis = 3'b110; 
      end 
     endcase 
    end 

    always @(posedge clock) begin 
    if(reset) currentstate <= durum0 ; 
    else  currentstate <= nextstate; 
    end 

    always @(*) begin 
    nextstate =currentstate; 
     case (currentstate) 
     durum0: 
      begin 
      nextstate = durum1; 
      end 
     durum1: 
      begin 
      nextstate = durum2; 
      end 
     durum2: 
      begin 
      nextstate = durum3; 
      end 
     durum3: 
      begin 
      nextstate = durum4; 
      end 
     durum4: 
      begin 
      nextstate = durum1; 
      end 
     durum5: 
      begin 
      nextstate = durum0; 
      end 
     durum6: 
      begin 
      nextstate = durum0; 
      end 
      durum7: 
      begin 
       nextstate = durum0; 
      end 
     endcase 
    end  
    endmodule 

module sayici_fsm_tb(); 

wire [2:0] cikis; 
wire  out; 

reg clock;  
reg reset;  

sayici_fsm u1(.out (out ), 
       .clock (clock), 
       .cikis (cikis), 
       .reset (reset) 
      ); 

initial 
begin 
    $display($time, "Similasyon Baslasin"); 
    $display(" Time clock reset enable giris cikis"); 
    $monitor ("time =%d, clock =%b, reset=%b, cikis=%b out =%b", $time, clock, reset, cikis,out); 

    reset = 1'b1; 
    clock = 1'b0; 
#5 reset = 1'b0; 
    clock = 1'b1; 
#100 $finish; 
end 

always #7 clock =!clock; 

endmodule 
+0

Вы видите часы в моделях модели? – TM90

ответ

2

Ошибка при генерации сброса в тестбенче, так как не правильно инициализирован cikis идет по умолчанию значения «х»

 reset = 1'b1; 
    clock = 1'b0; 
    #5 reset = 1'b0; // give more time so that at posedge of clk reset is asserted say #8 
    clock = 1'b1; // remove from tb 
    #100 $finish; 
end 
always #7 clock =!clock; 

Из приведенного выше фрагмента кода сброса собирается на низком уровне 5 нса но часы получает первый posedge на 7 нс, в течение posedge тактового сигнала текущее состояние кодируется, чтобы получить значение durum0, как упомянуто ниже

always @(posedge clock) begin 
if(reset) currentstate <= durum0 ; 
else  currentstate <= nextstate; 
end 

чтобы решить ERR или дождитесь значительного количества часов и переустановите шину.

Смежные вопросы