2016-05-26 12 views
1

私はチャップからカウンターを実装しています。イッツカウンターの実装に間違いが見つかりません

// This file is part of www.nand2tetris.org 
    // and the book "The Elements of Computing Systems" 
    // by Nisan and Schocken, MIT Press. 
    // File name: projects/03/a/PC.hdl 

    /** 
    * A 16-bit counter with load and reset control bits. 
    * if  (reset[t] == 1) out[t+1] = 0 
    * else if (load[t] == 1) out[t+1] = in[t] 
    * else if (inc[t] == 1) out[t+1] = out[t] + 1 (integer addition) 
    * else     out[t+1] = out[t] 
    */ 

    CHIP PC { 
     IN in[16], load, inc, reset; 
     OUT out[16]; 
     //sel=0; a;sel=1;b 
     PARTS: 
     //reset 
     Not16(in=true, out=resetted); 
     //inc 
     Inc16(in=t, out=incremented); 
     //Choose input between reset and out[t] 
     Mux16(a=t,b=resetted,sel=reset,out=o1); 
     //Choose input between o1 and in[t](load) 
     Mux16(a=o1, b=in,sel=load,out=o2); 
     //Choose input between o2 and inc 
     Mux16(a=o2,b=incremented, sel=inc, out=o3); 
     Register(in=o3, load=load, out=t, out=out); 
    } 

は、このテストで失敗するようだ:

set in -32123, 
tick, 
output 

これは、私は私のミス(複数可)を見つけることができない、5行目である3。ここに私のコードです。すべてのヘルプは

答えて

0

ヒント(これはすべての後に、学習運動であるため)評価されて:

をあなたの新しい値を生成するために、マルチプレクサのカスケードを行っているが、どのような状況の下で、あなたは登録を更新していますか?

提案:バック第2章へ

行くと、彼らはあなたがMux4Way16コンポーネントを実装していたことに気づきます。それを使用すると、あなたの人生はずっと楽になります。

また、入力としてfalseを使用することができ、自動的に必要な幅になります。したがって、あなたはNot16を通して真実に走って偽りを得る必要はありません[16]。

+0

また、検索エンジンを使用して誰かがここに来た場合、私はそれが動作するように操作の順序を変更しなければならなかったことに気付きたい(なぜこれが機能するのか分かりません)。 –

関連する問題