title: Latch duplication in technology schema (vhdl)
body: <p>Please note, this is a study question.  </p>
  
  <p>I have to describe a simple d-latch in vhdl, and then synthesize it. The problem is that it is a "unary" d-latch, and its single input is mapped directly to its outputs (Q and nQ). You can imagine it as a classical async d-latch, where clk signal is always high. This is useless element in logic, and xilinx synthesizer in most cases gives an empty technology schema. But the reason to keep this element is, for example, creating hardware "watermarks", which present on the schema, but don't affect its logic.<br>
  I came up with the following code:  </p>
  
  <pre><code>entity dLatch is
    port(
      d: in std_logic;
      q: out std_logic);
  end dLatch;
  
  architecture dLatch_beh of dLatch is  
    signal o: std_logic;
  begin
    latch: process(d)
    begin
      if d = '1' then
        o &lt;= '1';
      elsif d = '0' then
        o &lt;= '0';
      end if;
    end process;
  
    q &lt;= o;
  end;
  </code></pre>
  
  <p>This code produce the following technology schema</p>
  
  <p><a href="http://i.stack.imgur.com/XvOyb.png" rel="nofollow">link</a></p>
  
  <p>But when I try to add nQ out port, I gain duplication of latch</p>
  
  <pre><code>entity dLatch is
    port(
      d: in std_logic;
      q, nq: out std_logic);
  end dLatch;
  
  architecture dLatch_beh of dLatch is  
    signal o: std_logic;
  begin
    latch: process(d)
    begin
      if d = '1' then
        o &lt;= '1';
      elsif d = '0' then
        o &lt;= '0';
      end if;
    end process;
  
    q &lt;= o;
    nq &lt;= not o;
  end;
  </code></pre>
  
  <p>Technology schema: <a href="http://i.stack.imgur.com/reiER.png" rel="nofollow">link</a></p>
  
  <p>I don't understand, why I am getting two completely equal latches here. I expected only one additional 'not' gate.
  So my question is how to avoid the duplication of latches, or maybe some other way to solve this problem.
  I use Xilinx ISE Web Pack 14.6 for synthesis.</p>
  
  <p>UPD The solution is to set synthesizer's flag -register_duplication to false.</p>