2016-09-12 25 views
0

muxを使用せずにHack ALUを実装しようとしていますが、hdlをシミュレータにアップロードできません。どんな助けもありがとう。割り当ての双方が同じ幅を持っていないので、B [0..15] = notzxなどのおかげMuxを使用しないNand2tetris ALUの実装

CHIP ALU { 
    IN 
     x[16], y[16], // 16-bit inputs   
     zx, // zero the x input? 
     nx, // negate the x input? 
     zy, // zero the y input? 
     ny, // negate the y input? 
     f, // compute out = x + y (if 1) or x & y (if 0) 
     no; // negate the out output? 

    OUT 
     out[16], // 16-bit output 
     zr, // 1 if (out == 0), 0 otherwise 
     ng; // 1 if (out < 0), 0 otherwise 

    PARTS: 
    // Put you code here: 

    //To zero x or not 

    Not(in=zx, out=notzx); 
    And16(a=x, b[0..15]=notzx, out=zerox); 

    //To zero y or not 
    Not(in=zy, out=notzy); 
    And16(a=y, b[0..15]=notzy, out=zeroy); 

    //Negate x or not 

    Xor16(a=zerox, b[0..15]=nx, out=negatex); 


    //Negate y or not 
    Xor16(a=zeroy, b[0..15]=ny, out=negatey); 

    Not(in=f, out=fnot); 

    //"and" or "add" x? 

    And16(a=negatex, b[0..15]=f, out=addx); 
    And16(a=negatex, b[0..15]=fnot, out=andx); 

    //"and" or "add" y 

    And16(a=negatey, b[0..15]=f, out=addy); 
    And16(a=negatey, b[0..15]=fnot, out=andy); 

    //adding x and y 

    Add16(a=addx, b=addy, out=sum); 

    //anding x and y 
    And16(a=andx, b=andy, out=outxandy); 

    //output of adding or anding 

    Or16(a=sum, b=outxandy, out=out1); 

    //Negating using "Xor" 

    Xor16(a=out1, b[0..15]=no, out=out2); 
    Not(in=out2[15], out=ng); 
    Or8Way(in=out2[0..7], out=zr1); 
    Or8Way(in=out2[8..15], out=zr2); 
    Or(a=zr1, b=zr2, out=zr); 
    And16(a=out2, b=out2, out=out); 

答えて

0

入力はHDLには有効ではありません。可変幅を持つ唯一の値はtrueとfalseです。

あなたのような何か試してみてください:

AND16を(= X、B [0] = notzx、B [1] = notzx、...、B [15] = notzx、アウト= ZEROX);

+0

ここにまだ読み込まれない改訂版があります。 –

+0

@VikBhullar:あなたは改訂版を追加したようには見えないので、あなたに追加のフィードバックを与える方法はありません。 割り当ての両側が同じビット幅を持つ限り、入力を組み合わせることは可能です。例えば、ここに私のプロジェクトの1つから得た線があります: Mux16(a = ALUout、b [15] = false、b [0..14] = sel = aInstr、 out = AREGin); – MadOverlord

関連する問題