I am new in VHDL. The code below doesn't work for some reason. The D0 and D1 are switches and when I added the D1 it stopped working. clk_Centi is pointing to an LED.

end if;
end process gen_clk;

    clk_Centi <= clk_Centi_i WHEN D0='0' AND D1='0' ELSE
            clk_Sec_i WHEN D0='1' AND D1='0' ELSE
            clk_Min_i WHEN D0='0' AND D1='1';

end Behavioral;
| improve this question | | | | |

In VHDL, you have to take into account every possibilities in a combinatory block for the program to work properly. I think that if you add a line with

WHEN D0='1' AND D1='1'

It will work again.

| improve this answer | | | | |
  • \$\begingroup\$ Easier way is to delete the last WHEN expression which will then cover all the bases for you. \$\endgroup\$ – Brian Drummond May 29 '16 at 21:42
  • \$\begingroup\$ When D0=1 and D1=1 (the state I didn't take into account) my output should be -. Is there a way to state this in VHDL? \$\endgroup\$ – traveller May 30 '16 at 3:50
  • \$\begingroup\$ Brians solution should work here without having to care about solving this - with D0=1 and D1=1 it will act like D0=0 and D1=1. Or maybe you do not want it to act like this. \$\endgroup\$ – Albits May 30 '16 at 7:44
  • \$\begingroup\$ I should match this case as zero as this will be the output of some leds. \$\endgroup\$ – traveller May 30 '16 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.