OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_peripheral/] [clk_source/] [xilinx_pll/] [xilinx_pll_sim/] [README.md] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
# Xilinx 7 Series PLL and MMCM Simulation
2
 
3
This project aims to simulate the behavior of the PLLE2_BASE as well as the PLLE2_ADV PLL and the MMCME2_BASE MMCM found on the Xilinx 7 Series FPGAs. The MMCME2_ADV MMCM is not (yet) supported. This is done in Verilog, and can for example be simulated using the Icarus Verilog simulation and synthesis tool. It follows the instantiation interface described in the [documentation](https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_3/ug953-vivado-7series-libraries.pdf) on page 509ff for the PLLs and 461ff for the MMCM. This way you can just drop the files listed below into your project, instantiate the PLL/MMCM like you would for real hardware and simulate it. Read on to learn how to use the module and what it can and cannot do. If you just want to know, what works and what doesn't, just have a look at the [project status](#status)
4
 
5
## Quickstart
6
 
7
To use this module, you need to have the following files in your project:
8
- ```plle2_base.v```, ```plle2_adv.v``` or ```mmcme2_base.v``` depending on [which one you want](#pll-choosing)
9
- ```period_count.v```
10
- ```period_check.v```
11
- ```freq_gen.v```
12
- ```divider.v```
13
- ```phase_shift.v```
14
- ```dyn_reconf.v```
15
- ```pll.v```
16
 
17
 
18
To build and simulate your project, you can use [icarus verilog and vvp](http://iverilog.icarus.com/) and view the results in [GTKWave](http://gtkwave.sourceforge.net/):
19
- ```iverilog plle2_base.v period_check.v period_count.v freq_gen.v divider.v phase_shift.v dyn_reconf.v pll.v  -o ```,
20
 
21
```iverilog plle2_adv.v period_check.v period_count.v freq_gen.v divider.v phase_shift.v dyn_reconf.v pll.v  -o ```
22
 
23
or ```iverilog mmcme2_base.v period_check.v period_count.v freq_gen.v divider.v phase_shift.v dyn_reconf.v pll.v  -o ```, depending on [which one you want](#pll-choosing)
24
- ```vvp ```
25
- ```gtkwave dump.vcd```
26
 
27
If you specified the name of your output file using something like ```$dumpfile("")```, you have to replace ```dump.vcd``` with your chosen name.
28
 
29
The module works by supplying an input clock, which will be transformed to an, or rather 6 (or 7 in the case of the MMCM), output clocks. In the simplest case, this output clock depends on the input clock and multiple parameters. You can set the wanted output frequency, phase shift and duty cycle. The output frequency is calculated like this: ```output frequency = input frequency * (multiplier / (divider * output divider))```, while the output phase can be calculated (in relation to the input phase) by using this formula: ```output phase = feedback phase + output phase```. The parts of these formulas with "output" in their name are specific to one specific output, while the others are global. There are certain limits to the values. If you hit them, the module is going to stop simulation and inform you about it. Check out the [FAQ](#FAQ) section at the end to learn more about these limits. You can also find a table there, how the allowed VCO frequency depends on FPGA model, their speed grades the used module (MMCM or PLL).
30
 
31
An typical instatiation of the PLLE2_BASE module might look like this:
32
 
33
        PLLE2_BASE #(
34
                .CLKFBOUT_MULT(8),                      // This multiplies your output clock by 8
35
                .CLKFBOUT_PHASE(90.0),          // This shifts the output clock by 90 degrees
36
                .CLKIN1_PERIOD(10.0),           // This specifies the period length of your input clock. This information is mandatory.
37
 
38
                // The following lines set up different dividers for every output
39
                .CLKOUT0_DIVIDE(128),
40
                .CLKOUT1_DIVIDE(64),
41
                .CLKOUT2_DIVIDE(32),
42
                .CLKOUT3_DIVIDE(16),
43
                .CLKOUT4_DIVIDE(128),
44
                .CLKOUT5_DIVIDE(128),
45
 
46
                // Similiarly you can set the duty cycle for every output
47
                .CLKOUT0_DUTY_CYCLE(0.5),
48
                .CLKOUT1_DUTY_CYCLE(0.5),
49
                .CLKOUT2_DUTY_CYCLE(0.5),
50
                .CLKOUT3_DUTY_CYCLE(0.5),
51
                .CLKOUT4_DUTY_CYCLE(0.9),
52
                .CLKOUT5_DUTY_CYCLE(0.1),
53
 
54
                // And the phase shift
55
                .CLKOUT0_PHASE(0.0),
56
                .CLKOUT1_PHASE(45.0),
57
                .CLKOUT2_PHASE(22.5),
58
                .CLKOUT3_PHASE(0.0),
59
                .CLKOUT4_PHASE(0.0),
60
                .CLKOUT5_PHASE(0.0),
61
 
62
                // You can also set up a divider for your input clock. This can be useful, if you have a very fast clock, which exceeds the limits of the PLL.
63
                .DIVCLK_DIVIDE(1),
64
 
65
                // At this point this instatiation differs from the real hardware. This is to allow setting a FPGA model and it's speed grade. This enables a more realistic simulation. It is, however, entirely optional. By default it is set to the most restrictive values (ARTIX -1), so it should work on every version.
66
                .FPGA_TYPE("ARTIX"),
67
                .SPEED_GRADE("-1"))
68
        pll (
69
                // Bind the outputs of the PLL, for example like this.
70
                .CLKOUT0(output[0]),
71
                .CLKOUT1(output[1]),
72
                .CLKOUT2(output[2]),
73
                .CLKOUT3(output[3]),
74
                .CLKOUT4(output[5]),
75
                .CLKOUT5(output[6]),
76
 
77
                // These should always be set to the same wire.
78
                .CLKFBOUT(CLKFB),
79
                .CLKFBIN(CLKFB),
80
 
81
                // This informs you, if the output frequency is usable.
82
                .LOCKED(locked),
83
                // Bind your input clock.
84
                .CLKIN1(clk),
85
 
86
                // Allows you to power down or reset the PLL.
87
                .PWRDWN(pwrdwn),
88
                .RST(rst));
89
 
90
## Example project
91
 
92
An example project using the PLLE2_BASE found under ```pll_example/pll_example.srcs/sources_1/new/```. It is a simple program to show the usage of the module. It can be simulated from the ```tb/``` or the ```pll_example``` directory using
93
 
94
- ```make pll_led_test```
95
 
96
This runs iverilog and vvp to simulate the module.
97
To inspect the results you can use GTKWave like this:
98
 
99
- ```gtkwave pll_led_tb.vcd```
100
 
101
The default values chosen are meant to be seen with the naked eye on real hardware. If you run the simulation using ```make``` the values are adjusted to be easy to see in GTKWave.
102
 
103
There is also an example project using the PLLE2_ADV found under ```pll_adv_example/pll_example.srcs/sources_1/new``` It is similar to the other example, but uses the PLLE2_ADV module and it's dynamic reconfiguration capabilities. It can be simulated from the ```tb/``` or the ```pll_adv_example``` directory using
104
 
105
- ```make pll_adv_example_test```
106
 
107
This runs iverilog and vvp to simulate the module. To inspect the results you can use GTKWave:
108
 
109
- ```gtkwave pll_adv_example_tb.vcd```
110
 
111
 
112
To learn more about the instantiation of the module, you should read [Xilinx UG953](https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_3/ug953-vivado-7series-libraries.pdf) page 509ff.
113
 
114

Project Status

115
 
116
### Working
117
- instantiation interface compatible to the one described in UG953
118
- setting the phase, duty cycle and divider of CLKOUT outputs (CLKOUTn_DIVIDE, CLKOUTn_DUTY_CYCLE and CLKOUTn_PHASE)
119
- lock detection (LOCKED)
120
- PWRDWN and RST signals
121
- setting DIVCLK_DIVIDE (divides the input clock)
122
- tests for RST, PWRDWN, output frequency, output phase and output duty cycle
123
- applying CLKFBOUT_MULT to multiply the output frequency
124
- applying CLKFBOUT_PHASE to set a phase shift to every output
125
- setting CLKINSEL and selecting one of two input clocks (PLLE2_ADV)
126
- basic dynamic reconfiguration functionality (PLLE2_ADV)
127
- CLKOUT6 (MMCME2_BASE)
128
- CLKOUT0_DIVIDE_F for fractional divides (MMCME2_BASE)
129
- CLKOUT0-3B for inverted outputs
130
- CLKOUT4_CASCADE for using the divider of CLKOUT6 to divide the CLKOUT4 output again (MMCME2_BASE)
131
- CLKFBOUT_MULT_F for fractional multipies (MMCME2_BASE)
132
- stopping the simulation, if illegal values are hit
133
- chaining PLLs should work as expected, although the CLKFBIN input is ignored
134
 
135
### Not Working
136
- there is no feedback loop by design
137
- BANDWIDTH, REF_JITTER1, REF_JITTER2, COMPENSATION and STARTUP_WAIT settings won't work with the current design approach
138
- connecting CLKFBIN to any other clock than CLKFBOUT won't change the behaviour of the module
139
- dynamic reconfiguration only has an effect in the ClkReg1 and ClkReg2 registers as well as the DivReg register (PLLE2_ADV)
140
- RESERVED bits in the dynamic reconfiguration are ignored (PLLE2_ADV)
141
 
142
## Test
143
 
144
You can test this project automatically using avocado or make. The testbenches themselves are written in pure verilog.
145
 
146
### Avocado [recommended]
147
 
148
- install avocado: [Documentation](https://avocado-framework.readthedocs.io/en/latest/#how-to-install)
149
- change into the ```tb/``` folder
150
- run ```$ avocado run test_freq_gen.py test_high_counter.py test_period_check.py test_period_count.py test_phase_shift.py test_plle2_adv.py test_plle2_base.py test_mmcme2_base.py test_dyn_reconf.py```
151
 
152
### Make
153
 
154
- change into the ```tb/``` folder
155
- run ```make```. This will just run every testbench in it's default configuration.
156
 
157
## Architecture
158
 
159
This diagram roughly outlines the basic architecture of the project outlining the ```pll.v``` module, which has the ```plle2_base.v```, ```plle2_adv.v``` and ```mmcme2_base.v``` modules as wrappers determining the needed functionality.
160
 
161
![architecture diagram](https://raw.githubusercontent.com/ti-leipzig/sim-x-pll/master/arch.svg?sanitize=true)
162
 
163
## License
164
 
165
This project is licensed under the [ISC license](https://github.com/ti-leipzig/sim-x-pll/blob/master/LICENSE).
166
 
167

FAQ

168
 
169
### What limits does the PLL/MMCM have?
170
Use this table for parameters:
171
 
172
| parameter          | allowed values                            |
173
| ------------------ | ----------------------------------------- |
174
| BANDWIDTH          | "OPTIMIZED", "HIGH", "LOW"                |
175
| CLKFBOUT_MULT      | 2 - 64                                    |
176
| CLKFBOUT_MULT_F        | 2.000 - 64.000                            |
177
| CLKFBOUT_PHASE     | -360.000 - 360.000                        |
178
| CLKINn_PERIOD      | 0 - 52.631                                |
179
| CLKOUTn_DIVIDE     | 1 - 128                                   |
180
| CLKOUT0_DIVIDE_F   | 1.000 - 128.000                           |
181
| CLKOUTn_DUTY_CYCLE | -360.000 - 360.000                        |
182
| CLKOUT4_CASCADE    | "FALSE", "TRUE"                           |
183
| DIVCLK_DIVIDE      | 1 - 56                                    |
184
| REF_JITTERn        | 0.000 - 0.999                             |
185
| STARTUP_WAIT       | "FALSE", "TRUE"                           |
186
| COMPENSATION       | "ZHOLD", "BUF_IN", "EXTERNAL", "INTERNAL" |
187
| CLKOUT4_CASCADE    | "TRUE", "FALSE"                           |
188
 
189
Also there is a limitation in the PLL regarding the possible frequency. They depend on the capabilities of the VCO, which itself depends on the FPGA model, it's speedgrade and if it's used by a PLL or an MMCM. It's frequency can be calculated using this formula: ```VCO frequency = (CLKFBOUT_MULT * 1000) / (CLKIN1_PERIOD * DIVCLK_DIVIDE)```. Use this table for reference:
190
 
191
| FPGA model        | -3       | -2       | -2L      | -2LE     | -2LI     | -2LG     | -1       | -1LI     | -1M      | -1LM     | -1Q      |
192
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
193
| **ARTIX** - PLL   | 800-2133 | 800-1866 | N/A      | 800-1600 | N/A      | N/A      | 800-1600 | 800-1600 | N/A      | N/A      | N/A      |
194
| **ARTIX** - MMCM  | 600-1600 | 600-1440 | N/A      | 600-1200 | N/A      | N/A      | 600-1200 | 600-1200 | N/A      | N/A      | N/A      |
195
| **KINTEX** - PLL  | 800-2133 | 800-1866 | N/A      | 800-1600 | 800-1866 | N/A      | 800-1600 | N/A      | 800-1600 | 800-1600 | 800-1600 |
196
| **KINTEX** - MMCM | 600-1600 | 600-1440 | N/A      | 600-1200 | 600-1440 | N/A      | 600-1200 | N/A      | 600-1200 | 600-1200 | 600-1200 |
197
| **VIRTEX** - PLL  | 800-2133 | 800-1866 | 800-1866 | N/A      | N/A      | 800-1866 | 800-1600 | N/A      | 800-1600 | N/A      | N/A      |
198
| **VIRTEX** - MMCM | 600-1600 | 600-1440 | 600-1440 | N/A      | N/A      | 600-1440 | 600-1200 | N/A      | 600-1200 | N/A      | N/A      |
199
 
200
 
201

Which PLL/MMCM should I choose?

202
 
203
The main differences between the two PLL versions are the support for two input clocks and dynamic reconfiguration in PLLE2_ADV. For a more in-depth overview of the differences see [UGS472 page 70](https://www.xilinx.com/support/documentation/user_guides/ug472_7Series_Clocking.pdf).
204
 
205
The MMCM offers an additional output (CLKOUT6), fractional divides for CLKOUT0 and CLKFBOUT (which functions as a fractional multiplier) and the possibility to use the divider of CLKOUT6 to divide CLKOUT4 again, allowing for divisors as high as 16384 (128 * 128).
206
 
207
### Is this module synthesizable?
208
No, it isn't. This project is purely for simulation purposes. It is not meant to be synthesizable and contains a lot of unsynthesizable code. The [examples](https://github.com/ti-leipzig/sim-x-pll/tree/master/pll_example) however are synthesizable.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.