1 | -- hello_world.vhdl Just output to the screen
|
2 | -- This should be independent of whose VHDL you use
|
3 | -- When using some vendors GUI, you have a learning curve
|
4 | -- Using portable VHDL, it will run on all vendors
|
5 | -- with implementations conforming to IEEE Std. 1076-1993
|
6 |
|
7 |
|
8 | entity hello_world is -- test bench (top level like "main")
|
9 | end entity hello_world;
|
10 |
|
11 | library STD; -- you don't need STD, it is automatic
|
12 | library IEEE; -- but may need other libraries
|
13 | use IEEE.std_logic_1164.all; -- basic logic types
|
14 | use STD.textio.all; -- basic I/O
|
15 | use IEEE.std_logic_textio.all; -- I/O for logic types
|
16 |
|
17 | architecture test of hello_world is -- where declarations are placed
|
18 | subtype word_32 is std_logic_vector(31 downto 0); -- simple name
|
19 | signal four_32 : word_32 := x"00000004"; -- just four in hex
|
20 | signal counter : integer := 1; -- initialized counter
|
21 | begin -- where parallel code is placed
|
22 | my_print : process is -- a process is parallel
|
23 | variable my_line : line; -- type 'line' comes from textio
|
24 | begin
|
25 | write(my_line, string'("Hello World")); -- formatting
|
26 | writeline(output, my_line); -- write to "output"
|
27 | write(my_line, string'("four_32 = ")); -- formatting
|
28 | hwrite(my_line, four_32); -- format type std_logic_vector as hex
|
29 | write(my_line, string'(" counter= "));
|
30 | write(my_line, counter); -- format 'counter' as integer
|
31 | write(my_line, string'(" at time "));
|
32 | write(my_line, now); -- format time
|
33 | writeline(output, my_line); -- write to display
|
34 | wait;
|
35 | end process my_print;
|
36 | end architecture test;
|
37 |
|
38 |
|
39 | -- compile/analyze this file, then simulate
|
40 | -- the output on the screen should contain the following lines (without "-- ")
|
41 |
|
42 | -- Hello World
|
43 | -- four_32 = 00000004 counter= 1 at time 0 NS
|