On Tuesday, July 12, 2016 at 1:44:33 PM UTC-4, Pavel-Ioan Duta wrote:
>
> I know there are many ways of doing this latch and i'm a novice on VHDL but even the smallest progress is still a prgress :)
Then here is a little tidbit, don't bother with the component declaration. Instead you directly instantiate. Where you currently have a component and you instantiate like this...
> COMPONENT NOR2 PORT(a,b : IN BIT; c : OUT BIT); END COMPONENT;
> U1 : NOR2 PORT MAP(R,NQ,Q);
> U2 : NOR2 PORT MAP(Q,S,NQ);
Instead you can skip the component declaration and instead write it like this...
> U1 : entity work.NOR2 PORT MAP(R,NQ,Q);
> U2 : entity work.NOR2 PORT MAP(Q,S,NQ);
As you've probably already noticed, the entity declaration for NOR2 and the component declaration for NOR2 are nearly identical. Problem occurs when those two declarations are not identical usually due to some change in one place that is not reflected in the other. The errors you get from the simulator are often not terribly clear when you have this problem.
By using direct entity instantiation (i.e. putting 'entity work.' in front of the NOR2 entity name), you no longer need to have the component declaration. Since now there is only the entity defining the interface, you don't have to worry about changing the interface in one place and not the other. Also less code to write.
This has nothing to do with modelling an RS flip flop, just a tip on how to write things better to avoid future problems.
Kevin Jennings