Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

[D-TYPE flip-flop vhdl] a brief question about process

Hello guys,

here is vhdl code from the lecture slide. I don't understand why the prof chose the put the output outside of the process. Just wondering, if the clock is slow, and it's not yet at falling yet, then process is not triggered. And Qtemp will have no value assign to it. What will happen to Q ?

LIBRARY IEEE ;

USE IEEE . STD_LOGIC_1164 . ALL ;

---------------------------------------------

ENTITY Negative_Edge_D_FlipFlop_with_Asynchronous_RS IS

PORT (

D , Set , Reset : IN STD_LOGIC ;

Clock : IN STD_LOGIC ;

Q , Qbar : OUT STD_LOGIC

) ;

END ;

----------------------------------------------

ARCHITECTURE behavioural OF Negative_Edge_D_FlipFlop_with_Asynchronous_RS IS

SIGNAL Qtemp : STD_LOGIC ;

BEGIN

PROCESS ( Clock , Set , Reset )

BEGIN

-- note syntax for stating ‘Q’ becomes ‘D’ on falling edge of input clock

-- there is a ‘rising_edge’ notation also if you want positive edge triggering

IF ( Reset = '0' ) THEN

Qtemp <= '0' ;

ELSIF ( Set = '0‘ ) THEN

Qtemp <= '1' ;

ELSIF ( falling_edge ( Clock ) ) THEN

Qtemp <= D ;

END IF ;

END PROCESS ;

Q <= Qtemp ;

QBar <= NOT Qtemp ;

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Regarding Qbar, you need to put it outside as it is, since otherwise the compiler creates a second register to invert Q into Qbar.

    You can replace Qtemp with Q directly inside process and get rid of "Q <= Qtemp" which is outside process. In your case it is just wiring of Q to Qtemp but it will be rejected by compiler because you are not allowed to read output Q back. So Qtemp works as convenient intermediary.