Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design of Networks for Arithmetic Operation

Similar presentations


Presentation on theme: "Design of Networks for Arithmetic Operation"— Presentation transcript:

1 Design of Networks for Arithmetic Operation
31/05/2019 DSD,USIT,GGSIPU

2 Table 4-1 Operation of Serial Adder
31/05/2019 DSD,USIT,GGSIPU

3 Fig. 4-2 Control State Graph and Table for Serial Adder
31/05/2019 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 + I In = 1. 31/05/2019 DSD,USIT,GGSIPU

5 Example 1 31/05/2019 DSD,USIT,GGSIPU

6 Example - 2 31/05/2019 DSD,USIT,GGSIPU

7 Design of a Binary Mulitplier
31/05/2019 DSD,USIT,GGSIPU

8 31/05/2019 DSD,USIT,GGSIPU

9 31/05/2019 DSD,USIT,GGSIPU

10 31/05/2019 DSD,USIT,GGSIPU

11 31/05/2019 DSD,USIT,GGSIPU

12 31/05/2019 DSD,USIT,GGSIPU

13 31/05/2019 DSD,USIT,GGSIPU

14 31/05/2019 DSD,USIT,GGSIPU

15 31/05/2019 DSD,USIT,GGSIPU

16 31/05/2019 DSD,USIT,GGSIPU

17 Multiplication of Signed Binary Numbers
31/05/2019 DSD,USIT,GGSIPU

18 31/05/2019 DSD,USIT,GGSIPU

19 31/05/2019 DSD,USIT,GGSIPU

20 31/05/2019 DSD,USIT,GGSIPU

21 31/05/2019 DSD,USIT,GGSIPU

22 31/05/2019 DSD,USIT,GGSIPU

23 31/05/2019 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); 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; 31/05/2019 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); 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; 31/05/2019 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, repeat 20 -- (5/8 * -3/8) force Mcand 0101 force Mplier 1101 run 120 ns delta CLK St State A B Done Product 31/05/2019 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 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; 31/05/2019 DSD,USIT,GGSIPU

28 Parallel Divider for Positive Binary Numbers
31/05/2019 DSD,USIT,GGSIPU

29 31/05/2019 DSD,USIT,GGSIPU

30 Figure 4-19 Block Diagram for Parallel Binary Divider
31/05/2019 DSD,USIT,GGSIPU

31 Figure 4-20 State Diagram for Divider Control Circuit
31/05/2019 DSD,USIT,GGSIPU

32 31/05/2019 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 Cm2 Enable 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) 31/05/2019 DSD,USIT,GGSIPU

34 Figure 4-21 Block Diagram for Signed Divider
31/05/2019 DSD,USIT,GGSIPU

35 Figure 4-22 State Graph for Signed Divider Control Network
31/05/2019 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); bit adder Quotient <= Q; Rdy <= '1' when State=0 else '0'; 31/05/2019 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' Count <= Count+1; State <= 5; 31/05/2019 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; when 6=> 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 case; end process; end signdiv; 31/05/2019 DSD,USIT,GGSIPU


Download ppt "Design of Networks for Arithmetic Operation"

Similar presentations


Ads by Google