2020-09-24 14:50:59 -05:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Design Name : D-type Flip-flops
|
|
|
|
// File Name : ff.v
|
|
|
|
// Coder : Xifan TANG
|
|
|
|
//-----------------------------------------------------
|
|
|
|
|
2020-11-06 11:18:37 -06:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : A native D-type flip-flop with single output
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFQ (
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q // Q output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ (posedge CK) begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
2020-09-24 14:50:59 -05:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : A native D-type flip-flop
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFF (
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
2020-09-24 15:53:21 -05:00
|
|
|
always @ (posedge CK) begin
|
2020-09-24 14:50:59 -05:00
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
2020-11-06 12:19:19 -06:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - single output
|
|
|
|
// - asynchronous active high reset
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFRQ (
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q // Q output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
|
2020-09-24 14:50:59 -05:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFR (
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active low reset
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFRN (
|
|
|
|
input RSTN, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or negedge RSTN)
|
|
|
|
if (~RSTN) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high set
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFS (
|
|
|
|
input SET, // Set input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge SET)
|
|
|
|
if (SET) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active low set
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFSN (
|
|
|
|
input SETN, // Set input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or negedge SETN)
|
|
|
|
if (~SETN) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - asynchronous active high set
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFSR (
|
|
|
|
input SET, // set input
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // QB output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST or posedge SET)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SET) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
// Wire q_reg to Q
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = ~q_reg;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
|
|
|
//-----------------------------------------------------
|
2020-09-24 18:26:48 -05:00
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - asynchronous active high set
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module DFFSRQ (
|
|
|
|
input SET, // set input
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input D, // Data Input
|
2020-09-24 18:41:03 -05:00
|
|
|
output Q // Q output
|
2020-09-24 18:26:48 -05:00
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST or posedge SET)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SET) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
2020-09-24 18:53:30 -05:00
|
|
|
assign Q = q_reg;
|
2020-09-24 18:26:48 -05:00
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
2020-09-24 18:38:16 -05:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - asynchronous active high set
|
|
|
|
// - scan-chain input
|
|
|
|
// - a scan-chain enable
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module SDFFSR (
|
|
|
|
input SET, // Set input
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input SE, // Scan-chain Enable
|
|
|
|
input D, // Data Input
|
|
|
|
input SI, // Scan-chain input
|
|
|
|
output Q, // Q output
|
|
|
|
output QN // Q negative output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST or posedge SET)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SET) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else if (SE) begin
|
|
|
|
q_reg <= SI;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
// Wire q_reg to Q
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = !Q;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
2020-11-30 18:54:10 -06:00
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - scan-chain input
|
|
|
|
// - a scan-chain enable
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module SDFFRQ (
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input SE, // Scan-chain Enable
|
|
|
|
input D, // Data Input
|
|
|
|
input SI, // Scan-chain input
|
|
|
|
output Q // Q output
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SE) begin
|
|
|
|
q_reg <= SI;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
assign Q = q_reg;
|
|
|
|
|
|
|
|
endmodule //End Of Module
|
|
|
|
|
2020-09-24 18:26:48 -05:00
|
|
|
//-----------------------------------------------------
|
2020-09-24 14:50:59 -05:00
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - asynchronous active high set
|
|
|
|
// - scan-chain input
|
|
|
|
// - a scan-chain enable
|
|
|
|
//-----------------------------------------------------
|
2020-09-24 18:33:14 -05:00
|
|
|
module SDFFSRQ (
|
2020-09-24 14:50:59 -05:00
|
|
|
input SET, // Set input
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
2020-09-24 18:33:14 -05:00
|
|
|
input SE, // Scan-chain Enable
|
2020-09-24 14:50:59 -05:00
|
|
|
input D, // Data Input
|
2020-09-24 18:33:14 -05:00
|
|
|
input SI, // Scan-chain input
|
2020-09-24 18:41:03 -05:00
|
|
|
output Q // Q output
|
2020-09-24 14:50:59 -05:00
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST or posedge SET)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SET) begin
|
|
|
|
q_reg <= 1'b1;
|
|
|
|
end else if (SE) begin
|
|
|
|
q_reg <= SI;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
2020-09-24 18:53:30 -05:00
|
|
|
assign Q = q_reg;
|
2020-09-24 14:50:59 -05:00
|
|
|
|
|
|
|
endmodule //End Of Module
|
2021-01-04 15:31:26 -06:00
|
|
|
|
|
|
|
//-----------------------------------------------------
|
|
|
|
// Function : D-type flip-flop with
|
|
|
|
// - asynchronous active high reset
|
|
|
|
// - scan-chain input
|
|
|
|
// - a scan-chain enable
|
|
|
|
// - a configure enable, when enabled the registered output will
|
|
|
|
// be released to the Q
|
|
|
|
//-----------------------------------------------------
|
|
|
|
module CFGSDFFR (
|
|
|
|
input RST, // Reset input
|
|
|
|
input CK, // Clock Input
|
|
|
|
input SE, // Scan-chain Enable
|
|
|
|
input D, // Data Input
|
|
|
|
input SI, // Scan-chain input
|
|
|
|
input CFGE, // Configure enable
|
|
|
|
output Q, // Regular Q output
|
|
|
|
output CFGQ, // Data Q output which is released when configure enable is activated
|
|
|
|
output CFGQN // Data Qb output which is released when configure enable is activated
|
|
|
|
);
|
|
|
|
//------------Internal Variables--------
|
|
|
|
reg q_reg;
|
2021-01-04 18:17:35 -06:00
|
|
|
wire QN;
|
2021-01-04 15:31:26 -06:00
|
|
|
|
|
|
|
//-------------Code Starts Here---------
|
|
|
|
always @ ( posedge CK or posedge RST)
|
|
|
|
if (RST) begin
|
|
|
|
q_reg <= 1'b0;
|
|
|
|
end else if (SE) begin
|
|
|
|
q_reg <= SI;
|
|
|
|
end else begin
|
|
|
|
q_reg <= D;
|
|
|
|
end
|
|
|
|
|
|
|
|
assign CFGQ = CFGE ? Q : 1'b0;
|
2021-01-04 18:17:35 -06:00
|
|
|
assign CFGQN = CFGE ? QN : 1'b1;
|
2021-01-04 15:31:26 -06:00
|
|
|
|
|
|
|
`ifndef ENABLE_FORMAL_VERIFICATION
|
|
|
|
// Wire q_reg to Q
|
|
|
|
assign Q = q_reg;
|
|
|
|
assign QN = !Q;
|
|
|
|
`else
|
|
|
|
assign Q = 1'bZ;
|
|
|
|
assign QN = !Q;
|
|
|
|
`endif
|
|
|
|
|
|
|
|
endmodule //End Of Module
|