Hexadecimal digit to seven-segment LED decoder : Testing circuit

Last post has talked the seven-segment LED decoder.

To save the number of FPGA chip’s I/O pins, a time-multiplexing scheme is used , as shown in Figure (a). The circuit generates a properly timed enable signal and routes the four input parttens to the ouput alternatively. The design of this module is discussed in later post. For now, we just treat it as a black box.

Testing circuit

We use a simple 8-bit increment circuit to verify operation of the decoder. The sketch is shown in Figure (b).


library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity hex_to_sseg_test is
    port(
        clk: in std_logic;
        sw: in std_logic_vector(7 downto 0);
        an: out std_logic_vector(3 downto 0);
        sseg: out std_logic_vector(7 downto 0);
        );
    end hex_to_sseg_test;
    
architecture arch of hex_to_sseg_test is 
    signal inc: std_logic_vector(7 downto 0);
    signal led3,led2,led1,led0: std_logic_vector(7 downto 0);
begin
    --increment input
    inc <= std_logic_vector(unsigned(sw) + 1); 
                --instantiate four instances of hex decoders 
                --instance for 4 LSBs of input 
                sseg_unit_0: entity work.hex_to_sseg 
                port map(hex => sw(3 downto 0), dp=> '0',sseg=> led0);
        --instance for 4 MSBs of input
        sseg_unit_1: entity work.hex_to_sseg
        port map(hex => sw(7 downto 4), dp=> '0',sseg=> led1);
        --instance for 4 LSBs of incremented value 
        sseg_unit_2: entity work.hex_to_sseg
        port map(hex => sw(3 downto 0), dp=> '1',sseg=> led2);
        --instance for MSBs of incremented value
        sseg_unit_3: entity work.hex_to_sseg
        port map(hex => sw(7 downto 4), dp=> '1',sseg=> led3);
        --instantiate 7-seg LED display time-multiplexing module
        disp_unit: entity work.disp_mux
        port map(
        clk => clk, reset => '0',
        in0=>led0, in1 =>led1,in2=>led2, in3 =>led3,
        an => an, sseg=> sseg);
end arch; 
News Reporter
Dr. Lu

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Skip to toolbar