title: Mod-M counter Unsigned values have no signal
body: <p>I am writing a RS232 module for my Nexys2 board. I am currently having issues with my baud rate controller which I want to set to 19200.</p>
  
  <p>For this I am using a Mod-M counter, after many ISim simulations the problem with my code is in the mod-m counter as it is not producing any ticks. </p>
  
  <pre><code>library IEEE;
  use IEEE.STD_LOGIC_1164.ALL;
  
  -- Uncomment the following library declaration if using
  -- arithmetic functions with Signed or Unsigned values
  use IEEE.NUMERIC_STD.ALL;
  
  -- Uncomment the following library declaration if instantiating
  -- any Xilinx primitives in this code.
  --library UNISIM;
  --use UNISIM.VComponents.all;
  
  entity baud_rate is
      generic (
      N: integer := 8;
      M: integer :=163);
      Port (clk, reset : in  STD_LOGIC;
             tick : out  STD_LOGIC;
                q : out STD_LOGIC_VECTOR(N-1 downto 0));
  
  end baud_rate;
  
  architecture Behavioral of baud_rate is
  signal r_reg :  unsigned(N-1 downto 0);
  signal r_next : unsigned(N-1 downto 0);
  begin
  process(clk,reset)
  begin
      if (reset ='1') then
          r_reg &lt;= (others=&gt;'0');
      elsif(clk'event and clk='1') then 
      r_reg &lt;= r_next;
      end if;
  end process;
  
  r_next &lt;= (others =&gt;'0') when r_reg=(M-1) else r_reg+1;
  tick &lt;='1' when r_reg=(M-1) else '0';
  q &lt;= std_logic_vector(r_reg);
  
  
  end Behavioral;
  </code></pre>
  
  <p>I have tested and all the clk inputs and run fine and the issue seems to be with the r_reg and r_next registers. In ISim when outputing either of these on q I get UUUUUUUU, so it seems they are not generating signal. From this i can infer that the two r_reg and r_next registers aren't being created or storing values, is there an issue when using unsigned?</p>
  
  <p>To make triple sure I have even copied the mod-m counter from the book FPGA Prototyping with VHDL (which is the code shown) BUT still this does not work and q output is UUUUUUUU.</p>
  
  <p>If there are any better ways of creating a baud rate from the nexys2 50mz clock that would also be appreciated!</p>
  
  <p>Cheers</p>