FF_4bit_SR.nsl


/* ************************************************************ */
declare FF_4bit_sr {

    input       D_in[4] ;           // D input
    input       SR_in ;             // Synchronous RESET input
    input       ENB_in ;            // Data hold enable input

    output      Q_out[4] ;          // Flip-Flop data output

}

/* ************************************************************ */
// Declare module
module FF_4bit_sr {

/* ************************************************************ */
// Internal operation signals
    reg         Dtype_FF[4] ;           // Declare D-type F/F

/* ************************************************************ */
// Equation

    {
/* **** Data output **** */
        Q_out = Dtype_FF ;      // Q_out = Dtype_FF[3:0] ; is acceptable
                                // Q_out[3:0] = .... is not acceptable

/* **** Flip-Flop equation **** */

    // Statement variation #1
        if ( SR_in )
            Dtype_FF := 4'b0 ;              // Set INITIAL value
        else
            if ( ENB_in )
                Dtype_FF := D_in ;          // Capture NEW data

/*
    // Statement variation #2
        if ( SR_in ) {
            Dtype_FF := 4'b0 ;              // Set INITIAL value
        } else {
            if ( ENB_in ) {
                Dtype_FF := D_in ;          // Capture NEW data.
            }
        }
*/

/*
    // Statement variation #3 : Using ALTERNATE syntax
        alt {
            SR_in   : Dtype_FF := 4'b0 ;    // Set INITIAL value
            ENB_in  : Dtype_FF := D_in ;    // Capture NEW data.
        }
*/

    }
}
/* ************************************************************ */
PAGE TOP