r/VHDL • • 8d ago

help !!!!!!

Title: VHDL 7-segment display multiplexing – AUTOCHECK fails, but simulation and FPGA board seem to work correctly

Hi everyone,

this text is ai generated and is based on the conversation i had with the ai model about the code.

I'm working on a VHDL assignment using a Nexys A7-100T FPGA board. The task is to display the numbers 1 through 8, with one number on each of the eight 7-segment displays.

I'm having trouble understanding why the teacher's AUTOCHECK reports errors even though my simulation looks correct and the display works correctly on the physical board.

1. What the assignment requires

  • Display the numbers 1 to 8, from left to right.
  • Use all eight 7-segment displays.
  • Activate each display for 125 µs.
  • The cathodes must be 8 bits wide, including the decimal point.
  • The decimal points must remain OFF.
  • The clock input is 100 MHz.

2. My current VHDL code

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;

entity opg_5 is
    Port (
        clk      : in std_logic;
        anodes   : out STD_LOGIC_VECTOR(7 downto 0);
        cathodes : out STD_LOGIC_VECTOR(7 downto 0)
    );
end opg_5;

architecture Behavioral of opg_5 is

    signal clkcounter : integer range 0 to 12499 := 0;
    signal clk_dig : integer range 0 to 7 := 0;

    signal anodes_n : STD_LOGIC_VECTOR(7 downto 0) := "01111111";
    signal cathodes_n : STD_LOGIC_VECTOR(7 downto 0) := "11111001";

begin

    anodes <= anodes_n;
    cathodes <= cathodes_n;

    P_clkdiv : process(clk)
    begin
        if rising_edge(clk) then
            if clkcounter = 12499 then
                clkcounter <= 0;

                if clk_dig = 7 then
                    clk_dig <= 0;
                else
                    clk_dig <= clk_dig + 1;
                end if;

            else
                clkcounter <= clkcounter + 1;
            end if;
        end if;
    end process;

    P_display : process(clk_dig)
    begin
        case clk_dig is

            when 0 =>
                cathodes_n <= "11111001";
                anodes_n   <= "01111111";

            when 1 =>
                cathodes_n <= "10100100";
                anodes_n   <= "10111111";

            when 2 =>
                cathodes_n <= "10110000";
                anodes_n   <= "11011111";

            when 3 =>
                cathodes_n <= "10011001";
                anodes_n   <= "11101111";

            when 4 =>
                cathodes_n <= "10010010";
                anodes_n   <= "11110111";

            when 5 =>
                cathodes_n <= "10000010";
                anodes_n   <= "11111011";

            when 6 =>
                cathodes_n <= "11111000";
                anodes_n   <= "11111101";

            when 7 =>
                cathodes_n <= "10000000";
                anodes_n   <= "11111110";

            when others =>
                cathodes_n <= "11111111";
                anodes_n   <= "11111111";

        end case;
    end process;

end Behavioral;

3. What I have already checked

I initially had the display-selection case statement inside the clock-divider process. I was advised to separate it into a second process sensitive to clk_dig.

After doing that:

  • The simulation shows clk_dig counting from 0 to 7 and then returning to 0.
  • Each digit changes every 125 µs.
  • One complete scanning cycle takes 1 ms.
  • The cathode patterns change as expected.
  • Only one anode is active (LOW) at a time.
  • The physical FPGA board displays the numbers 1 through 8 in the correct order.

I also checked the initial values in the simulation at exactly 0 ns:

  • anodes = 7F (hexadecimal), which is 01111111 in binary.
  • cathodes = F9 (hexadecimal), which is 11111001 in binary.

These match the initial values I assigned in my code.

4. The AUTOCHECK feedback

Despite all this, the teacher's AUTOCHECK reports:

AUTOCHECK 1: NOK

Anodes=11001101b en niet 01111111b op tijdstip 0.
Cathodes=0000000

Translation: At timestamp 0, the checker expected anodes 01111111, but found 11001101. It also reports an unexpected cathode value.

AUTOCHECK 2: NOK

Cijfer 2 werd verwacht op de cathodes in plaats van 1001111

Translation: The checker expected digit 2 on the cathodes but found 1001111.

One detail: the AUTOCHECK feedback shows a 7-bit cathode value, whereas my assignment explicitly requires 8 bits because the decimal point must also be controlled.

5. My XDC mapping

I'm using the Nexys A7-100T. My cathode pin mapping is:

cathodes[0] -> ca
cathodes[1] -> cb
cathodes[2] -> cc
cathodes[3] -> cd
cathodes[4] -> ce
cathodes[5] -> cf
cathodes[6] -> cg
cathodes[7] -> dp

The anodes are mapped to an[0] through an[7].

6. My questions

  1. Why would AUTOCHECK report incorrect initial output values when my simulation shows the correct values at exactly 0 ns?
  2. Could this be related to delta cycles, signal initialization, or the way the testbench samples the outputs?
  3. Is there something wrong with my cathode encoding, especially for digit 2?
  4. Could the checker be expecting a different bit ordering or a different convention for the decimal point?
  5. Is there any problem with separating the clock divider and display-selection logic into two processes?

I'm particularly interested in understanding the actual cause of these failures rather than randomly changing code that already works on the FPGA.

I'd really appreciate a technical explanation or suggestions for what I should investigate next.

Thank you!

0 Upvotes

2 comments sorted by

4

u/skydivertricky 8d ago

Anodes and cathodes are "UUUUUUUU" at time 0 because this is what the default initial value is. It takes 1 delta for the _n signal to update the output port.

1

u/And-Bee 8d ago

Timestep 0, is right at the start of simulation but you sensitive to rising clk, so at time 0 you can’t have rising edge so it is undefined.