FPGA Quartus - II - 时钟约束.docx
17页FPGA Quartus - II - 时钟约束 FPGA QuartusII 时钟约束时钟约束〔Clock Specification〕:约束全部时钟〔包括你的设计中特有的时钟〕对精确的时序分析结果而言是必不行少的Quartus II TimeQuest Timing Analyzer为各种各样的时钟配置和典型时钟供应很多SDC吩咐时钟〔Clocks〕运用create_clock吩咐为任何register, port或pin进展时钟特性描述,使其具有独一的时钟特性例6–2展示了create_clock吩咐: Example 6–2. create_clock Commandcreate_clock-period [-name ] [-waveform ] [-add]Table 6–6. create_clock Command Options选项 -period [-name ] [-waveform ] [-add]Example 6–3 约束时钟频率101MHz,占空比50%,0ns上升沿,5ns下降沿 Example 6–3. 101MHz Clock Creationcreate_clock –period 10 –waveform { 0 5 } clk指定时钟周期 指定时钟名称〔不必须是约束时钟的节点名称〕 指定时钟上升沿/下降沿 可以对一个时钟节点进展多个时钟约束 指定你要约束的时钟〔目标节点〕 描述 这个章节将介绍SDC可用的应用编程接口,以及描述指定的时钟特性。
Example 6–4和上例相差90度的相位Example 6–4. 101MHz Shifted by 90 Degrees Clock Creationcreate_clock –period 10 –waveform { 2.5 7.5 } clk_sys运用create_clock吩咐约束时钟缺省的source Latency值为0Quartus II TimeQuest Timing Analyzer自动为非虚拟时钟〔non-virtual clocks〕计算时钟网络延时〔clock’s network latency〕Quartus II Handbook, Volume 3 6-29 生成时钟〔Generated Clocks〕Quartus II TimeQuest Timing Analyzer可以把修改或变更主时钟〔或者引入时钟〕特性的分频时钟、水纹时钟和电路作为生成时钟你可以定义这些电路的输出作为生成时钟这些定义可以让Quartus II TimeQuest Timing Analyzer分析这些时钟以及关联的时钟网络延时〔network latency〕运用create_generated_clock吩咐定义生成时钟。
Example 6–5. create_generated_clock Commandcreate_generated_clock [-name ] -source [-edges ] [-edge_shift ] [-divide_by ] [-multiply_by ] [-duty_cycle ] [-add] [-invert][-master_clock ] [-phase ][-offset ]Table 6–7. create_generated_clock Command Options选项 -name -source -edges | -edge_shift -divide_by | -multiply_by 生成时钟名 指定被设定的时钟节点 -edges指定和主时钟的上升沿和下降沿有关的新的上升沿和下降沿 -divide_by和-multiply_by要素是基于第一个时钟上升沿,通过设定来延长或者缩短指定要素的波形 -duty_cycle -add -invert -master_clock -phase -offset源延时是由于从主时钟〔不必须是主管脚〕起先的时钟网络延时所致。
你可以运用set_clock_latency –source吩咐约束源延时Figure 6–17 展示了如何产生一个基于10ns时钟的反向生成时钟: Figure 6–17. Generating an Inverted Clock create_clock -period 10 [get_ports clk]create_generated_clock -divide_by 1 -invert -source [get_registers clk] \\ [get_registers gen|clkreg]指定生成时钟的占空比 允许你对同一个管脚添加多个时钟约束 用于主管脚上有多个时钟存在时指定一个主时钟 指定生成时钟的相位 指定生成时钟的偏移 指定被安排到的目标管脚 描述Figure 6–18 展示了如何运用-edges和-edge_shift选项以变更生成时钟 Figure 6–18. Edges and Edge Shifting a Generated Clock create_clock -period 10 -waveform { 0 5} [get_ports clk] # Creates a divide-by-t clockcreate_generated_clock -source [get_ports clk] -edges {1 3 5 } [get_registers \\ clkdivA|clkreg]# Creates a divide-by-2 clock independent of the master clocks’ duty cycle (now 50%)create_generated_clock -source [get_ports clk] -edges {1 1 5} -edge_shift { 0 2.5 0 } \\ Figure 6–19 展示了-multiply_by选项对生成时钟的影响。
Figure 6–19. Multiplying a Generated Clockcreate_clock -period 10 -waveform { 0 5 } [get_ports clk]# Creates a multiply-by-2 clockcreate_generated_clock -source [get_ports clk] -multiply_by 2 [get_registers \\ Quartus II Handbook, Volume 3 6-32 虚拟时钟Virtual Clocks虚拟时钟是一个在设计中没有真正源或者说与设计没有干脆关系的一个时钟例如,假如一个时钟不是设计中的时钟,而仅仅作为一个外部器件的时钟源,并且外部器件和该设计有输入或者输出的管脚,那么就认为这个时钟是虚拟时钟运用create_clock吩咐缔造一个虚拟时钟,对源选项没有指定值 你可以运用set_input_delay和set_output_delay约束虚拟时钟Figure 6–20展示了Quartus II TimeQuest Timing Analyzer假设要正确的分析外部存放器和内部设计逻辑之间的关系,在何处须要设置虚拟时钟的实例。
虽然名为virt_clk的晶振没有和Altera器件干脆相互作用,但是担当起了外部存放器的源时钟的角色,所以时钟virt_clk必需申明Example 6–6 展示了定义一个周期10ns,名为virt_clk,50%占空比,上升沿在0ns的虚拟时钟的吩咐虚拟时钟用于作为输出延时约束的时钟源 在你产生虚拟时钟之后,你可以执行register-to-register的分析报告〔在Altera器件和外部器件的存放器之间〕Example 6–6. 虚拟时钟Example 1 #create base clock for the designcreate_clock -period 5 [get_ports system_clk] #create the virtual clock for the external register create_clock -period 10 -name virt_clk -waveform { 0 5 } #set the output delay referencing the virtual clockset_output_delay -clock virt_clk -max 1.5 [get_ports dataout]Example 6–7 展示了产生一个周期为10ns,占空比为50%,相移90度虚拟时钟的吩咐。
Example 6–7. Virtual Clock Example 2create_clock -name virt_clk –period 10 –waveform { 2.5 7.5 }Quartus II Handbook, Volume 3 6-33 多频时钟 Multi-Frequency Clocks某些状况下在设计中会有许多个时钟源供应时钟信号增加的时钟或许扮演一个低频率低功耗时钟的角色在分析这种设计时,create_clock吩咐供应了–add选项让你添加多个时钟节点Example 6–8展示了时钟周期为10ns的节点clk,然后对同一个节点添加时钟周期为15ns的时钟Quartus II TimeQuest Timing Analyzer在执行时序分析时两个时钟都用到了Example 6–8. Multi-Frequency Examplecreate_clock –period 10 –name clock_primary –waveform { 0 5 } [get_ports clk] create_clock –period 15 –name clock_secondary –waveform { 0 7.5 } [get_ports clk] -add Quartus II Handbook, Volume 3 6-34 自动时钟检测 Automatic Clock Detection想要为你的设计中全部的时钟节点自动添加时钟约束,那么就运用derive_clocks吩咐。
这个吩咐从管脚或者存放器生成时钟以确保设计中的每个存放器都有时钟Example 6–9 展示了derive_clocks吩咐选项 Example 6–9. derive_clocks Command derive_clocks[-period ] [-waveform ]Table 6–8 describes the options for the derive_clocks command.选项 -period 描述 指定时钟周期,你也可以指定时钟频率如下:-period MHz -waveform 指定沿改变时刻 derive_clocks吩咐不能为PLLs输出时钟进展约束derive_clocks吩咐相当于运用create_clock吩咐为每个存放器或者管脚产生时钟Quartus II Handbook, Volume 3 6-35 锁相环时钟 Derive PLL ClocksPLLs〔锁相环〕在Altera器件中被用于时钟管理和综合你可以定制基于你设计须要的PLL输出时钟约束因为全部的时钟节点应当有一个共同的时钟基准,故全部的PLL输。





