|
Its been days since started implementation, but every time it fails test ,i dont know what to do next, can someone help me to fix the flaws.
PARTS:
//instruction handling
Mux16(a=instruction , b=aluout , sel=instruction[15] , out=insORalu );
//A register
And(a=instruction[15] , b=instruction[5] , out=arload );
Register(in=insORalu , load=arload , out=arout , out[0..14]=addressM );
//D register
And(a=instruction[15] , b=instruction[4] , out=drload );
Register(in=aluout , load=drload , out=drout );
//ALU second input decider
And(a=instruction[15] , b=instruction[12] , out=aORmload );
Mux16(a=arout , b=inM , sel=aORmload , out=aORm );
//ALU
And(a=instruction[15] , b=instruction[11] , out=zxin );
And(a=instruction[15] , b=instruction[10] , out=nxin );
And(a=instruction[15] , b=instruction[9] , out=zyin );
And(a=instruction[15] , b=instruction[8] , out=nyin );
And(a=instruction[15] , b=instruction[7] , out=fin );
And(a=instruction[15] , b=instruction[6] , out=noin );
ALU(x=drout , y=aORm , zx=zxin , nx=nxin ,
zy=zyin , ny=nyin , f=fin , no=noin ,out=aluout,
out=outM , zr=zrout , ng=ngout );
//writeM
And(a=instruction[15] , b=instruction[3] , out=writeM );
//pc load
Nand(a=zrout , b=ngout , out=JGT ); //JGT
Or(a=JGT , b=zrout , out=JGE ); //JGE
Not(in=zrout , out=JNE ); //JNE
Or(a=ngout , b=zrout , out=JLE ); //JLE
And(a=instruction[15] , b=instruction[0] , out=sel0 );
And(a=instruction[15] , b=instruction[1] , out=sel1 );
And(a=instruction[15] , b=instruction[2] , out=sel2 );
Mux8Way16(a[0]=false , b[0]=JGT , c[0]=zrout , d[0]=JGE ,e[0]=ngout ,f[0]=JNE,
g[0]=JLE , h[0]=true , sel[0]=sel0,sel[1]=sel1,sel[2]=sel2 , out[0]=pcload);
//program counter
PC(in=arout , load =pcload , inc=true , reset=reset , out[0..14]=pc );
|