プロが教える店舗&オフィスのセキュリティ対策術

現在Z8085のCPUを設計しており、テンポラリレジスタにラッチする部分でなかなか上手くいきませんので質問させていただきます。

always文を使用したステートマシンにより制御しようとしているのですが次のようなWarningが出ます。


Warning: Latch IR[0]$latch has unsafe behavior
Warning: Latch IR[1]$latch has unsafe behavior
           :
Warning: Latch IR[7]$latch has unsafe behavior
Warning: Latch TMP1[0]$latch has unsafe behavior
Warning: Latch TMP1[1]$latch has unsafe behavior
           :
Warning: Latch TMP1[7]$latch has unsafe behavior
Warning: Latch TMP2[0]$latch has unsafe behavior
Warning: Latch TMP2[1]$latch has unsafe behavior
           :
Warning: Latch TMP2[7]$latch has unsafe behavior
Warning: Latch NEXT_STATE[0]$latch has unsafe behavior
Warning: Latch NEXT_STATE[1]$latch has unsafe behavior


<ソース>
module CPU_TMP( CLK, nRST, FROM_DCD, IR, TMP1, TMP2, STATE, NEXT_STATE );

input CLK;//クロック
input nRST;//リセット
input [7:0] FROM_DCD;//入力命令

output [7:0] IR;//命令レジスタ
output [7:0] TMP1;//テンポラリレジスタ1
output [7:0] TMP2;//テンポラリレジスタ2
output [1:0] STATE;//現在のステート
output [1:0] NEXT_STATE;//次のステート

reg [7:0] IR;
reg [7:0] TMP1;
reg [7:0] TMP2;
reg [1:0] STATE;
reg [1:0] NEXT_STATE;

//状態
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter SD = 2'b11;

//命令
parameter INRA = 8'h11;
parameter MVIA = 8'h22;
parameter JMP = 8'h33;



always @( posedge CLK )
begin
    if( nRST == 0 )
      STATE <= SD;
    else
      STATE <= NEXT_STATE;
end


always @( STATE )
begin
   case( STATE )
     SD : begin
           IR <= 0;
           TMP1 <= 0;
           TMP2 <= 0;
           NEXT_STATE <= S0;
         end
     S0 : begin
           IR <= FROM_DCD;
           case( FROM_DCD )
             INRA: NEXT_STATE <= S0;
             MVIA: NEXT_STATE <= S1;
             JMP: NEXT_STATE <= S2;
           endcase
         end
     S1 : begin
             TMP1 <= FROM_DCD;
             NEXT_STATE <= S0;
         end
     S2 : begin
             TMP2 <= FROM_DCD;
             NEXT_STATE <= S0;
         end
endcase
end


endmodule


どのようにしたらこのWarningを消すことができるでしょうか。

A 回答 (1件)

お手持ちの教科書等を見てみましょう。


「always文で組み合わせ回路を書くときにcase文などで全ての条件を記述していないとラッチが生成される」と書いてありませんか?

私はalways文で組み合わせ回路は一切書きません。reg宣言したものがFFでないというのに違和感がありますし、可読性が悪くなり他人が見たとき混乱します。
複雑な組み合わせ回路はfunctionを使って切り分けています。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!