Forum Discussion

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

signal'last_value: when can I use it?

Hello people!

I am kind of new to VHDL and I was wondering when one can use the X'last_value for a signal and when does that have a meaningful value. I mean except for the use with the clock signal, i do not know how the FPGA keeps track of the previous values of every signal.

For example I have a clocked process that has only the clock and reset at its sensitivity list. Inside the rising_edge block of the process i need to check the previous value of a signal that changes in a much slower pace than my clock. My main question is:

Is the "system" saving the previous value of every signal that is registered with this clock in every clock cycle?

2 Replies

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

    --- Quote Start ---

    Hello people!

    I am kind of new to VHDL and I was wondering when one can use the X'last_value for a signal and when does that have a meaningful value. I mean except for the use with the clock signal, i do not know how the FPGA keeps track of the previous values of every signal.

    For example I have a clocked process that has only the clock and reset at its sensitivity list. Inside the rising_edge block of the process i need to check the previous value of a signal that changes in a much slower pace than my clock. My main question is:

    Is the "system" saving the previous value of every signal that is registered with this clock in every clock cycle?

    --- Quote End ---

    No there is no such thing as automatic memory of signal values. The expression you mentioned is just the way the compiler used to understand clock signal for registers. I normally use if rising_edge(clk) ... i.e. function format
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It may be useful for simulation, but I don't think it will be too helpful for synthesis. Instead I think you will have to make use of a basic register to store the previous value.