------------------------------------------------------------------------------- --! @file --! @author Hipolito Guzman-Miranda --! @brief Emulates on-board leds. ------------------------------------------------------------------------------- --! Use IEEE standard definitions library library ieee; --! Use std_logic* signal types use ieee.std_logic_1164.all; --! Use the slv2string function present in the vhdl_verification package use work.vhdl_verification.all; --! @brief Emulates on-board leds --! --! @details Checks for events on \c led_input port, and reports the current --! state of the leds each time any the input bit changes. Does not keep any --! internal memory, \c led_input is assumed to be directly connected to the --! leds. entity led_emu is generic ( ACTIVE_VALUE : std_logic := '0'; --! Led polarity NUM_LEDS : integer := 4 --! How many leds are we emulating ); port ( led_input : in std_logic_vector(NUM_LEDS-1 downto 0) --! Connect here the signal that drives the leds ); end led_emu; --! @brief Architecture is based on just a single process --! --! @detailed An assertion has also been added to check that \c ACTIVE_VALUE is --! set to a non-ambiguous strong value (either '0' or '1'). architecture led_emu_arch of led_emu is begin -- ACTIVE_VALUE must be either '0' or '1' (no other values supported) assert ACTIVE_VALUE = '0' or ACTIVE_VALUE = '1' report "led_emu: ACTIVE_VALUE must be either '0' or '1'" severity failure; --! @brief Report led state each time there is an event in \c led_input --! --! @detailed We don't actually need to check for \c led_input'event, since --! putting \c led_input in the sensitivity list of the process does it for --! us. We use the report statement to print a string to the simulation log, --! and the slv2string function in the vhdl_verification package to convert --! the std_logic_vector value to a printable string. process (led_input) begin report "led_emu: current state of leds: " & slv2string(led_input); end process; end led_emu_arch;