VHDL

VHDL

infobox programming language
name = VHDL

paradigm = behavioural
year = 1980s
designer =
developer =
latest_release_version =
latest_release_date =
latest_test_version =
latest_test_date =
typing = strong
implementations =
dialects =
influenced_by =
influenced =
operating_system =
license =
website = [http://www.eda.org/vasg/ IEEE VASG]

VHDL (VHSIC hardware description language) is commonly used as a design-entry language for field-programmable gate arrays and application-specific integrated circuits in electronic design automation of digital circuits.

History

VHDL was originally developed at the behest of the US Department of Defense in order to document the behavior of the ASICs that supplier companies were including in equipment. That is to say, VHDL was developed as an alternative to huge, complex manuals which were subject to implementation-specific details.

The idea of being able to simulate this documentation was so obviously attractive that logic simulators were developed that could read the VHDL files. The next step was the development of logic synthesis tools that read the VHDL, and output a definition of the physical implementation of the circuit. Modern synthesis tools can extract RAM, counter, and arithmetic blocks out of the code, and implement them according to what the user specifies. Thus, the same VHDL code could be synthesized differently for lowest area, lowest power consumption, highest clock speed, or other requirements.

VHDL borrows heavily from the Ada programming language in both concepts (for example, the slice notation for indexing part of a one-dimensional array) and syntax. VHDL has constructs to handle the parallelism inherent in hardware designs, but these constructs (processes) differ in syntax from the parallel constructs in Ada (tasks). Like Ada, VHDL is strongly-typed and is case insensitive. There are many features of VHDL which are not found in Ada, such as an extended set of Boolean operators including nand and nor, in order to represent directly operations which are common in hardware. VHDL also allowsarrays to be indexed in either direction (ascending or descending) because both conventions are used in hardware, whereas Ada (like most programming languages) provides ascending indexing only. The reason for the similarity between the two languages is that the Department of Defense required as much of the syntax as possible to be based on Ada, in order to avoid re-inventing concepts that had already been thoroughly tested in the development of Ada.

The initial version of VHDL, designed to IEEE standard 1076-1987, included a wide range of data types, including numerical (integer and real), logical (bit and boolean), character and time, plus arrays of bit called bit_vector and of character called string.

A problem not solved by this edition, however, was "multi-valued logic", where a signal's drive strength (none, weak or strong) and unknown values are also considered. This required IEEE standard 1164, which defined the 9-value logic types: scalar std_ulogic and its vector version std_ulogic_vector.

The second issue of IEEE 1076, in 1993, made the syntax more consistent, allowed more flexibility in naming, extended the character type to allow ISO-8859-1 printable characters, added the xnor operator, etc.

Minor changes in the standard (2000 and 2002) added the idea of protected types (similar to the concept of class in C++) and removed some restrictions from port mapping rules.

In addition to IEEE standard 1164, several child standards were introduced to extend functionality of the language. IEEE standard 1076.2 added better handling of real and complex data types. IEEE standard 1076.3 introduced signed and unsigned types to facilitate arithmetical operations on vectors. IEEE standard 1076.1 (known as VHDL-AMS) provided analog and mixed-signal circuit design extensions.

Some other standards support wider use of VHDL, notably VITAL (VHDL Initiative Towards ASIC Libraries) and microwave circuit design extensions.

In June 2006, VHDL Technical Committee of Accellera (delegated by IEEE to work on next update of the standard) approved so called Draft 3.0 of VHDL-2006. While maintaining full compatibility with older versions, this proposed standard provides numerous extensions that make writing and managing VHDL code easier. Key changes include incorporation of child standards (1164, 1076.2, 1076.3) into the main 1076 standard, an extended set of operators, more flexible syntax of 'case' and 'generate' statements, incorporation of VHPI (interface to C/C++ languages) and a subset of PSL (Property Specification Language). These changes should improve quality of synthesizable VHDL code, make testbenches more flexible, and allow wider use of VHDL for system-level descriptions.

In February 2008, Accellera approved VHDL 4.0 also informally known as VHDL 2008, which addressed more than 90 issues discovered during the trial period for version 3.0 and includes enhanced generic types. In 2008, Accellera plans to release VHDL 4.0 to the IEEE for balloting for inclusion in IEEE 1076-2008.

Discussion

Getting started

Although background in a computer programming language (such as C) is helpful, it is not essential. Free VHDL simulators are readily available, and although these are limited in functionality compared to commercial VHDL simulators, they are more than sufficient for independent study. If the user's goal is to learn RTL coding, (that is, design hardware circuits in VHDL, as opposed to simply document or simulate circuit behavior), then a synthesis/design package is also needed.

As with VHDL simulators, free FPGA synthesis tools are readily available, and are more than adequate for independent study. Feedback from the synthesis tool gives the user a feel for the relative efficiencies of different coding styles. A schematic/gate viewer shows the user the synthesized design as a navigable netlist diagram. Many FPGA design packages offer alternative design input methods, such as block-diagram (schematic) and state-diagram capture. These provide a useful starting template for coding certain types of repetitive structures, or complex state-transition diagrams. Finally, the included tutorials and examples are valuable aids.

Nearly all FPGA design and simulation flows support both Verilog and VHDL, allowing the user to learn either or both languages.

Free design & simulation packages for VHDL/Verilog:* If Modelsim is installed on the computer, the ISE software can call ModelSim's features if desired.(ISE 9.2i comes with an integrated simulator)
** Limited to vendor's device-database

Code examples

In VHDL, a design consists at a minimum of an "entity" which describes the interface and an "architecture" which contains the actual implementation. In addition, most designs import library modules. Some designs also contain multiple architectures and "configurations".

A simple AND gate in VHDL would look something like this:

-- (this is a VHDL comment)

-- import std_logic from the IEEE librarylibrary IEEE;use IEEE.std_logic_1164.all;

-- this is the entityentity ANDGATE is port ( IN1 : in std_logic; IN2 : in std_logic; OUT1: out std_logic);end ANDGATE;

architecture RTL of ANDGATE isbegin

OUT1 <= IN1 and IN2;

end RTL;

While the example above may seem very verbose to HDL beginners, one should keep in mind that many parts are either optional or need to be written only once. And generally simple functions like this are part of a larger behavioral module, instead of having a separate module for something so simple. In addition, use of elements such as the std_logic type might at first seem an overkill. One could easily use the built-in bit type and avoid the library import in the beginning. However, using this 9-valued logic (U,X,0,1,Z,W,H,L,-) instead of simple bits (0,1) offers a very powerful simulation and debugging tool to the designer which currently does not exist in any other HDL.

In the examples that follow, you will see that VHDL code can be written in a very compact form. However, the experienced designers usually avoid these compact forms and use a more verbose coding style for the sake of readability and maintainability. Another advantage to the verbose coding style is the smaller amount of resources used when programming to a Programmable Logic Device such as a CPLD.

Synthesizeable constructs and VHDL templates

Originally synthesizers, which would correspond to compilers in the HDL world, used a set of templates to identify the common hardware constructs in the HDL code (recall that VHDL is a hardware 'description' language, not a programming language). These templates can still be used today, although the HDL tools are far more sophisticated these days. Due to their usually one-to-one mapping to well known digital circuits, the templates are usually what an otherwise experienced hardware designer would use when entering the HDL world. But they are also useful for those who are completely new to digital design.

Some digital components have multiple templates, consider for instance the multiplexer example that follows:

MUX templates

The multiplexer, or 'MUX' as it is usually called, is a simple construct very common in hardware design. The example below demonstrates a simple two to one MUX, with inputs A and B, selector S and output X:

-- template 1:X <= A when S = '1' else B;

-- template 2:with S select X <= A when '1' else B;

-- 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; -- or when "11" end case;end process;

The three last templates make use of what VHDL calls 'sequential' code. The sequential sections are always placed inside a "process" and have a slightly different syntax which may resemble more traditional programming languages.

Latch templates

A transparent latch is basically one bit of memory which is updated when an enable signal is raised:

-- latch template 1:Q <= D when Enable = '1' else Q;

-- latch template 2:process(D,Enable)begin if Enable = '1' then Q <= D; end if;end process;

A SR-latch uses a set and reset signal instead:

-- SR-latch template 1:Q <= '1' when S = '1' else '0' when R = '1' else Q;

-- SR-latch template 2:process(S,R)begin if S = '1' then Q <= '1'; elsif R = '1' then Q <= '0'; end if;end process;Template 2 has an implicit "else Q <= Q;" which may be explicitly added if desired.-- This one is a RS-latch (i.e. reset dominates)process(S,R)begin if R = '1' then Q <= '0'; elsif S = '1' then Q <= '1'; end if;end process;

D-type flip-flops

The D-type flip-flop samples an incoming signal at the rising or falling edge of a clock. The DFF is the basis for all synchronous logic.

-- 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:processbegin wait until rising_edge(CLK); Q <= D; end process;

Some flip-flops also have Enable signals and asynchronous or synchronous Set and Reset signals:

-- template for asynchronous reset with clock enable:process(CLK, RESET)begin if RESET = '1' then -- or '0' if RESET is active low... Q <= '0'; elsif rising_edge(CLK) then if Enable = '1' then -- or '0' if Enable is active low... Q <= D; end if; end if;end process;

-- template for synchronous reset with clock enable:process(CLK)begin if rising_edge(CLK) then if RESET = '1' then Q <= '0'; elsif Enable = '1' then -- or '0' if Enable is active low... Q <= D; end if; end if;end process;

A common beginner mistake is to have a set or reset input but not use it. For example, the following two snippets are not equal, the first one is a simple D-type flip-flop, while the second one is a DFF with a feedback MUX.

-- simple D-type flip-flop process(CLK)begin if rising_edge(CLK) then Q <= D; end if;end process;

-- BAD VHDL: this does NOT make the flip-flop a DFF without a reset!!process(CLK, RESET)begin if RESET = '1' then -- do nothing. Q is not set here... elsif rising_edge(CLK) then Q <= D; end if;end process;

This is very similar to the 'transparent latch' mistake mentioned earlier.

The counter example

The following example is an up-counter with asynchronous reset, parallel load and configurable width. It demonstrates the use of the 'unsigned' type and VHDL "generics". The generic are very close to arguments or templates in other traditional programming languages like C or C++.

library IEEE;use IEEE.std_logic_1164.all;use IEEE.numeric_std.all; -- for the unsigned type

entity counter_example isgeneric ( 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 issignal cnt : unsigned(WIDTH-1 downto 0);begin process(RESET, CLK) 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;

While not recommended for new designs, the std_logic_vector type can be used instead of the unsigned type.

More complex counters may add if/then/else statements within the rising_edge(CLK) elsif to add other functions, such as count enables, stopping or rolling over at some count value, generating output signals like terminal count signals, etc. Care must be taken with the ordering and nesting of such controls if used together, in order to produce the desired priorities and minimize the number of logic levels needed.

Simulation-only constructs

A large subset of VHDL cannot be translated into hardware. This subset is known as the non-synthesizable or the simulation-only subset of VHDL and can only be used for prototyping, simulation and debugging. For example, the following code will generate a clock with the frequency of 50 MHz. It can, for example, be used to drive a clock input in a design during simulation. It is however a simulation-only construct and cannot be implemented in hardware!

processbegin CLK <= '1'; wait for 10 ns; CLK <= '0'; wait for 10 ns;end process;

The simulation-only constructs can be used to build complex waveforms in very short time. Such waveform can be used, for example, as test vectors for a complex design or as a prototype of some synthesizable logic that will be implemented in future.

processbegin wait until START = '1'; -- wait until START is high for i in 1 to 10 loop -- then wait for a few clock periods... wait until rising_edge(CLK); end loop;

for i in 1 to 10 loop -- write numbers 1 to 10 to DATA, 1 every cycle DATA <= to_unsigned(i, 8); wait until rising_edge(CLK); end loop;

-- wait until the output changes wait on RESULT; -- now raise ACK for clock period ACK <= '1'; wait until rising_edge(CLK); ACK <= '0';

-- and so on...end process;

References

See also

* Verilog
* SystemC
* Register transfer level
* Electronic design automation
* Complex programmable logic device (CPLD)
* Field Programmable Gate Array (FPGA)
* Application Specific Integrated Circuit (ASIC)
* Free VHDL Simulator from Xilinx [http://www.xilinx.com/ise/logic_design_prod/webpack.htm]

External links

* [http://www.vhdl.org/comp.lang.vhdl/ The FAQ of news://comp.lang.vhdl]
* [http://groups.google.com/group/comp.lang.vhdl/topics comp.lang.vhdl Newsgroup]
* [http://www.eda.org/vhdl-200x/ IEEE VASG (VHDL Analysis and Standardization Group)] - Official VHDL Working Group
* [http://ghdl.free.fr/ GHDL] , a complete Free Software VHDL compiler/simulator, built on top of GCC.
* [http://members.optushome.com.au/jekent/FPGA.htm John's FPGA Page] - List of VHDL and FPGA resources, including VHDL tutorials.
* [http://www.opencores.org/ www.opencores.org] - home of many open source VHDL and Verilog projects

Further reading

* &mdash; Sandstrom presents a table relating VHDL constructs to Verilog constructs.
*
*
*
*
* Janick Bergerdon, "Writing Testbenches: Functional Verification of HDL Models", 2000, ISBN 0-7923-7766-4. (The HDL Testbench Bible)


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • VHDL — est un langage de description matériel destiné à représenter le comportement ainsi que l architecture d’un système électronique numérique. Son nom complet est VHSIC[1] Hardware Description Language. L intérêt d une telle description réside dans… …   Wikipédia en Français

  • VHDL — es el acrónimo que representa la combinación de VHSIC y HDL, donde VHSIC es el acrónimo de Very High Speed Integrated Circuit y HDL es a su vez el acrónimo de Hardware Description Language. Es un lenguaje definido por el IEEE (Institute of… …   Wikipedia Español

  • VHDL — Появился в: 1983 Типизация данных: строгая Испытал влияние: Ada, Pascal VHDL (англ. VHSIC (Very high speed integrated circuits) Hardware Description Language) язык описания аппар …   Википедия

  • VHDL — es el acrónimo que representa la combinación de VHSIC y HDL, donde VHSIC es el acrónimo de Very High Speed Integrated Circuit y HDL es a su vez el acrónimo de Hardware Description Language. Es un lenguaje usado por ingenieros definido por el IEEE …   Enciclopedia Universal

  • VHDL — Die Abkürzung VHDL bezeichnet: eine Hardwarebeschreibungssprache, siehe Very High Speed Integrated Circuit Hardware Description Language. einen Bestandteil des Cholesterins, Very High Density Lipoproteins, siehe Lipoprotein Diese Seite ist eine …   Deutsch Wikipedia

  • VHDL — Very High Scale IC (Hardware) Description Language (IEEE1076 Standard, DoD, http://vhdl.org/) …   Acronyms

  • VHDL — Very High Scale IC (Hardware) Description Language (IEEE1076 Standard, DoD, http://vhdl.org/) …   Acronyms von A bis Z

  • VHDL-AMS — est un dérivé du langage de description matériel VHDL (norme IEEE 1076 1993). Il comprend des extensions analogiques et des signaux mixtes (en anglais analog and mixed signal, AMS) afin de définir le comportement des systèmes à signaux… …   Wikipédia en Français

  • VHDL-AMS — is a derivative of the hardware description language VHDL (IEEE standard 1076 1993). It includes analog and mixed signal extensions (AMS) in order to define the behavior of analog and mixed signal systems (IEEE 1076.1 1999).The VHDL AMS standard… …   Wikipedia

  • VHDL-AMS — Very High Speed Integrated Circuit Hardware Description Language (auch VHSIC Hardware Description Language), kurz VHDL, ist eine Hardwarebeschreibungssprache, vergleichbar mit einer Programmiersprache, mit der es einfach möglich ist, komplizierte …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”