2
\$\begingroup\$

If, for example, I implement a multiplexer in VHDL using logic gates, it may produce hazards, but if I use a higher level of abstraction describing the circuit in code, the simulation will not produce these hazards.

So, can glitches in hardware be eliminated completely by using behavioural code instead of structural gate-level implementations?

\$\endgroup\$
4
  • 7
    \$\begingroup\$ Both implementations are becoming hardware in the end. And theoretically your "gates" implementation can end up identical to the synthesized behavioral. So there will be no difference. \$\endgroup\$ Commented Feb 22, 2023 at 20:04
  • \$\begingroup\$ 'the simulation' is poorly specified. If you mean a simulation quantised on discrete time steps, then the hazard occurs before the value for each step is chosen. If you mean an asynchronous 'next event' type simulation, then the hazards are reproduced right there if mathematically real numbers are simulated as the time to the next event. If finite precision computer reals are used instead, then it's a discrete time simulation again. \$\endgroup\$ Commented Feb 22, 2023 at 20:38
  • \$\begingroup\$ It sounds like you want a HDL that does automatic formal verification (BMC, induction, etc.) to generate a proof that there are no combinatorial logic hazards in the generated implementation? \$\endgroup\$ Commented Feb 22, 2023 at 21:23
  • 1
    \$\begingroup\$ VHDL is a description, not an implementation! It is a language you use to tell the tools what behavior you want, not how to achieve it (if no constraints are given). When you describe a multiplexer using "logic gates", you still describe the same truth table as produced by higher levels of abstraction. The tooling is very good at figuring out the best way to implement each part of a truth table, so the description is largely out of the question. \$\endgroup\$ Commented Feb 23, 2023 at 2:31

2 Answers 2

6
\$\begingroup\$

This may change the behaviour of the VHDL simulation, but when you actually want to operate the circuit in an FPGA, both of them are going to be turned into (probably) the same hardware with the same glitches.

Since you are using Xilinx tools, you have the ability to simulate the programmed FPGA, rather than simulating the VHDL code, and you might see the same glitches there too.

\$\endgroup\$
5
\$\begingroup\$

Can glitches in hardware be eliminated completely by using behavioral code instead of structural gate-level implementations?

No. You must check the resulting hardware, simulate the final results (not the VHDL code) and use constraints if needed.

If, for example, I implement a multiplexer in VHDL using logic gates

You don't actually implement it, you describe it when using VHDL or Verilog. It is the synthesis tool that actually implements the hardware that matches the description.

For example, consider this MUX 4x1 interface:

library IEEE;
use IEEE.std_logic_1164.all;

entity mux4x1 is
    port(D3, D2, D1, D0 : in std_ulogic;
         SEL : in std_ulogic_vector(1 downto 0);
         MX_OUT : out std_ulogic);
end mux4x1;

and these 3 implementations:

architecture my_mux4x1 of mux4x1 is
begin
    MX_OUT <= D3 when (SEL = "11") else
              D2 when (SEL = "10") else
              D1 when (SEL = "01") else
              D0 when (SEL = "00") else
              '0';
end my_mux4x1;

architecture my_mux4x1 of mux4x1 is
begin
    process (D3, D2, D2, D0) is
    begin
        if (SEL(1) = '1') then
            if (SEL(0) = '1') then
                MX_OUT <= D3;
            else
                MX_OUT <= D2;
            end if;
        else
            if (SEL(0) = '1') then
                MX_OUT <= D1;
            else
                MX_OUT <= D0;
            end if;
        end if;
    end process;
end my_mux4x1;

architecture my_mux4x1 of mux4x1 is
begin
    MX_OUT <= (SEL(1) and SEL(0) and D3) or
              (SEL(1) and (not SEL(0)) and D2) or
              (not(SEL(1)) and SEL(0) and D1) or
              (not(SEL(1)) and not(SEL(0)) and D0);
end my_mux4x1;

All 3 descriptions are implemented with a single Lookup-Table (LUT6) by Vivado for a Xilinx FPGA.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.