VHDL-verification
Package to ease directed testing of HDL entities
led_emu.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 --! @file
3 --! @author Hipolito Guzman-Miranda
4 --! @brief Emulates on-board leds.
5 -------------------------------------------------------------------------------
6 
7 --! Use IEEE standard definitions library
8 library ieee;
9 --! Use std_logic* signal types
10 use ieee.std_logic_1164.all;
11 --! Use the slv2string function present in the vhdl_verification package
12 use work.vhdl_verification.all;
13 
14 --! @brief Emulates on-board leds
15 --!
16 --! @details Checks for events on \c led_input port, and reports the current
17 --! state of the leds each time any the input bit changes. Does not keep any
18 --! internal memory, \c led_input is assumed to be directly connected to the
19 --! leds.
20 entity led_emu is
21  generic (
22  ACTIVE_VALUE : std_logic := '0'; --! Led polarity
23  NUM_LEDS : integer := 4 --! How many leds are we emulating
24  );
25  port (
26  led_input : in std_logic_vector(NUM_LEDS-1 downto 0) --! Connect here the signal that drives the leds
27  );
28 end led_emu;
29 
30 --! @brief Architecture is based on just a single process
31 --!
32 --! @detailed An assertion has also been added to check that \c ACTIVE_VALUE is
33 --! set to a non-ambiguous strong value (either '0' or '1').
34 architecture led_emu_arch of led_emu is
35 
36 begin
37 
38  -- ACTIVE_VALUE must be either '0' or '1' (no other values supported)
39  assert ACTIVE_VALUE = '0' or ACTIVE_VALUE = '1'
40  report "led_emu: ACTIVE_VALUE must be either '0' or '1'"
41  severity failure;
42 
43  --! @brief Report led state each time there is an event in \c led_input
44  --!
45  --! @detailed We don't actually need to check for \c led_input'event, since
46  --! putting \c led_input in the sensitivity list of the process does it for
47  --! us. We use the report statement to print a string to the simulation log,
48  --! and the slv2string function in the vhdl_verification package to convert
49  --! the std_logic_vector value to a printable string.
50  process (led_input)
51  begin
52  report "led_emu: current state of leds: " & slv2string(led_input);
53  end process;
54 
55 end led_emu_arch;
_library_ ieeeieee
Use IEEE standard definitions library.
Definition: keypad_emu.vhd:8
in led_inputstd_logic_vector( NUM_LEDS- 1 downto 0)
Connect here the signal that drives the leds.
Definition: led_emu.vhd:27
Common datatypes and component declarations.
Emulates on-board leds.
Definition: led_emu.vhd:20
ACTIVE_VALUEstd_logic := '0'
Led polarity.
Definition: led_emu.vhd:22
NUM_LEDSinteger := 4
How many leds are we emulating.
Definition: led_emu.vhd:24