1 / 5

Arithmetic Logic Unit (ALU)

Arithmetic Logic Unit (ALU). Lecture L7.5 Section 7.5. ALU. MODULE alu interface([A3..A0],[B3..B0], [s2..s0] -> [Y3..Y0],CF,OVF,ZF,NF); TITLE '4-bit ALU' DECLARATIONS " INPUT PINS " A3..A0 PIN; A = [A3..A0]; " 4-bit input A B3..B0 PIN; B = [B3..B0]; " 4-bit input B

Download Presentation

Arithmetic Logic Unit (ALU)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arithmetic Logic Unit (ALU) Lecture L7.5 Section 7.5

  2. ALU

  3. MODULE alu interface([A3..A0],[B3..B0], [s2..s0] -> [Y3..Y0],CF,OVF,ZF,NF); TITLE '4-bit ALU' DECLARATIONS " INPUT PINS " A3..A0 PIN; A = [A3..A0]; " 4-bit input A B3..B0 PIN; B = [B3..B0]; " 4-bit input B s2..s0 PIN; S = [s2..s0]; " 3-bit control input " OUTPUT PINS " Y3..Y0 PIN; Y = [Y3..Y0]; " 4-bit output Y CF, OVF, ZF, NF PIN ISTYPE 'com';

  4. " INTERMEDIATE NODES " C4..C0 NODE ISTYPE 'com'; " internal carry vector Cin = [C3..C0]; " carry input vector Cout = [C4..C1]; " carry output vector E1 = !s2 & s1 & s0; " [E1,E2] = [0,1] for A - B E2 = !s2 & s1 & !s0; " [E1,E2] = [1,0] for B - A E = E1 # E2; Ain = A $ E1; " E1 = 1 for subtraction Bin = B $ E2; " E2 = 1 for subtraction not = !A; and = A & B; or = A # B; xorr = A $ B; SD = Ain $ Bin $ Cin; " sum/difference output

  5. EQUATIONS C0 = E1 # E2; " E1 # E2 = 1 for subtraction Cout = Ain & Bin # (Ain $ Bin) & Cin; " carry/borrow output vector ZF = !Y3 & !Y2 & !Y1 & !Y0; " zero flag NF = Y3; " negative flag when (S == 0) then {Y = A; CF = 0; OVF = 0;} " A when (S == 1) then {Y = SD; CF = C4 $ E; OVF = C3 $ C4;} " A + B when (S == 2) then {Y = SD; CF = C4 $ E; OVF = C3 $ C4;} " A - B when (S == 3) then {Y = SD; CF = C4 $ E; OVF = C3 $ C4;} " B - A when (S == 4) then {Y = not; CF = 0; OVF = 0;} " NOT when (S == 5) then {Y = and; CF = 0; OVF = 0;} " AND when (S == 6) then {Y = or; CF = 0; OVF = 0;} " OR when (S == 7) then {Y = xorr; CF = 0; OVF = 0;} " XOR END alu

More Related