1 / 38

Design of Networks for Arithmetic Operation

This document discusses the design of networks for arithmetic operations, including network constraints, control state graphs, and examples. It also covers binary multiplication and parallel division for positive binary numbers.

bmoss
Download Presentation

Design of Networks for Arithmetic Operation

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. Design of Networks for Arithmetic Operation DSD,USIT,GGSIPU

  2. Table 4-1 Operation of Serial Adder DSD,USIT,GGSIPU

  3. Fig. 4-2 Control State Graph and Table for Serial Adder DSD,USIT,GGSIPU

  4. State Graph for Control Networks Constraints on Input Labels for Every State Sk 1. If Ii and Ij are any pair of input labels on arcs exiting state Sk, then IiIj= 0 if i ¹j. 2. If n arcs exit state Sk and the n arcs have input labels I1, I2, ..., In,respectively, then I1 + I2 + ... + In = 1. DSD,USIT,GGSIPU

  5. Example 1 DSD,USIT,GGSIPU

  6. Example - 2 DSD,USIT,GGSIPU

  7. Design of a Binary Mulitplier DSD,USIT,GGSIPU

  8. DSD,USIT,GGSIPU

  9. DSD,USIT,GGSIPU

  10. DSD,USIT,GGSIPU

  11. DSD,USIT,GGSIPU

  12. DSD,USIT,GGSIPU

  13. DSD,USIT,GGSIPU

  14. DSD,USIT,GGSIPU

  15. DSD,USIT,GGSIPU

  16. DSD,USIT,GGSIPU

  17. Multiplication of Signed Binary Numbers DSD,USIT,GGSIPU

  18. DSD,USIT,GGSIPU

  19. DSD,USIT,GGSIPU

  20. DSD,USIT,GGSIPU

  21. DSD,USIT,GGSIPU

  22. DSD,USIT,GGSIPU

  23. DSD,USIT,GGSIPU

  24. Figure 4-12(a) Behavioural Model for 2’s Complement Multiplier library BITLIB; use BITLIB.bit_pack.all; entity mult2C is port (CLK, St: in bit; Mplier,Mcand : in bit_vector(3 downto 0); Product: out bit_vector (6 downto 0); Done: out bit); end mult2C; architecture behave1 of mult2C is signal State : integer range 0 to 5; signal A, B: bit_vector(3 downto 0); alias M: bit is B(0); begin process variable addout: bit_vector(4 downto 0); begin wait until CLK = '1'; case State is when 0=> -- initial State if St='1' then A <= "0000"; -- Begin cycle B <= Mplier; -- load the multiplier State <= 1; end if; DSD,USIT,GGSIPU

  25. Figure 4-12(b) Behavioral Model for 2’s Complement Multiplier when 1 | 2 | 3 => -- "add/shift" State if M = '1' then addout := add4(A,Mcand,'0'); -- Add multiplicand to A and shift A <= Mcand(3) & addout(3 downto 1); B <= addout(0) & B(3 downto 1); else A <= A(3) & A(3 downto 1); -- Arithmetic right shift B <= A(0) & B(3 downto 1); end if; State <= State + 1; when 4 => -- add complement if sign bit if M = '1' then -- of multiplier is 1 addout := add4(A, not Mcand,'1'); A <= not Mcand(3) & addout(3 downto 1); B <= addout(0) & B(3 downto 1); else A <= A(3) & A(3 downto 1); -- Arithmetic right shift B <= A(0) & B(3 downto 1); end if; State <= 5; wait for 0 ns; Done <= '1'; Product <= A(2 downto 0) & B; when 5 => -- output product State <= 0; Done <= '0'; end case; end process; end behave1; DSD,USIT,GGSIPU

  26. Figure 4-13 Command File and Simulation Results for (+5/8 by -3/8) -- command file to test signed multiplier list CLK St State A B Done Product force st 1 2, 0 22 force clk 1 0, 0 10 - repeat 20 -- (5/8 * -3/8) force Mcand 0101 force Mplier 1101 run 120 ns delta CLK St State A B Done Product 0 +1 1 0 0 0000 0000 0 0000000 2 +0 1 1 0 0000 0000 0 0000000 10 +0 0 1 0 0000 0000 0 0000000 20 +1 1 1 1 0000 1101 0 0000000 22 +0 1 0 1 0000 1101 0 0000000 30 +0 0 0 1 0000 1101 0 0000000 40 +1 1 0 2 0010 1110 0 0000000 50 +0 0 0 2 0010 1110 0 0000000 60 +1 1 0 3 0001 0111 0 0000000 70 +0 0 0 3 0001 0111 0 0000000 80 +1 1 0 4 0011 0011 0 0000000 90 +0 0 0 4 0011 0011 0 0000000 100 +2 1 0 5 1111 0001 1 1110001 110 +0 0 0 5 1111 0001 1 1110001 120 +1 1 0 0 1111 0001 0 1110001 DSD,USIT,GGSIPU

  27. Figure 4-14 Test Bench for Signed Multiplier library BITLIB; use BITLIB.bit_pack.all; entity testmult is end testmult; architecture test1 of testmult is component mult2C port(CLK, St: in bit; Mplier,Mcand : in bit_vector(3 downto 0); Product: out bit_vector (6 downto 0); Done: out bit); end component; constant N: integer := 11; type arr is array(1 to N) of bit_vector(3 downto 0); constant Mcandarr: arr := ("0111", "1101", "0101", "1101", "0111", "1000", "0111", "1000", "0000", "1111", "1011"); constant Mplierarr: arr := ("0101", "0101", "1101", "1101", "0111", "0111", "1000", "1000", "1101", "1111", "0000"); signal CLK, St, Done: bit; signal Mplier, Mcand: bit_vector(3 downto 0); signal Product: bit_vector(6 downto 0); begin CLK <= not CLK after 10 ns; process begin for i in 1 to N loop Mcand <= Mcandarr(i); Mplier <= Mplierarr(i); St <= '1'; wait until rising_edge(CLK); St <= '0'; wait until falling_edge(Done); end loop; end process; mult1: mult2c port map(Clk, St, Mplier, Mcand, Product, Done); end test1; DSD,USIT,GGSIPU

  28. Parallel Divider for Positive Binary Numbers DSD,USIT,GGSIPU

  29. DSD,USIT,GGSIPU

  30. Figure 4-19 Block Diagram for Parallel Binary Divider DSD,USIT,GGSIPU

  31. Figure 4-20 State Diagram for Divider Control Circuit DSD,USIT,GGSIPU

  32. DSD,USIT,GGSIPU

  33. Control Signals for Signed Divider LdU Load upper half of dividend from bus LdL Load lower half of dividend from bus Lds Load sign of dividend into sign flip-flop S Sign of dividend Cm1 Complement dividend register (2's complement) Ldd Load divisor from bus Su Enable adder output onto bus (Ena) and load upper half of dividend from bus Cm2Enable complementer (Cm2 equals the complement of the sign bit of the divisor, so that a positive divisor is complemented and a negative divisor is not) Sh Shift the dividend register left one place and increment the counter C Carry output from adder (If C = 1, the divisor can be subtracted from the upper dividend.) St Start V Overflow Qneg Quotient will be negative (Qneg = 1 when sign of dividend and divisor are different) DSD,USIT,GGSIPU

  34. Figure 4-21 Block Diagram for Signed Divider DSD,USIT,GGSIPU

  35. Figure 4-22 State Graph for Signed Divider Control Network DSD,USIT,GGSIPU

  36. Figure 4-23(a) VHDL Model of 32-bit Signed Divider library BITLIB; use BITLIB.bit_pack.all; entity sdiv is port(Clk,St: in bit; Dbus: in bit_vector(15 downto 0); Quotient: out bit_vector(15 downto 0); V, Rdy: out bit); end sdiv; architecture Signdiv of Sdiv is constant zero_vector: bit_vector(31 downto 0):=(others=>'0'); signal State: integer range 0 to 6; signal Count : integer range 0 to 15; signal Sign,C,NC: bit; signal Divisor,Sum,Compout: bit_vector(15 downto 0); signal Dividend: bit_vector(31 downto 0); alias Q: bit_vector(15 downto 0) is Dividend(15 downto 0); alias Acc: bit_vector(15 downto 0) is Dividend(31 downto 16); begin -- concurrent statements compout <= divisor when divisor(15) = '1' -- 1's complementer else not divisor; Addvec(Acc,compout,not divisor(15),Sum,C,16); -- 16-bit adder Quotient <= Q; Rdy <= '1' when State=0 else '0'; DSD,USIT,GGSIPU

  37. Figure 4-23(b) VHDL Model of 32-bit Signed Divider process begin wait until Clk = '1'; -- wait for rising edge of clock case State is when 0=> if St = '1' then Acc <= Dbus; -- load upper dividend Sign <= Dbus(15); State <= 1; V <= '0'; Count <= 0; -- initialize overflow// initialize counter end if; when 1=> Q <= Dbus; State <= 2; -- load lower dividend when 2=> Divisor <= Dbus; if Sign ='1'then -- two's complement Dividend if necessary addvec(not Dividend,zero_vector,'1',Dividend,NC,32); end if; State <= 3; when 3=> Dividend <= Dividend(30 downto 0) & '0'; -- left shift Count <= Count+1; State <= 4; when 4 => if C ='1' then -- C v <= '1'; State <= 0; else -- C' Dividend <= Dividend(30 downto 0) & '0'; -- left shift Count <= Count+1; State <= 5; end if; DSD,USIT,GGSIPU

  38. Figure 4-23(c) VHDL Model of 32-bit Signed Divider when 5 => if C = '1' then -- C ACC <= Sum; -- subtract Q(0)<= '1'; else Dividend <= Dividend(30 downto 0) & '0'; -- left shift if Count = 15 then -- KC' count<= 0; State <= 6; else Count <= Count+1; end if; end if; when 6=> if C = '1' then -- C Acc <= Sum; -- subtract Q(0) <= '1'; else if (Sign xor Divisor(15))='1' then -- C'Qneg addvec(not Dividend,zero_vector,'1',Dividend,NC,32); end if; -- 2's complement Dividend state <= 0; end if; end case; end process; end signdiv; DSD,USIT,GGSIPU

More Related