Forum Discussion

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

When to reset a signal.

In one process I set a command


    when X"01" =>  --continious data read
         cont_ram_addr := to_integer(unsigned(addr_bus));
       ram_command <= RAM_CONT_WRITE;
     when X"02" =>  --continious data write
         cont_ram_addr := to_integer(unsigned(addr_bus));
       ram_command <= RAM_CONT_READ;
     when X"03" => --read data command 
         ram_command <= RAM_BYTE_WRITE;
     when X"04" => --write data command 
         ram_command <= RAM_BYTE_READ;

In another process I read this command and do some actions according the command.

      case RamState is
        when ST_IDLE =>
        if(ram_command > "000") then  
          case ram_command is
           when RAM_CONT_WRITE => RamState <= ST_CONT_WR_RAM;
           when RAM_CONT_READ  => RamState <= ST_CONT_RD_RAM;
           when RAM_BYTE_WRITE => RamState <= ST_WR_RAM;
           when RAM_BYTE_READ  => RamState <= ST_RD_RAM;
           when others => RamState <= ST_IDLE;
       end case;
      end if;
      
    when ST_WR_RAM =>   - 
        --do something
      RamState <= ST_IDLE;
      
      when ST_RD_RAM =>   
        --do something
        RamState <= ST_IDLE;
    when ST_CONT_WR_RAM =>        
        -do something
      RamState <= ST_IDLE;
 
    when ST_CONT_RD_RAM =>
     -- do something 
        RamState <= ST_IDLE;

But where and when I should reset ram_command. If I return to ST_IDLE I once again evaluate ram_command case and create endless loop. ram_command should be reset at some point.

5 Replies

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

    This is a design choice for the designer. Without knowing the design, it will be impossible to comment.

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

    Looks like you either need to incorporate the command setting logic into the command executing state machine, or at least you need the state machine to be able to communicate with the command setting logic (to reset the command or whatever you need to make the design work). As Tricky said, very hard to give advice from such little information.

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

    --- Quote Start ---

    Looks like you either need to incorporate the command setting logic into the command executing state machine, or at least you need the state machine to be able to communicate with the command setting logic (to reset the command or whatever you need to make the design work). As Tricky said, very hard to give advice from such little information.

    --- Quote End ---

    That's the problem. I'd gladly reset ram_command in the second process. But I get Error (10028): Can't resolve multiple constant drivers for net. So I dont know when I'm good to reset the signal.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    That's the problem. I'd gladly reset ram_command in the second process. But I get Error (10028): Can't resolve multiple constant drivers for net. So I dont know when I'm good to reset the signal.

    --- Quote End ---

    Like I said in your other post, you need to communicate between processes with signals. Create a signal for the sole purpose to send a message between the processes that can reset you ram_command signal.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Like I said in your other post, you need to communicate between processes with signals. Create a signal for the sole purpose to send a message between the processes that can reset you ram_command signal.

    --- Quote End ---

    But who reset the other signal - the one that reset ram_command? And when?

    Thanks guys. Stupid question. I figured it out.