title: VHDL Demultiplexer output to switch signal between port
body: <p>Please go easy on me, I'm new to this...   :)  I have a signal in which I would like to toggle the output between one of two available output ports TX_ADDR and TX_DATA based on the value of a count CNT.  The idea is to pipe some value first 32 bit value I get serially to an address bus, then to the data bus, then the address, then data...And so on.  And I basically keep that routine going ad infinitum.  </p>
  
  <p>If I have something like:</p>
  
  <pre><code>   process(sCNT)
     begin
     if(sCNT = false) then
         TX_ADDR &lt;= sTXD;
         sCNT    &lt;= true;
     else
         TX_DATA &lt;= sTXD;
         sCNT    &lt;= false;
     end if;
     end process;
  </code></pre>
  
  <p>...it doesn't seem to work.  Basically the idea is that sCNT ('s' indicates a signal) needs to be toggled once another process receives 32 bits of data serially.  The next 32 bits basically trigger that again, and then again the output is toggled to either TX_ADDR or TX_DATA depending on the state of sCNT.</p>
  
  <p>Thank you!</p>
  
  <p>John</p>
  
  <p>EDIT:  here's the full updated and "working" code.  I didn't see where I could paste this much code into a comment so I thought I'd share it up here:  </p>
  
  <pre><code>process(CLK, RST)
   begin
      if (RST = '1') then
        sRXD       &lt;= x"00000000";
        sINDEX     &lt;= 31;
        sTXD       &lt;= x"00000000";
        sSCLK_old  &lt;= '0';
        sSCLK_l    &lt;= '0';
        sCS_old    &lt;= '0';
        sCS_l      &lt;= '0';
        DONE       &lt;= '0';
        sMOSI_l    &lt;= '0';
  
      elsif( rising_edge(CLK) ) then
  
        sSCLK_l       &lt;= SCLK;
        sSCLK_old     &lt;= sSCLK_l;
        sCS_l         &lt;= CS;
        sCS_old       &lt;= sCS_l;
        DONE          &lt;= '0';
        sMOSI_l       &lt;= MOSI;
  
        if(TX_EN = '1') then
            sTXD &lt;= TX_DATA;
        end if;
  
        if (sCS_old = '1' and sCS_l = '0') then
            sINDEX &lt;= 31;
        end if;
  
        if( sCS_l = '0' ) then
           if(sSCLK_old = '0' and sSCLK_l = '1') then
              sRXD &lt;= sRXD(30 downto 0) &amp; sMOSI_l;
              if(sINDEX = 0) then
                 sINDEX &lt;= 31;
              else
                 sINDEX &lt;= sINDEX-1;
              end if;
           elsif(sSCLK_old = '1' and sSCLK_l = '0') then
              if( sINDEX = 31 ) then
                 DONE &lt;= '1';
              end if;
              sTXD &lt;= sTXD(30 downto 0) &amp; '1';
           end if;
        end if;
  
  
       if(sCNT = false) then
           RX_ADDR &lt;= sRXD;
           sCNT    &lt;= true;
       else
           RX_DATA &lt;= sRXD;
           sCNT    &lt;= false;
       end if;
     end if;
     end process;
  
     MISO    &lt;= sTXD(31);
  end arch;
  </code></pre>