VHDL Quick Reference
VHDL Quick Reference
vhd
1 / 2
-------------------------------------------------------------------------------- Title
: VHDL Quick Reference
-------------------------------------------------------------------------------- File
: Quick_Reference.vhd
-- Author
: DOUZE Yann <[email protected]>
-- Company
: Polytech'Paris UPMC
-- Last update: 2006/09/5
-- Platform
:
-------------------------------------------------------------------------------- Description: Modles de syntaxe VHDL
----------------------------------------------------------------------------------------------------------------------------------------------Exemple typique de VHDL RTL (compteur paramtrable)
----------------------------------------------------------------library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-- use WORK.mypackage.ALL; -- si vous utilisez votre propre package
entity COUNTER is
generic(Counter_Width : positive := 8);
port( CLK
: in std_logic;
RST
: in std_logic; -- reset asynchrone
EN
: in std_logic; -- ENable
UP
: in std_logic; -- 1= counting up, 0 = down
Q
: out std_logic_vector(Counter_Width-1 downto 0)
);
end COUNTER;
architecture RTL of COUNTER is
signal iCount : unsigned(Q'range);
begin
Q <= std_logic_vector(iCount);
process(CLK,RST)
begin
if (RST='1') then
iCount <= (others => '0');
elsif rising_edge(CLK) then
if EN='1' then
if UP='1' then
iCount <= iCount + 1;
else
iCount <= iCount - 1;
end if;
end if;
end if;
end process;
end RTL;
----------------------------------------------------------------Exemple typique de Test Bench
----------------------------------------------------------------LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
USE STD.textio.all;
USE IEEE.std_logic_textio.all;
ENTITY Counter_tb IS
END Counter_tb;
ARCHITECTURE bench OF Counter_tb IS
constant Width : positive := 8;
March 02, 2009
Crimson Editor
Quick_Reference.vhd
2 / 2
Crimson Editor