confusion when resetting registers

Discussion in 'VHDL' started by martin f. krafft, Aug 18, 2004.

  1. Hi all,

    A student of mine is currently working on an implementation of
    artificial neurons in FPGAs. We are experiencing a weird problem
    trying to reset. I am only the messenger here (because I use
    usenet), but from what I understand, the problem is as follows:

    The weights connecting neurons are stored as 8 bit values in an
    array (std logic vector) and there is a button that we want to use
    to reset all weights to zero. The button is value '1' when not
    pressed and '0' when pressed. Here is the logic we tried:

    Reset: process (clock,Rst_n)
    begin
    if (clock'event and clock='1') then
    ResP <= Rst_n;
    end if;
    end process Reset;

    ResetAndClock: process (clock, ResP)
    begin
    if (ResP = '0') then
    RegWeightsP <= (others => '0');
    RegDIPvalueP <= (others => '0');
    elsif (clock'event and clock='1') then
    RegWeightsP <= RegWeightsN;
    RegDIPvalueP <= DIPvalue;
    end if;
    end process ResetAndClock;

    The idea is to force the creation of a flip-flop ResP to stabilise
    the reset button value. In the second process, this register is then
    queried and the weights reset if it's '0' or propagated if not.

    I am not exactly sure why he uses *P and *N (the previous and next
    values), but I believe it has to do with stabilisation.

    Anyway, the problem is that the reset works fine while the button is
    pressed, but as soon as we let go, the weight registers assume their
    old values.

    What are we doing wrong?

    You can find the complete implementation of the neuron at

    ftp://ftp.madduck.net/scratch/neuron.vhdl

    Suggestions, comments, anything about the whole code or other parts
    or whatever are very welcome. Primarily we would like to get the
    reset switch working though.

    Also, if any of the above is unclear, please ask and I will try to
    clarify as best as I can.

    Thanks a bunch,

    Martin Krafft
    AILab, Univ. Zürich, Switzerland
     
    martin f. krafft, Aug 18, 2004
    #1
    1. Advertising

  2. martin f. krafft

    Jeroen Guest

    "martin f. krafft" <> wrote in message
    news:...
    > Hi all,
    >
    > A student of mine is currently working on an implementation of
    > artificial neurons in FPGAs. We are experiencing a weird problem
    > trying to reset. I am only the messenger here (because I use
    > usenet), but from what I understand, the problem is as follows:
    >
    > The weights connecting neurons are stored as 8 bit values in an
    > array (std logic vector) and there is a button that we want to use
    > to reset all weights to zero. The button is value '1' when not
    > pressed and '0' when pressed. Here is the logic we tried:
    >
    > Reset: process (clock,Rst_n)
    > begin
    > if (clock'event and clock='1') then
    > ResP <= Rst_n;
    > end if;
    > end process Reset;
    >
    > ResetAndClock: process (clock, ResP)
    > begin
    > if (ResP = '0') then
    > RegWeightsP <= (others => '0');
    > RegDIPvalueP <= (others => '0');
    > elsif (clock'event and clock='1') then
    > RegWeightsP <= RegWeightsN;
    > RegDIPvalueP <= DIPvalue;
    > end if;
    > end process ResetAndClock;
    >


    RegWeightsN is not reset; I assume this signal is driven from somewhere
    else.

    Jeroen
     
    Jeroen, Aug 18, 2004
    #2
    1. Advertising

  3. martin f. krafft

    Paul Sereno Guest

    "Jeroen" <> wrote in message news:<4123b9c2$0$48933$4all.nl>...
    > "martin f. krafft" <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > A student of mine is currently working on an implementation of
    > > artificial neurons in FPGAs. We are experiencing a weird problem
    > > trying to reset. I am only the messenger here (because I use
    > > usenet), but from what I understand, the problem is as follows:
    > >
    > > The weights connecting neurons are stored as 8 bit values in an
    > > array (std logic vector) and there is a button that we want to use
    > > to reset all weights to zero. The button is value '1' when not
    > > pressed and '0' when pressed. Here is the logic we tried:
    > >
    > > Reset: process (clock,Rst_n)
    > > begin
    > > if (clock'event and clock='1') then
    > > ResP <= Rst_n;
    > > end if;
    > > end process Reset;
    > >
    > > ResetAndClock: process (clock, ResP)
    > > begin
    > > if (ResP = '0') then
    > > RegWeightsP <= (others => '0');
    > > RegDIPvalueP <= (others => '0');
    > > elsif (clock'event and clock='1') then
    > > RegWeightsP <= RegWeightsN;
    > > RegDIPvalueP <= DIPvalue;
    > > end if;
    > > end process ResetAndClock;
    > >

    >
    > RegWeightsN is not reset; I assume this signal is driven from somewhere
    > else.
    >
    > Jeroen


    Martin,
    I do not understand what you mean with
    "the problem is that the reset works fine while the button is pressed,
    but as soon as we let go, the weight registers assume their old
    values."
    Analyzing the ResetAndClock process, the first part (if) will be
    executed when ResP be equal to '0' (bottom press), the registers get
    '0'. When the bottom is released the 'elsif' part will be executed
    (ResP='1'). In this part RegWeightsP will get whatever value is in the
    RegWeightsN signal. If RegWeightsN has not changed since the previous
    active clock edge, RegWaithsP will get an 'old' value from
    RegWeightsN. . . So, check when RegWeightsN changes and then check
    whether RegWeightsP is update on the next rising edge of the clock.

    paul
     
    Paul Sereno, Aug 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MM
    Replies:
    3
    Views:
    643
    Ralf Hildebrandt
    Jul 28, 2004
  2. Replies:
    5
    Views:
    547
  3. tom
    Replies:
    5
    Views:
    549
    =?ISO-8859-1?Q?G=F6ran_Bilski?=
    Jan 19, 2005
  4. ALuPin

    Input registers in ispLEVER

    ALuPin, Jan 26, 2005, in forum: VHDL
    Replies:
    1
    Views:
    780
  5. Replies:
    1
    Views:
    548
    Peter Alfke
    Mar 25, 2005
Loading...

Share This Page