Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There actually are two issues here: (1) On what you are trying to build; (2) On the code itself.</p> <p>1) On what you are trying to build:</p> <p>You are trying to build a T-type flip-flop. This is usually built with a D-type flip-flop by simply connecting an inverted version of its output back to its input. In your case, you also want a "toggle enable" signal (called T in your code), to allow stopping the TFF when T=0. This means that the TFF input must go through an XOR gate, nothing else. </p> <p>Such XOR gate can be constructed as you did (AND-OR layers) or using directly an XOR gate. Because the DFFs in FPGAs are already constructed with an enable port (XOR functionality internal to the DFF), it is better to use the XOR option, saving logic and operating faster. But the other option will also function, obviously.</p> <p>2) Regarding the code:</p> <ul> <li>Q is buffer, not inout</li> <li>Include "and clk='1'" (-> rising_edge(clk))</li> <li>Eliminate variables hold1, hold2</li> <li>Use Q &lt;= T xor Q instead of Q &lt;= (T and notQ) or (not T and Q)</li> </ul> <hr> <pre><code>library ieee; use ieee.std_logic_1164.all; -------------------------------------------- entity T_FF is port ( T, clk: in std_logic; Q : buffer std_logic); end T_FF; -------------------------------------------- architecture behv of T_FF is begin process (clk) is begin if rising_edge(clk) then Q &lt;= (T and not Q) or (not T and Q); --Q &lt;= T xor Q; --preferred option end if; end process; end behv; -------------------------------------------- </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload