µ±Ç°Î»Ö㺠´úÂëÃÔ >> ×ÛºÏ >> FPGAѧϰ֮·(Ò»)Ö®DÀà´¥·¢Æ÷(Data Flip-Flop/Delay Flip-Flop)´î½¨
  Ïêϸ½â¾ö·½°¸

FPGAѧϰ֮·(Ò»)Ö®DÀà´¥·¢Æ÷(Data Flip-Flop/Delay Flip-Flop)´î½¨

Èȶȣº44   ·¢²¼Ê±¼ä£º2024-02-06 05:04:18.0

hello£¬´ó¼ÒºÃ£¬ÕâÀïÊÇxddcore¡£×î½ü¿ªÊ¼ÕÛÌÚFPGA£¬È»ºó½ñÌìÔçÉÏ»¨ÁËÒ»¸ö¶àСʱµÄʱ¼ä£¬´î½¨ÁËÒ»¸öDÀà´¥·¢Æ÷¡£ÎªºóÃæÒª×öµÄBCD Genertor×öһЩǰÆÚ¹¤×÷¡£(¹ØÓÚ BCD GenertorµÄÉè¼Æ˼·¿ÉÒÔ¿´ÎÒµÄÕâƪ²©¿Í:https://blog.csdn.net/qq_36229876/article/details/107728996)

Ç°ÑÔ

ʲôÊÇDÀà´¥·¢Æ÷£¿

D´¥·¢Æ÷£¨data flip-flop»òdelay flip-flop£©ÓÉ4¸öÓë·ÇÃÅ×é³É£¬ÆäÖÐG1ºÍG2¹¹³É»ù±¾RS´¥·¢Æ÷¡£µçƽ´¥·¢µÄÖ÷´Ó´¥·¢Æ÷¹¤×÷ʱ£¬±ØÐëÔÚÕýÌøÑØÇ°¼ÓÈëÊäÈëÐźš£D´¥·¢Æ÷ÔÚʱÖÓÂö³åCPµÄÇ°ÑØ£¨ÕýÌø±ä0¡ú1£©·¢Éú·­×ª£¬´¥·¢Æ÷µÄ´Î̬ȡ¾öÓÚCPµÄÂö³åÉÏÉýÑص½À´Ö®Ç°D¶ËµÄ״̬£¬¼´´Î̬=D¡£Òò´Ë£¬Ëü¾ßÓÐÖÃ0¡¢ÖÃ1Á½ÖÖ¹¦ÄÜ¡£ÓÉÓÚÔÚCP=1ÆÚ¼äµç·¾ßÓÐά³Ö×èÈû×÷Óã¬ËùÒÔÔÚCP=1Æڼ䣬D¶ËµÄÊý¾Ý״̬±ä»¯£¬²»»áÓ°Ïì´¥·¢Æ÷µÄÊä³ö״̬¡£

Ó¦ÓÃ

D´¥·¢Æ÷Ó¦Óúܹ㣬¿ÉÓÃ×öÊý×ÖÐźŵļĴ棬ÒÆλ¼Ä´æ£¬·ÖƵºÍ²¨Ðη¢ÉúÆ÷µÈ¡£ÔÚBCD GenertorÖУ¬ÎÒÖ÷Òª°ÑËüµ±×÷ÿ´Î×ÔÔö1µÄ¼Ó·¨Æ÷Óá£

Òý½Å¶¨Òå

ÔÚÕâÀï²åÈëͼƬÃèÊö

D, //Êý¾ÝÊäÈë
CLK, //ʱÖÓ(ÉÏÉýÑØÓÐЧ)
SD, //¸´Î»(µÍµçƽÓÐЧ)£¬QÖÃ1
RD, //¸´Î»(µÍµçƽÓÐЧ)£¬QÖÃ0
Q, //Êä³ö¶Ë
QN //Êä³ö¶ËQÈ¡·´

¹¤×÷Ô­Àí

Èç¹ûÒªÓÃÎÄ×ÖÀ´ÃèÊö¹¤×÷Ô­Àí»á±È½Ï¸´ÔÓ£¬µ«ÊÇÓÃÕæÖµ±íµÄ»°£¬´ó¼ÒÒ»¿´¾ÍÃ÷°×ÁË¡£
ÔÚÕâÀï²åÈëͼƬÃèÊö
ps:CP=CLK£¬R=RD£¬S=SD£¬~Q=QN
Ò»¾ä»°¸ÅÊöDÀà´¥·¢Æ÷¹¤×÷Ô­Àí:µ±RD=SD=1ʱ£¬Ã¿µ±CLKÉÏÉýÑØ£¬±ã½«DÉϵĵçƽ״̬¸³Öµ¸øQ£¬QNµÈÓÚ~Q
ÔÙÀ´Á½¾ä»°½øÐв¹³ä˵Ã÷:
1.µ±RD=0,SD=1ʱ£¬DÀà´¥·¢Æ÷´¦ÓÚ¸´Î»µÍµçƽ±£³Ö״̬£¬Q=0£¬QN=1
1.µ±RD=1,SD=0ʱ£¬DÀà´¥·¢Æ÷´¦ÓÚ¸´Î»¸ßµçƽ±£³Ö״̬£¬Q=1£¬QN=0

Verilog³ÌÐò±àд

`timescale 1 ns/ 1 ns //ʱ¼äµ¥Î»/ʱ¼ä¾«¶Èmodule data_flip_flop( //¶¨ÒåDÀà´¥·¢Æ÷Ä£¿éD, //Êý¾ÝÊäÈëCLK, //ʱÖÓ(ÉÏÉýÑØÓÐЧ)SD, //¸´Î»(µÍµçƽÓÐЧ)£¬QÖÃ1RD, //¸´Î»(µÍµçƽÓÐЧ)£¬QÖÃ0Q, //Êä³ö¶ËQN //Êä³ö¶ËÈ¡·´);//===========================================================================
// ¶Ë¿ÚÉùÃ÷Óë¼Ä´æÆ÷¶¨Òå
//=========================================================================== 
input D; //Êý¾ÝÊäÈë
input CLK; //ʱÖÓÊäÈë(ÉÏÉýÑØÓÐЧ)
input SD; //¸´Î»(µÍµçƽÓÐЧ)£¬QÖÃ1
input RD; //¸´Î»(µÍµçƽÓÐЧ)
output Q; //Êä³ö¶Ë
output QN; //Êä³ö¶ËÈ¡·´reg Q; //1bitµÄÊä³öQ
reg QN; //1bitµÄÊä³öQN//===========================================================================
// Ö÷ÌåÂß¼­
//=========================================================================== always @(posedge CLK) //CLKÉÏÉýÑØ´¥·¢beginif({RD,SD} == 2'b11) //µ±RD,SD¶¼Îª¸ßµçƽʱ£¬Ã¿¸öCLKÉÏÉýÑØ£¬°ÑDµÄÊý¾ÝÈ¡µ½QbeginQ <= D; //·Ç×èÈû¸³ÖµQN <= ~D;endelse if({RD,SD} == 2'b01) //µ±RD=0,SD=1ʱbeginQ <= 1'b0;QN <= 1'b1;endelse if({RD,SD} == 2'b10) //µ±RD=1,SD=0ʱbeginQ <= 1'b1;QN <= 1'b0;endend
endmodule //Ä£¿é½áÊø 

TestBench

// Copyright (C) 2017 Intel Corporation. All rights reserved.
// Your use of Intel Corporation's design tools, logic functions 
// and other software and tools, and its AMPP partner logic 
// functions, and any output files from any of the foregoing 
// (including device programming or simulation files), and any 
// associated documentation or information are expressly subject 
// to the terms and conditions of the Intel Program License 
// Subscription Agreement, the Intel Quartus Prime License Agreement,
// the Intel FPGA IP License Agreement, or other applicable license
// agreement, including, without limitation, that your use is for
// the sole purpose of programming logic devices manufactured by
// Intel and sold by Intel or its authorized distributors. Please
// refer to the applicable agreement for further details.// *****************************************************************************
// This file contains a Verilog test bench template that is freely editable to 
// suit user's needs .Comments are provided in each section to help the user 
// fill out necessary details. 
// *****************************************************************************
// Generated on "08/04/2020 10:22:36"// Verilog Test Bench template for design : data_flip_flop
// 
// Simulation tool : ModelSim-Altera (Verilog)
// `timescale 1 ns/ 1 ns
module data_flip_flop_test(); //Ä£¿éÃûºÍvtÎļþÃû±£³ÖÒ»ÖÂreg CLK;reg D;reg RD;reg SD;// wires wire Q;wire QN;// assign statements (if any) data_flip_flop i1 (// port map - connection between master ports and signals/registers .CLK(CLK),.D(D),.Q(Q),.QN(QN),.RD(RD),.SD(SD));initial //³õʼ»¯ begin                                                                          CLK = 1'b1; //ʱÖÓÏßÀ­¸ßD <= 1'b0;  //Êý¾ÝÏßÀ­µÍ RD <= 1'b1; //ban 0 resetSD <= 1'b1; //ban 1 reset$display("Running Data flip-flop testbench");                                                                    foreverbegin#60 D <= 1'b1;#22 D <= 1'b0; //Ä£ÄâÔëÉù#2 D <= 1'b1; //Ä£ÄâÔëÉù#2 D <= 1'b0; //Ä£ÄâÔëÉù#16 D <= 1'b0;end  endalways #20 CLK <= ~CLK; //Éú³ÉÖÜÆÚ40nsµÄclkÐźÅendmodule

RTL·ÂÕæ½á¹û

ÔÚÕâÀï²åÈëͼƬÃèÊö

½áÂÛ

ͨ¹ýÉÏÊö·ÂÕæ½á¹û£¬¿ÉÒÔ¿´³ö£¬ÊµÏÖÁËDÀà´¥·¢Æ÷µÄ¹¤×÷Ч¹û¡£±¾´ÎÀûÓÃFPGA´î½¨DÀà´¥·¢Æ÷µÄÈÎÎñÄ¿±êʵÏÖ¡£

  Ïà¹Ø½â¾ö·½°¸