1- -------------------------------------------------------------------------------
2- --
3- -- File: DFlop.vhd
4- -- Author: Tamas Gyorfi
5- -- Original Project: Vivado support for 7-series LabVIEW FPGA targets
6- -- Date: 16 July 2013
7- --
8- -------------------------------------------------------------------------------
9- -- (c) 2013 Copyright National Instruments Corporation
10- -- All Rights Reserved
11- -- National Instruments Internal Information
12- -------------------------------------------------------------------------------
13- --
14- -- Purpose:
15- -- This creates a flip-flop using either the FDCE or FDPE Xilinx
16- -- primitives, depending on the desired async. reset value of the Flop.
17- -- The implementation described in this component is specific to Vivado,
18- -- since Vivado no longer supports the FDCPE primitive on newer FPGAs (>V6).
19- --
20- -- The kAsyncReg generic is helping to set the ASYNC_REG attribute
21- -- for the instantiated FDCE or FDPE primitives.
22- -- This cannot be done from the upper levels where the DFlop is instantiated,
23- -- since the attribute can not propagate from the net to his driver FF.
24- -- We set the default value to "false" so the already existing instances
25- -- would not require to be updated.
26-
27- -- The ASYNC_REG attribute affects optimization, placement, and routing to improve Mean
28- -- Time Between Failure (MTBF) for registers that may go metastable. If ASYNC_REG is applied,
29- -- the placer will ensure the flip-flops on a synchronization chain are placed closely to
30- -- maximize MTBF. Registers with ASYNC_REG that are directly connected will be grouped and
31- -- placed together into a single SLICE, assuming they have a compatible control set and the
32- -- number of registers does not exceed the available resources of the SLICE
33- --
34- -- Asrar Rangwala July 12 2023: Minor changes were manually made to this file to make it compile with
35- -- vsmake. A better long term fix would be to upgrade LV FPGA's version of NICores to the latest.
36- -- However, that's a non-trivial task and unlikely to be prioritized unless necessary.
37- -- Since, there is a quick workaround available, we have opted to apply a manual
38- -- change to this file rather than update it to an official export of the NICores.
39- -------------------------------------------------------------------------------
40-
41- library ieee;
42- use ieee.std_logic_1164.all ;
43-
44- library work;
45- use work.PkgNiUtilities.all ;
46-
47- library UNISIM;
48- use UNISIM.vcomponents.all ;
49-
50- entity DFlop is
51-
52- generic (kResetVal : std_logic := '0' ;
53- kAsyncReg : string := " false" );
54- port (
55- aReset, cEn : in boolean ;
56- Clk, cD : in std_logic ;
57- cQ : out std_logic := kResetVal
58- );
59- end DFlop;
60-
61- architecture rtl of DFlop is
62- attribute ASYNC_REG : string ;
63- begin
64-
65- -- This VScan model helps VScan analyze this as a flip-flop and not
66- -- be fooled by the delta delay that occurs on the PRE and CLR signals.
67- GenVScanModel: if false generate
68- process (aReset, Clk)
69- begin
70- if aReset then
71- cQ <= '0' ;
72- elsif rising_edge (Clk) then
73- if cEn then cQ <= cD; end if ;
74- end if ;
75- end process ;
76- end generate GenVScanModel;
77-
78- --vscan vscan_off
79-
80- -- !!NOTE:
81- -- If you change the instance names in this component, consider updating
82- -- DFlop module generator as well: vi.lib\rvi\nicores\ClockBoundaryCrossing\DFlopBaseniFpgaDflopInstanceName.vi
83-
84- GenClr: if kResetVal= '0' generate
85- attribute ASYNC_REG of ClearFDCPEx : label is kAsyncReg;
86- begin
87- -- Generate Flop with asynchronous clear
88-
89- --vhook_i FDCE ClearFDCPEx
90- --vhook_a INIT '0'
91- --vhook_a IS_CLR_INVERTED '0'
92- --vhook_a IS_C_INVERTED '0'
93- --vhook_a IS_D_INVERTED '0'
94- --vhook_a CLR To_StdLogic(aReset)
95- --vhook_a C Clk
96- --vhook_a CE To_StdLogic(cEn)
97- --vhook_a D cD
98- --vhook_a Q cQ
99- ClearFDCPEx: FDCE
100- generic map (
101- INIT => '0' , --bit:='0'
102- IS_CLR_INVERTED => '0' , --bit:='0'
103- IS_C_INVERTED => '0' , --bit:='0'
104- IS_D_INVERTED => '0' ) --bit:='0'
105- port map (
106- Q => cQ, --out std_ulogic:=TO_X01(INIT)
107- C => Clk, --in std_ulogic
108- CE => To_StdLogic(cEn), --in std_ulogic
109- CLR => To_StdLogic(aReset), --in std_ulogic
110- D => cD); --in std_ulogic
111-
112- end generate GenClr;
113-
114- GenSet: if kResetVal= '1' generate
115- attribute ASYNC_REG of PresetFDCPEx : label is kAsyncReg;
116- begin
117- -- Generate Flop with asynchronous preset
118-
119- --vhook_i FDPE PresetFDCPEx
120- --vhook_a INIT '1'
121- --vhook_a IS_CLR_INVERTED '0'
122- --vhook_a IS_C_INVERTED '0'
123- --vhook_a IS_D_INVERTED '0'
124- --vhook_a IS_PRE_INVERTED '0'
125- --vhook_a PRE To_StdLogic(aReset)
126- --vhook_a C Clk
127- --vhook_a CE To_StdLogic(cEn)
128- --vhook_a D cD
129- --vhook_a Q cQ
130- PresetFDCPEx: FDPE
131- generic map (
132- INIT => '1' , --bit:='1'
133- IS_C_INVERTED => '0' , --bit:='0'
134- IS_D_INVERTED => '0' , --bit:='0'
135- IS_PRE_INVERTED => '0' ) --bit:='0'
136- port map (
137- Q => cQ, --out std_ulogic:=TO_X01(INIT)
138- C => Clk, --in std_ulogic
139- CE => To_StdLogic(cEn), --in std_ulogic
140- D => cD, --in std_ulogic
141- PRE => To_StdLogic(aReset)); --in std_ulogic
142-
143- end generate GenSet;
144-
145- --vscan vscan_on
146-
147- end rtl;
1+ ----------------------------------------------
2+ -- IMPLEMENTATION NOT NEEDED FOR TESTING
3+ ----------------------------------------------
0 commit comments