Forum Discussion

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

simple vhdl question

when "000" PRICE = "110010";

How do I code the above so that it reads

when "000" the price is "110010"

2 Replies

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

    Did you notice the HDL templates in Quartus editor context menu (right mouse click in the editor window)? They have examples for all usual VHDL constructs.

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

    It depends on where you want to do it. If "000" is the value of some signal - say some_signal and you have various options then use a case statement, e.g.:

    
    case some_signal
        when "000" =>
            PRICE <= "110010";
        when "111" =>
            PRICE <= some other value;
        when others =>
            PRICE <= some default value;
    end case;

    note that the case statement has to be within a process. You could do if then else:

    if some_signal = "000" then
        PRICE <= "110010";
    else
        PRICE <= some value;
    end if;

    If you don't want / have a process then you coule write it as a concurrent statement - i.e just on its own:

    PRICE <= "110010" when some_signal = "000" else "some default value";