Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

VHDL default signal state bug ?

We tried to do a very simple thing: a demultiplexer that enables one of several gates according to the state of an n-signal vector. (Just static, no Flipflops involved.)

So we defined a 2^n signal vector and set the default value to "0" and later in the code we set one of it's the signals to "1" by an appropriate statement.

We were used to use this method with Xilinx projects and it did work fine there.

We did find a (supposedly more "recommended") way to create a demultiplexer (without using default values), so no harm done, but....

Our first try might be considered "bad style" but the Quartus did not complain and I don't see why this does not work with Quartus (but with teh Xilinx tool chain). So I feel this is might be a bug....

-Michael

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    this second method has no meaning, because you cannot xor an integer with anything, or invert it, or assing it directly to a std_logic_vector.

    --- Quote End ---

    Oops, no simple operations creating logical results from numerical values ?!?!?!

    But if you cay a process does not harm, I do see how to proceed.

    Thanks a lot for the VHDL introduction !!!

    Michael (having noticed that C is a straight forward language :) )
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Oops, no simple operations creating logical results from numerical values ?!?!?!

    --- Quote End ---

    VHDL is strongly typed, so you have to be careful with your typecasting. an integer is not a collection of bits, so you cant extract them from it. A std_logic_vector is NOT an integer, it is a collection of bits, and can represent anything (an unsigned integer, signed integer, float, double, a bus full of control bits, fixed point binary, BCD - anything). But if you mean to store something as an integer, use an integer type rather than a std_logic_vector.

    I notice you use the std_logic_arith/unsigned packages. You might want to change over to iee.numeric_std instead seeing as you are a beginner - best to get into good habits now. Numeric_std is an ieee standard, std_logic_arith and the like are not - they encourage you to forget about the typing that VHDL provides and use std_logic_vectors as integers, which they are not!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Numeric_std is an ieee standard, std_logic_arith and the like are not

    --- Quote End ---

    std_logic_arith is the old IEEE standard, still used in all Altera IP till now. It doesn't involve std_logic_unsigned/signed, which is a different thing. Regarding the original question, if you are intending just a simple combinational decoder, the generate variant is a straightforward way to build it.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    std_logic_arith was never an IEEE standard. It was created by synopsys to bring together what everyone else had done in their own packages. Because numeric std wasnt around until vhdl '93 everyone adopted it.

    VHDL '08 brings std_logic_arith packages all together again into IEEE standard packages.