Division Discussion D11.3. Division 1101 10000111 1010 1101 00111 0000 01111 1101 00101 0000 0101 13 135 13 05 10.

Slides:



Advertisements
Similar presentations
Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
Advertisements

Arbitrary Waveform Discussion 5.5 Example 34.
Arithmetic Logic Unit (ALU)
Edge-Triggered D Flip-Flops Discussion D4.2 Example 26.
7-Segment Display: Spartan-3 board
Shifters Discussion D7.1 Example Bit Shifter.
Divider Discussion D7.3 Example 20.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Adder Discussion D6.2 Example 17. s i = c i ^ (a i ^ b i ) c i+1 = a i * b i + c i * (a i ^ b i ) Full Adder (Appendix I)
Top-level VHDL Designs
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
RS-232 Port Discussion D7.1. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
Single-Cycle Instructions VHDL Tutorial R. E. Haskell and D. M. Hanna T5: VHDL ROM.
Digilent Spartan 3 Board Lecture L2.2
1 Comparators Discussion D A 1-Bit Comparator The variable Gout is 1 if x > y or if x = y and Gin = 1. The variable Eout is 1 if x = y and Gin =
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Finite State Machines Discussion D7.1 Mealy and Moore Machines.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
7-Segment Display DIO1 Board. Digilab2 – DIO1 Boards Four 7-segment displays A0A1A2A3.
Introduction to VHDL Multiplexers. Introduction to VHDL VHDL is an acronym for VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.
Lecture L6.2 VHDL Multiply Operator (*)
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
Division Lecture L6.3. Division
4-to-1 Multiplexer: case Statement Discussion D2.3 Example 6.
Finite State Machines Mano and Kime Sections 4-4, 4-5, 4-8.
FPGAs and VHDL Lecture L13.1 Sections 13.1 – 13.3.
Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise “010”true if b < a.
Finite State Machines Discussion D8.1 Example 36.
7-Segment Displays Digilent Spartan 3 Board Discussion DS-4.2.
Introduction to VHDL Multiplexers Discussion D1.1.
Multiplication and Division Lab 9. Multiplication 13 x = 8Fh 1101 x
Binary-to-BCD Converter
7-Segment Displays VHDL Tutorial R. E. Haskell and D. M. Hanna T4: Xilinx LogiBLOX.
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Sequential Multiplication Lecture L6.4. Multiplication 13 x = 8Fh 1101 x
Arithmetic Logic Unit (ALU) Discussion D4.6. ALU N = negative flag (N=1 if y(n)=0 Z = zero flag (Z = 1 if Y = 0) V = overflow flag C = carry flag.
Binary-to-BCD Converter
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
1 Comparators: Procedures Discussion D9.2 Example 22.
PS/2 Mouse/Keyboard Port Discussion D7.2. PS/2 Port.
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
ENG2410 Digital Design LAB #8 LAB #8 Data Path Design.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
4-to-1 Multiplexer: Module Instantiation Discussion D2.2 Example 5.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
INF H131 Clock and Reset Unit (CRU) module library ieee; use ieee.std_logic_1164.all; entity cru is port ( arst : in std_logic; -- Asynch. reset.
Prime Numbers Lecture L6.1 Sieve of Eratosthenes.
Multiplier: Functions Discussion D7.2 Example 19.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Combinational logic circuit
Lecture L5.1 Mealy and Moore Machines
Comparators Discussion DS-3.1.
Combinational Circuits Using VHDL
Mano and Kime Sections 7-6 – 7-8
A Data Stack CoreGen Discussion 12.1.
Binary-to-BCD Converter
A Greatest Common Divisor (GCD) Processor
Fibonacci Sequence Lecture L4.1 Lab 3.
Multiplication Discussion 11.1.
Fast, Asynchronous SRAM
RS-232 Port Discussion D12.1.
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
Digital Logic with VHDL
Presentation transcript:

Division Discussion D11.3

Division

Division 8-bit/4-bit = 4: _ numer[8:0] denom[3:0] If denom < numer[7:4] then overflow (quotient won’t fit in 4 bits) Let T = numer[8:4] N = numer[3:0] N2 = denom[3:0]

Division 8-bit/4-bit = 4: shl TN N2 for I in 0 to 3 loop shl T & N; if T[4:0] >= N2 then T := T - (0 & N2); N(0) := ‘1’; end if; end loop;

Division 8-bit/4-bit = 4: sll TN N sub1sll sll sub1sll rem quot

-- Title: Division: 8/4 = 4:4 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity div is port ( numer: in STD_LOGIC_VECTOR (7 downto 0); denom: in STD_LOGIC_VECTOR (3 downto 0); quot: out STD_LOGIC_VECTOR (3 downto 0); remain: out STD_LOGIC_VECTOR (3 downto 0) ); end div; div.vhd Combinational divide

architecture div_arch of div is begin div1: process(numer, denom) variable T, N2: STD_LOGIC_VECTOR (4 downto 0); variable N: STD_LOGIC_VECTOR (3 downto 0); TN N2 begin T := '0' & numer(7 downto 4); N := numer(3 downto 0); N2 := '0' & denom; div.vhd (cont.)

for I in 0 to 3 loop T := T(3 downto 0) & N(3); N := N(2 downto 0) & '0'; if T >= N2 then T := T - N2; N(0) := '1'; end if; end loop; quot <= N; remain <= T(3 downto 0); end process div1; end div_arch; shl TN N2 div.vhd (cont.)

div synthesized circuit numer(2:0) denom(3:0) remain(3:0) quot(3:0) numer(7:3)

Top-level Design

-- Title: DIV Test library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.std_logic_unsigned.all; entity DIVtest is port( mclk : in STD_LOGIC; SW : in STD_LOGIC_VECTOR(7 downto 0); BTN : in STD_LOGIC_VECTOR(3 downto 0); LD : out STD_LOGIC_VECTOR(7 downto 0); AtoG : out STD_LOGIC_VECTOR(6 downto 0); AN : out STD_LOGIC_VECTOR(3 downto 0) ); end DIVtest; DIVtest.vhd

architecture DIVtest_arch of DIVtest is signal r, p: std_logic_vector(15 downto 0); signal clr, clk, cclk: std_logic; signal clkdiv: std_logic_vector(23 downto 0); signal denom: std_logic_vector(3 downto 0); constant bus_width: positive := 4; begin clr <= BTN(3); -- Divide the master clock (50Mhz) process (mclk) begin if mclk = '1' and mclk'Event then clkdiv <= clkdiv + 1; end if; end process; cclk <= clkdiv(17); Hz

p(15 downto 8) <= " "; denom <= '0' & BTN(2 downto 0); U1: divg generic map(width => bus_width) port map (numer => SW, denom => denom, quot => p(3 downto 0), remain =>p(7 downto 4)); U3: x7segb port map (x => p, cclk => cclk, clr => clr, AtoG => AtoG, AN => AN); LD <= SW; end DIVtest_arch;

x7segb AtoG(6:0) AN(3:0) x(15:0)

-- Title: Division: 2*width/width = width:width library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity divg is generic(width:positive); port ( numer: in STD_LOGIC_VECTOR (width+width-1 downto 0); denom: in STD_LOGIC_VECTOR (width-1 downto 0); quot: out STD_LOGIC_VECTOR (width-1 downto 0); remain: out STD_LOGIC_VECTOR (width-1 downto 0) ); end divg; divg.vhd

architecture divg_arch of divg is begin div1: process(numer, denom) variable T, N2: STD_LOGIC_VECTOR (width downto 0); variable N: STD_LOGIC_VECTOR (width-1 downto 0); begin T := '0' & numer(width+width-1 downto width); N2 := '0' & denom; N := numer(width-1 downto 0); divg.vhd (cont.)

begin T := '0' & numer(width+width-1 downto width); N2 := '0' & denom; N := numer(width-1 downto 0); for j in 0 to width-1 loop T := T(width-1 downto 0) & N(width-1); N := N(width-2 downto 0) & '0'; if T >= N2 then T := T - N2; N(0) := '1'; end if; end loop; quot <= N; remain <= T(width-1 downto 0); end process div1; end divg_arch;

width = 8