ALU Help

Discussion in 'Community Discussion' started by DoFoT9, Apr 8, 2008.

  1. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #1
    hey all,

    just started uni this year, and i have to create a ALU (Logical AND, Logical OR, Logical XOR, Full Adder, Subtraction, Shift A Through, Shift A Left, Shift A Right).

    we are using "digital works", not sure if any1 has used that before.

    my question is this:
    we have not been shown how to join all of the smaller parts together, ive made the full adder, subtractor etc but im not sure how to put them all together. surely they cant just go together in any which way??

    anyways, hope this is in the right section!

    thanks in advance,

    DoFoT9
     
  2. theyoda3 macrumors member

    Joined:
    Sep 27, 2006
    #2
    Hey,

    I think I can help you a little bit because I am actually doing the same project right now, though I have not finished making all my parts.

    So, assuming you built all your individual functions correctly and according to your assignment specifications then all you need is a way to select which function to use. ALUs calculate all the functions at once and then select which one to use based on the instruction. Using the results of your different functions as inputs, a multiplexer (mux) can be used with a 3 or 4 bit selection line depending on how you set up your functions. Each binary number can represent a different function. The output of the mux will then be the result of the function of the two inputs that you selected.
     
  3. DoFoT9 thread starter macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #3
    hey, thanks for the reply!

    i have no idea how my functions are set up. ive just made them individually in "digital works" and want to import them all into make one 1-bit ALU. thats all ive got lol i cant do anymore, so confused.
     
  4. DoFoT9 thread starter macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #4
    ok so ive been working on all my components all day, ive got a whole bunch of my components made and templates are good to go. they have given a small example of a 4 function, 4 bit ALU (attached). they have specified that if you want to get extra marks you can do a harder 8 function, 4 bit ALU with the functions specified in my above post, (which i am choosing to do and thus this post)

    so yea im still wondering how the hell do i connect each component together so that they work??

    they dont tell us anything here. so vague in the tut's. gayar.
     

    Attached Files:

  5. theyoda3 macrumors member

    Joined:
    Sep 27, 2006
    #5
    What coding language are you using? For example, VHDL, Verilog, etc.
     
  6. DoFoT9 thread starter macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #6
    we arent using one, just using a UI based program.
     
  7. theyoda3 macrumors member

    Joined:
    Sep 27, 2006
    #7
    Hmm, well I do not use UI based systems for digital design, but it should be a similar process to coding. First, make sure all your individual functions work properly by testing them in waveform simulations. Each function should have its own file. Then to make the ALU, open a new file and insert the circuits for all the other functions and insert the mux. Then just connect all your signal lines. You should be able to simulate this with waveforms also.

    A lot of programs have project files to store all the device files you have made. When you insert a device into a file you usually reference it and assign the inputs and outputs. At simulation time, the software you use will call each individual component you referred to and be able to simulate a large device, such as the ALU.

    If you this is not helpful to you, then you should ask a student in your class or a professor about how to use the software. I do not know how to use your software.
     
  8. theyoda3 macrumors member

    Joined:
    Sep 27, 2006
    #8
    Let me give you an example, this might be more helpful.

    module ALU(A,B,C,E);
    // the ALU device has input A, input B, output C, and select line E
    input [63:0]A,B;
    // A and B are 64 bits long
    input [2:0]E;
    // the select line is 3 bits, base 10 number '0-7'
    output [63:0]C;
    // C is 64 bits long
    wire [63:0]Cxor,Cand,Cor,Cshift,Cneg,Caddsub;
    // these wires are 64 bits long each and they are used to connect the output of each function to the input of the ALU's mux
    wire Co;
    // this wire is 1 bit long and used as the carry from the add or subtract functions

    AddSub_64bit unit1(A,B,E[0],Co,Caddsub);
    // this calls my add/subtract device using the signals from the ALU and the wires mentioned before
    // the E[0] refers to the most significant bit of my select signal for the mux to make my adder add ,0, or subtract ,1
    AltShifter unit2(A,B,Cshift,E[1]);
    // this calls my shifter and makes in the same way as the other device
    // the E[1] refers to the middle bit of the select line and is used to make my shifter shift left ,0, or shift right ,1
    and_64bit unit3(A,B,Cand);
    // this calls my AND device with input and outputs assigned like the pervious devices
    // all my other devices are listed the same way, but I omitted them


    // Two lines of code go here, but I omitted them

    // to select each function based on the select line I used a case statement
    // '0-7' are the base 10 numbers for the 3 bit binary select line E
    // my guess is that UI program would just assign selection numbers from the lines connected from top to bottom, 0 to the max value
    case(E)
    0:C=Caddsub;
    1:C=Cand;
    2:C=Cor;
    3:C=Cxor;
    4:C=Cshift;
    5:C=Cneg;
    6:C=Cshift;
    7:C=Caddsub;
    // C, the output of the ALU, is assigned the value of the selected function based on the select line
    // for example, the ALU will output 'A AND B' when the select line is '001' in binary

    // two other lines of code were omitted here


    Basically you have do something like this, but you just draw the lines and insert devices instead of writing code.
     
  9. DoFoT9 thread starter macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #9
    ok i tried following you code really closely, but unfortunately i have no experience with that kind of code and cant really understand it. they are teaching us the visual way, and not the coding way. so yea.

    its quite hard to do seeing as though the way they want us to do it is exactly the opposite as the way the internet/every single other person in the world has done it.
     
  10. Technicalman macrumors newbie

    Joined:
    Apr 27, 2008
    #10
    pleaseee help me

    pleaseeeeeee help meee someone i realli need to know how to make a 4 function 4-bit ALU in digital works 95
    how do u design a macro i have the three gates AnD, Or and Xor wired now i need a 1 bit ALU please please help me thank u
     

Share This Page