
This post was updated on .
I am not sure if anyone every tired this, but after solving for the ALU part, wanted to add more to the chip.
I wanted to add a multiplication capabilities.
This is the implement I tired:
CHIP Mul2bit {
IN a[2], b[2];
OUT out[4];
PARTS:
// First row of AND gates
And(a=a[0], b=b[0], out=c0);
And(a=a[0], b=b[1], out=w1);
// Second row of AND gates
And(a=a[1], b=b[0], out=w2);
And(a=a[1], b=b[1], out=w3);
// First half adder
HalfAdder(a=w1, b=w2, sum=c1, carry=carry1);
// Second half adder
HalfAdder(a=w3, b=carry1, sum=c2, carry=c3);
}
I also tried this as well:
CHIP Mul2bit{
IN a[2], b[2];
OUT out;
PARTS:
And(a=a[0], b=b[1], out=w1);
And(a=a[0], b=b[0], out=c0);
And(a=a[1], b=b[0], out=w2);
And(a=a[1], b=b[1], out=w3);
And(a=w1, b=w2, out=w4);
And(a=w4, b=w3, out=c3);
Xor(a=w1, b=w2, out=c1);
Xor(a=w4, b=w3, out=c2);
}
However, the problem I was having is that I needed to make a .tst and the .cmp files. I don't understand the .cmp, I am not sure what exactly it does. I also don't quite understand how the .tst file should be written with what syntax. Has anyone tired to make a custom chip? If you did make a custom chip did you have to write your own .tst file and .cmp file?
Some other questions I have is that, I was planning on building it up to 4bit multiplier, that said, would I need to implement it into the ALU and all of its .tst file and .cmp? Meaning would I need to update the truth table in .cmp file?
NOTE I CHANGED THE QUESTIONS A BIT TO MAKE IT MORE CLEAR WHAT I AM ASKING!
