زبان توصیف سختافزار From Wikipedia, the free encyclopedia
ویاچدیال (به انگلیسی VHDL) یک زبان توصیف سختافزار برای بیان مشخصات سختافزار است. زبان VHDL نخستین بار توسط وزارت دفاع آمریکا به منظور طراحی و توصیف مدارهای مجتمع سرعت بالا طراحی شد و مورد استفاده قرار گرفت. سپس در سال ۱۹۸۷ توسط انجمن IEEE (انجمن مهندسان برق و الکترونیک) در قالب استاندارد IEEE 1076-1987 ارائه گردید. پس از گذشت چند سال و انجام پارهای از تصحیحات، استاندارد دوم این زبان تحت عنوان IEEE 1076-1993 در اختیار عموم قرار گرفت. بهطور کلی میتوان مزایای زیر را در استفاده از زبان VHDL عنوان نمود:
پارادایم برنامهنویسی | concurrent, reactive |
---|---|
ظهوریافته در | 1980s |
وابستگی زیاد و کم به نوع | |
وبگاه | |
متأثر از | |
ایدا (زبان برنامهنویسی)، پاسکال (زبان برنامهنویسی) |
-- (this is a VHDL comment)
-- import std_logic from the IEEE library
library IEEE;
use IEEE.std_logic_1164.all;
-- this is the entity
entity ANDGATE is
port (
IN1 : in std_logic;
IN2 : in std_logic;
OUT1: out std_logic);
end ANDGATE;
architecture RTL of ANDGATE is
begin
OUT1 <= IN1 and IN2;
end RTL;
-- template 1:
X <= A when S = '1' else B;
-- template 2:
with S select
X <= A when '1',
B when others;
-- template 3:
process(A,B,S)
begin
case S is
when '1' => X <= A;
when others => X <= B;
end case;
end process;
-- template 4:
process(A,B,S)
begin
if S = '1' then
X <= A;
else
X <= B;
end if;
end process;
-- template 5 - 4:1 MUX, where S is a 2-bit std_logic_vector :
process(A,B,C,D,S)
begin
case S is
when "00" => X <= A;
when "01" => X <= B;
when "10" => X <= C;
when others => X <= D;
end case;
end process;
-- simplest DFF template (not recommended)
Q <= D when rising_edge(CLK);
-- recommended DFF template:
process(CLK)
begin
-- use falling_edge(CLK) to sample at the falling edge instead
if rising_edge(CLK) then
Q <= D;
end if;
end process;
-- alternative DFF template:
process
begin
wait until CLK='1';
Q <= D;
end process;
-- alternative template expands the ''rising_edge'' function above:
process(CLK)
begin
if CLK = '1' and CLK'event then--use rising edge, use "if CLK = '0' and CLK'event" instead for falling edge
Q <= D;
end if;
end process;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all; -- for the unsigned type
entity counter_example is
generic ( WIDTH : integer := 32);
port (
CLK, RESET, LOAD : in std_logic;
DATA : in unsigned(WIDTH-1 downto 0);
Q : out unsigned(WIDTH-1 downto 0));
end entity counter_example;
architecture counter_example_a of counter_example is
signal cnt : unsigned(WIDTH-1 downto 0);
begin
process(RESET, CLK) is
begin
if RESET = '1' then
cnt <= (others => '0');
elsif rising_edge(CLK) then
if LOAD = '1' then
cnt <= DATA;
else
cnt <= cnt + 1;
end if;
end if;
end process;
Q <= cnt;
end architecture counter_example_a;
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.