Implement 16 bit division circuit using data flow architecture
Implement 16 bit division circuit using data flow architecture
entity Division8bit is
Port (
dividend : in STD_LOGIC_VECTOR(7 downto 0);
divisor : in STD_LOGIC_VECTOR(7 downto 0);
quotient : out STD_LOGIC_VECTOR(7 downto 0);
remainder : out STD_LOGIC_VECTOR(7 downto 0)
);
end Division8bit;
-- Assign outputs
quotient <= temp_quotient;
remainder <= temp_remainder;
end process;
end Behavioral;
begin
-- Stimulus process
stimulus_process: process
begin
-- Test Case 1: 24 / 6 = 4 remainder 0
dividend <= "00011000"; -- 24
divisor <= "00000110"; -- 6
wait for 20 ns;
-- Stop simulation
wait;
end process;
end behavior;
Explanation
library IEEE; → Includes the IEEE standard library, which provides logic types.
use IEEE.STD_LOGIC_1164.ALL; → Enables standard logic (std_logic_vector)
operations.
use IEEE.STD_LOGIC_ARITH.ALL; → Enables arithmetic functions for logic vectors.
use IEEE.STD_LOGIC_UNSIGNED.ALL; → Allows treating std_logic_vector as
unsigned numbers.
entity Division8bit is → Defines the hardware module for division.
dividend (8-bit input) → The number to be divided.
divisor (8-bit input) → The number by which we divide.
quotient (8-bit output) → The result of dividend ÷ divisor.
remainder (8-bit output) → The remainder of the division.
architecture Behavioral of Division8bit is → Describes how the division
works.
process(dividend, divisor) → Runs whenever dividend or divisor changes.
temp_dividend → Stores the current value of the dividend.
temp_divisor → Stores the current value of the divisor.
temp_quotient → Stores the computed quotient (initialized to 00000000).
temp_remainder → Stores the computed remainder.
Copies dividend and divisor into temporary variables.
temp_remainder is initialized to 0.
If divisor = 0, division is not allowed (undefined behavior).
Instead of crashing:
o The quotient is set to 0.
o The remainder is set to the dividend.
This is an iterative division using subtraction and bit shifts, similar to long division.
🔄 How it works?
2. If remainder ≥ divisor:
o Subtract divisor from remainder.
o Append '1' to quotient.