vivado XMP使用
文章目錄
- vivado XMP使用
- 前言
- 一、xpm_cdc_async_rst
- 二、XPM_CDC_ARRAY_SINGLE
- 三、XPM_CDC_PULSE
- 四、 XPM_CDC_SINGLE
- 五、 xpm_cdc_sync_rst
- 總結
前言
使用XMP做跨時鐘域,方便的是官方認證,好用且不會爆時序問題,懶得寫 set flase。
這里不給時序了,參數和使用方法都比較簡單,看手冊即可
鏈接如下:
UG974
一、xpm_cdc_async_rst
xpm_cdc_async_rst #(.DEST_SYNC_FF(4), // DECIMAL; range: 2-10.INIT_SYNC_FF(0), // DECIMAL; 0=disable simulation init values, 1=enable simulation init values.RST_ACTIVE_HIGH(0) // DECIMAL; 0=active low reset, 1=active high reset)xpm_cdc_async_rst_inst (.dest_arst(dest_arst), // 1-bit output: src_arst asynchronous reset signal synchronized to destination// clock domain. This output is registered. NOTE: Signal asserts asynchronously// but deasserts synchronously to dest_clk. Width of the reset signal is at least// (DEST_SYNC_FF*dest_clk) period..dest_clk(dest_clk), // 1-bit input: Destination clock..src_arst(src_arst) // 1-bit input: Source asynchronous reset signal.);
此宏將異步復位信號同步到目標時鐘域。生成的復位輸出將保證相對于輸入異步斷言,但輸出的斷言始終與目標時鐘域同步。您可以定義復位信號的極性和宏斷言時的最小輸出脈沖寬度。后者通過定義同步器中使用的寄存器級數來控制。注意:最小輸入脈沖斷言取決于寄存器復位或置位引腳的建立時間和保持時間要求。
- 和同步復位跨時鐘域的區別在于斷言,異步的是跨時鐘之后的復位還是異步斷言,但是取消斷言是和目標時鐘是同步的
- 要保證復位的長度能夠足夠被目標時鐘域采集到,也就是說快采集慢的時鐘,復位信號長度一定是兩倍以上。否則有問題
二、XPM_CDC_ARRAY_SINGLE
xpm_cdc_array_single #(.DEST_SYNC_FF(4), // DECIMAL; range: 2-10.INIT_SYNC_FF(0), // DECIMAL; 0=disable simulation init values, 1=enable simulation init values.SIM_ASSERT_CHK(0), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages.SRC_INPUT_REG(1), // DECIMAL; 0=do not register input, 1=register input.WIDTH(2) // DECIMAL; range: 1-1024)xpm_cdc_array_single_inst (.dest_out(dest_out), // WIDTH-bit output: src_in synchronized to the destination clock domain. This// output is registered..dest_clk(dest_clk), // 1-bit input: Clock signal for the destination clock domain..src_clk(src_clk), // 1-bit input: optional; required when SRC_INPUT_REG = 1.src_in(src_in) // WIDTH-bit input: Input single-bit array to be synchronized to destination clock// domain. It is assumed that each bit of the array is unrelated to the others. This// is reflected in the constraints applied to this macro. To transfer a binary value// losslessly across the two clock domains, use the XPM_CDC_GRAY macro instead.);
此宏從源時鐘域合成一個單比特信號數組到目標時鐘域。為了正常工作,輸入數據必須被目標時鐘采樣兩次或更多次。您可以定義同步器中使用的寄存器級數。可選的輸入寄存器可以在輸入在源時鐘域中同步之前對其進行注冊。您還可以啟用仿真功能以生成消息報告宏的任何潛在誤用。注意:此宏假定源數組的每一位都是獨立的,沒有需要保留的關系。
- 自己嘗試過不相關數據合并,其中一個數據只保持一個原時鐘域的脈沖,這樣可能會同步不到目標時鐘域
- 需要保證被目標時鐘域采樣兩次或者更多
使用場景:跨時鐘域之后,每一個單bit不再變化,類似于對于跨時鐘域的配置數據。
三、XPM_CDC_PULSE
xpm_cdc_pulse #(.DEST_SYNC_FF(4), // DECIMAL; range: 2-10.INIT_SYNC_FF(0), // DECIMAL; 0=disable simulation init values, 1=enable simulation init values.REG_OUTPUT(0), // DECIMAL; 0=disable registered output, 1=enable registered output.RST_USED(1), // DECIMAL; 0=no reset, 1=implement reset.SIM_ASSERT_CHK(0) // DECIMAL; 0=disable simulation messages, 1=enable simulation messages)xpm_cdc_pulse_inst (.dest_pulse(dest_pulse), // 1-bit output: Outputs a pulse the size of one dest_clk period when a pulse// transfer is correctly initiated on src_pulse input. This output is// combinatorial unless REG_OUTPUT is set to 1..dest_clk(dest_clk), // 1-bit input: Destination clock..dest_rst(dest_rst), // 1-bit input: optional; required when RST_USED = 1.src_clk(src_clk), // 1-bit input: Source clock..src_pulse(src_pulse), // 1-bit input: Rising edge of this signal initiates a pulse transfer to the// destination clock domain. The minimum gap between each pulse transfer must be// at the minimum 2*(larger(src_clk period, dest_clk period)). This is measured// between the falling edge of a src_pulse to the rising edge of the next// src_pulse. This minimum gap will guarantee that each rising edge of src_pulse// will generate a pulse the size of one dest_clk period in the destination// clock domain. When RST_USED = 1, pulse transfers will not be guaranteed while// src_rst and/or dest_rst are asserted..src_rst(src_rst) // 1-bit input: optional; required when RST_USED = 1);
此宏將源時鐘域中的脈沖同步到目標時鐘域。源時鐘域中任意大小的脈沖,如果正確啟動,將生成一個與單個目標時鐘周期相同大小的脈沖。為了正常工作,輸入數據必須被目標時鐘采樣兩次或更多次。您可以定義同步器中使用的寄存器級數。可選的源和目標復位可用于重置脈沖傳輸邏輯。您還可以啟用仿真功能,生成報告宏可能被濫用的消息。此宏的實現需要一些反饋邏輯。在沒有可選復位信號的情況下模擬宏時,輸入脈沖信號(src_pulse)必須始終定義,因為沒有復位邏輯可以從宏中傳播的未定義或‘x’恢復。
最小間隔是測量src_pulse的下降沿到下一個src_pulse的上升沿之間的距離。這個最小間隔將保證每個src_pulse的上升沿將在目標時鐘域生成一個dest_clk周期大小的脈沖。
- 脈沖之間是有一定間隔才能正常工作
- 保證被目標時鐘域采樣兩次(猜測里面是使用脈沖展寬,因為我沒有小于兩次也生成了目標時鐘域的脈沖,還是聽官方的吧,這樣才能靠譜的正常工作)
四、 XPM_CDC_SINGLE
xpm_cdc_single #(.DEST_SYNC_FF(4), // DECIMAL; range: 2-10.INIT_SYNC_FF(0), // DECIMAL; 0=disable simulation init values, 1=enable simulation init values.SIM_ASSERT_CHK(0), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages.SRC_INPUT_REG(1) // DECIMAL; 0=do not register input, 1=register input)xpm_cdc_single_inst (.dest_out(dest_out), // 1-bit output: src_in synchronized to the destination clock domain. This output is// registered..dest_clk(dest_clk), // 1-bit input: Clock signal for the destination clock domain..src_clk(src_clk), // 1-bit input: optional; required when SRC_INPUT_REG = 1.src_in(src_in) // 1-bit input: Input signal to be synchronized to dest_clk domain.);
此宏將一個比特信號從源時鐘域同步到目標時鐘域。為了正常工作,輸入數據必須被目標時鐘采樣兩次或更多次。您可以定義同步器中使用的寄存器級數。可選的輸入寄存器可用于在同步之前對源時鐘域中的輸入進行寄存。
- 電平信號一般也能被采樣兩次,只要滿足都可以使用這個來做跨時鐘
五、 xpm_cdc_sync_rst
xpm_cdc_sync_rst #(.DEST_SYNC_FF(4), // DECIMAL; range: 2-10.INIT(1), // DECIMAL; 0=initialize synchronization registers to 0, 1=initialize synchronization// registers to 1.INIT_SYNC_FF(0), // DECIMAL; 0=disable simulation init values, 1=enable simulation init values.SIM_ASSERT_CHK(0) // DECIMAL; 0=disable simulation messages, 1=enable simulation messages)xpm_cdc_sync_rst_inst (.dest_rst(dest_rst), // 1-bit output: src_rst synchronized to the destination clock domain. This output// is registered..dest_clk(dest_clk), // 1-bit input: Destination clock..src_rst(src_rst) // 1-bit input: Source reset signal.);
此宏將復位信號同步到目標時鐘域。與XPM_CDC_ASYNC_RST宏不同,生成的輸出將在目標時鐘域中同步斷言和解除斷言。為了正常工作,輸入數據必須被目標時鐘采樣兩次或更多次。您可以定義同步器中使用的寄存器級數以及配置后的初始寄存器值。您還可以啟用仿真功能,以生成報告宏可能被誤用的消息。
總結
對于上面所有的xpm,都是輸入數據必須被目標時鐘采樣兩次或更多次,也就是快到慢的跨時鐘,最好就要時鐘單獨的脈沖展寬或者握手信號,或者是做fifo或者ram緩沖等手段來做跨時鐘。