Professional Documents
Culture Documents
Library Ieee Use Ieee - STD - Logic - 1164.all Use Ieee - STD - Logic - Unsigned - All Use
Library Ieee Use Ieee - STD - Logic - 1164.all Use Ieee - STD - Logic - Unsigned - All Use
Library Ieee Use Ieee - STD - Logic - 1164.all Use Ieee - STD - Logic - Unsigned - All Use
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
use IEEE.STD_LOGIC_ARITH.all;
entity division is
generic(SIZE: INTEGER := ;
port(reset: in STD_LOGIC;
en: in STD_LOGIC;
clk: in STD_LOGIC;
2. library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity div_binary is
Port (
end div_binary;
a <= CONV_INTEGER(ina);
b <= CONV_INTEGER(inb);
process (a,b)
end Behavioral;
3. library ieee;
use ieee.std_logic_1164.all;
USE ieee.std_logic_signed.ALL;
entity nosrt is
port (in1, in2 : in std_logic_vector(3 downto 0);
clk : in std_logic ;
remainder : out std_logic_vector( 4 downto 0);
qotient : out std_logic_vector ( 3 downto 0));
end nosrt;
architecture div of nosrt is
begin
process(clk)
4.
signal dividend, divisor, quotient, remainder:
> > > * * * * * * * * * * * * * * * * * *unsigned(3 downto 0);
> > > * .....
> > > * process (dividend, divisor)
> > > * * variable v: unsigned(3 downto 0);
> > > * * variable done: boolean;
> > > * begin
> > > * * v := dividend;
> > > * * done := false;
> > > * * for i in 0 to 15 loop
> > > * * * if not done then
> > > * * * * if v < divisor then
> > > * * * * * quotient <= to_unsigned(i, 4);
> > > * * * * * remainder <= v;
> > > * * * * * done := true;
> > > * * * * else
> > > * * * * * v := v - divisor;
> > > * * * * end if;
> > > * * * end if;
> > > * * end loop;
> > > * end process;
http://www.scribd.com/doc/260030/DSD-Lab-Programs-Using-VHDL-Adders-
Subtractors-Comparator-Decoder-Parity-Multiplexer-FlipFlops-Counters
5. library ieee;
use ieee.std_logic_1164.all;
entity comparator is
port (
A : in std_logic_vector(1 downto 0);
B : in std_logic_vector(1 downto 0);
L_in : in std_logic;
G_in : in std_logic;
E_in : in std_logic;
L : out std_logic;
G : out std_logic;
E : out std_logic);
end comparator;
begin -- behav
process (A, B, L_in, G_in, E_in)
begin -- process
if ( (A = B) and E_in = '1') then
E <= '1';
else
E <= '0';
end if;
if (A(1)= '1' and B(1) = '0')
or ( (A(1) = B(1)) and (A(0)='1' and B(0)= '0'))
or ((A = B) and G_in = '1') then
G <= '1';
else
G <= '0';
end if;
if (A(1)='0' and B(1) ='1')
or ((A(1) = B(1)) and A(0)='0' and B(0)= '1')
or ((A = B) and L_in = '1') then
L <= '1';
else
L <= '0';
end if;
end process;
end behav;
library ieee;
use ieee.std_logic_1164.all;
entity comp_8bit is
port (
A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
L : out std_logic;
G : out std_logic;
E : out std_logic);
end comp_8bit;
end struct;