Saturday, August 25, 2012

4-bit ALU - Testing Chips

I have successfully tested 4 out of the 5 chips I need for the ALU. The multiplexor was giving me some trouble; hopefully I can figure out what was going wrong. I've tried several different chips, and I think whatever's going on is because of me, not faulty chips.

Here's a video of that testing in action, on the 4 good chips. While its not overly exciting, I want to document most of this project. So... enjoy?

4-bit ALU - Design

Today I finished coding my ALU in Hardware Description Language. I had already implemented a 16-bit ALU, so I didn't have to change much; I just switched all the 16-bit gates to 4-bit gates and substituted NAND gates for NOT gates, as I don't have any NOT gates. Though I came up with this particular implementation, the functionality was detailed in this book. Here's the truth table I used to build it:


As you can see, it performs a number of different functions, but it doesn't multiply or divide. While I may add that function to the 16-bit ALU, I'm sticking with these functions for the 4-bit ALU.

I've copied the code I wrote for the 4-bit ALU below. (NOTE: ALU CODE HAS BEEN CHANGED) The language is fairly self explanatory, but I've also included a link to the Hardware Simulator I used and materials explaining how to interpret it.

So far so good!

4-Bit ALU HDL Code v1.0

CHIP ALU4 {
    IN
        x[4], y[4],  // 4-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 out = x & y (if 0)
        no; // negate the out output?

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

    PARTS:
    Nand4(a[0]=zx, a[1]=zy, b=true, out[0]=w1, out[1]=w5);
    And4(a=x, b[0]=w1, b[1]=w1, b[2]=w1, b[3]=w1, out=w2);
    Nand4(a=w2, b=true, out=w3);
    Mux4(a=w2, b=w3, sel=nx, out=w4);
    And4(a=y, b[0]=w5, b[1]=w5, b[2]=w5, b[3]=w5, out=w6);
    Nand4(a=w6, b=true, out=w7);
    Mux4(a=w6, b=w7, sel=ny, out=w8);
    And4(a=w4, b=w8, out=w9);
    Add4(a=w4, b=w8, out=w10);
    Mux4(a=w9, b=w10, sel=f, out=w11);
    Nand4(a=w11, b=true, out=w12);
    Mux4(a=w11, b=w12, sel=no, out=w13, out=w14, out[3]=w15, out=out);
    Or4Way(in=w13, out=w16);
    Nand(a=w16, b=true, out=zr);
    And(a=w15, b=true, out=ng);
}

Thursday, August 23, 2012

4-bit ALU


This is the beginning of DupinComp. Though I don't quite know all the parts I need or the final design, I'm impatient, so I'm building the ALU before finishing the book. I haven't done any electrical engineering before, and I know very little about electricity, so I'm starting off with a 4-bit ALU. If it ends up not working, or I end up frying anything, then I've wasted less time and money than if I wired the 16-bit ALU I'll eventually need.  Here are all the components I'm using:

3 840 hole breadboards
3 spools of wire (1 green, 1 red, 1 black)
Arduino UNO (power supply)
2 DIP 8 slide switches (CTS 206-8)
4 NAND gates (sn74ls00n)
4 AND gates (sn74ls08n)
1 OR gate (sn74ls32n)
4 MUX gates (sn74hct157n)
1 Full Adder (sn7483n)

*Note: This list may change, if I find I need more parts

Though I planned out what I needed based on a design I had already tested with software, I'm tweaking it a little bit. Once I've written it down in HDL (hardware description language, for those who haven't read the book), I'll probably upload it.