System Generator CDC

12
Tri n khai các thi ết kế được điều khi n vi nhi u clock bng Xilinx System Generator I. Yêu cu phn mm - Matlab 2009b - Xilinx System Generator 12.1 - Hoc các phiên bản Matlab và Xilinx System Generator tương thích với nhau. Xem thêm tại đây : http://www.xilinx.com/support/answers/17966.htm Chú ý : Bài này dch li tSystem Generator User Guide, phần “Generating Multiple Cycle-True Islands for Distinct ClocksII. Clock Domain Partitiong Chia thiết kế multiple-clock thành nhiu min rt quan trng trong thiết kế FPGA. System Generator sdng các thiết kế tun tđể htrvic chia min clock. Khi 1 thiết kế sdng nhiu min clock, logic liên kết vi mi min clock sđược chia thành 1 nhóm trong Simulink subsystem. Những ưu điểm ca vic chia thiết kế thành các subsystems : - Đường clock vật lí được trừu tượng hóa thành sơ đồ khi. - Truyn Cross-Domain ddàng định nghĩa và có thể điều khin vi các khi meta-stable-safe ca Xilinx - Vì các miền được định nghĩa, SG có thể timing constraints cho các “synchronous islands”. Tng trừu tượng ca SG gim tlmà người dùng phm vào các li thiết kế. Như : - Gate Clocks: Vì các clocks ca SG suy ra tphn cng, nó không kết ni với đường không phi clock, clock inputs - Asynchronous Clears: vì các tín hiệu reset không đồng bđược suy ra tphn cng, nên không thskhông làm xóa đồng bkhi sdụng reset không đồng bộ, điều gây nên các vấn đề vtiming - Inferred Latches: Latches skhông to ra trong thiết kế SG. III. Crossing Clock Domains Các khi shared memory của SG được sdng khi cross clock domains. Các khối đó gồm : - Shared Memory - To FIFO, From FIFO

Transcript of System Generator CDC

Page 1: System Generator CDC

Triển khai các thiết kế được điều khiển với nhiều clock bằng Xilinx System Generator

I. Yêu cầu phần mềm

- Matlab 2009b

- Xilinx System Generator 12.1

- Hoặc các phiên bản Matlab và Xilinx System Generator tương thích với nhau. Xem thêm tại đây :

http://www.xilinx.com/support/answers/17966.htm

Chú ý : Bài này dịch lại từ System Generator User Guide, phần “Generating Multiple Cycle-True

Islands for Distinct Clocks”

II. Clock Domain Partitiong

Chia thiết kế multiple-clock thành nhiều miền rất quan trọng trong thiết kế FPGA. System Generator sử

dụng các thiết kế tuần tự để hỗ trợ việc chia miền clock. Khi 1 thiết kế sử dụng nhiều miền clock, logic

liên kết với mỗi miền clock sẽ được chia thành 1 nhóm trong Simulink subsystem.

Những ưu điểm của việc chia thiết kế thành các subsystems :

- Đường clock vật lí được trừu tượng hóa thành sơ đồ khối.

- Truyền Cross-Domain dễ dàng định nghĩa và có thể điều khiển với các khối meta-stable-safe của

Xilinx

- Vì các miền được định nghĩa, SG có thể timing constraints cho các “synchronous islands”.

Tầng trừu tượng của SG giảm tỉ lệ mà người dùng phạm vào các lỗi thiết kế. Như :

- Gate Clocks: Vì các clocks của SG suy ra từ phần cứng, nó không kết nối với đường không phải

clock, clock inputs

- Asynchronous Clears: vì các tín hiệu reset không đồng bộ được suy ra từ phần cứng, nên không

thể sẽ không làm xóa đồng bộ khi sử dụng reset không đồng bộ, điều gây nên các vấn đề về

timing

- Inferred Latches: Latches sẽ không tạo ra trong thiết kế SG.

III. Crossing Clock Domains

Các khối shared memory của SG được sử dụng khi cross clock domains. Các khối đó gồm :

- Shared Memory

- To FIFO, From FIFO

Page 2: System Generator CDC

- To Register, From Register

- FIFO: Sử dụng FIFO là cách dễ dàng nhất để cross domains và lựa chọn tốt nhất cho bằng tần

cao, truyền dữ liệu tuần tự.

- Shared Memory: Được sử dụng như là khối RAM dual-port. 2 khối được nối với nhau bằng tên.

Shared Memory được sử dụng cho những khối dữ liệu lớn được mapped qua nhiều BRAMs

- Register: 1 bit register dùng chung được synthesis thành 1 flop-flop

IV. Netlisting Multiple Clock Designs

- Mỗi miền clock nên có 1 subsystem trong thiết kế SG. Minh họa phía dưới

o Top

Page 3: System Generator CDC

Domain 1

Domain 2

- Sau khi các miền được netlist, SG

o Tạo HDL file cho Domain 0, gỏ FIFO, gọi netlister để tạo black-box netlist, file NGC

o Tạo HDL file cho Domain 1, gỏ FIFO, gọi netlister để tạo black-box netlist, file NGC

o Dùng Core Generator tạo core cho FIFO

o Tạo top-level để đưa các khối kết nối với nhau

V. Minh họa bằng ví dụ

1. Sử dụng đường dẫn : <sysgen_tree>/examples/multiple_clocks/

2. Bật file two_async_clks.mdl

Page 4: System Generator CDC

3. Mô phỏng

4. Bật Scope đểthấy được 2 miền clock khác nhau

Page 5: System Generator CDC

5. Mở 2 khối subsystem, thấy y hệt nhau.

6. Click vào 2 khối System Generator sẽ thấy thiết lập

Page 6: System Generator CDC

Miền A Miền B

FPGA Clock Period (ns) 10 15

Tần số 100 MHz 66,67 MHz

Simulink Period 2 3

7. Bật Multiple Subsystem Generator, click Generate.

8. Vào thư mục netlist sẽ thấy 2 file netlist của 2 miền ss_clk_domaina_cw.ngc và

ss_clk_domainb_cw.ngc

9. Bật file two_async_clks.vhd, chú dòng in đậm

Page 7: System Generator CDC

entity two_async_clks is

port (

din_a: in std_logic_vector(7 downto 0);

din_b: in std_logic_vector(7 downto 0);

ss_clk_domaina_cw_ce: in std_logic := '1';

ss_clk_domaina_cw_clk: in std_logic;

ss_clk_domainb_cw_ce: in std_logic := '1';

ss_clk_domainb_cw_clk: in std_logic;

dout_a: out std_logic_vector(7 downto 0);

dout_b: out std_logic_vector(7 downto 0)

);

end two_async_clks; Đó là 2 tín hiệu clock của 2 miền

Chú ý : System Generator không tạo mạch clocks. Chúng ta phải tự tạo file cấu hình clock và file

top module để ghép các khối với nhau

10. Tạo Top-Level Wrapper

- Tạo khối tạo clock ( như cấu hình DCM )

- Nối khối system Generator đến logic khác

- Tạo top-level port map nối tất cả với nhau

File ví dụ của hang :

----------------------------------------------------------------------

-------

-- top_wrapper.vhd

-- Example Top Level Wrapper

--

-- This is an example top-level wrapper for instantiating a System

Generator

-- design along with a DCM. In this example, the DCM connects the two

clock

-- inputs of the System Generator block ('two_async_clks') to two

buffered

-- outputs of the DCM, namely, CLK0 and CLKFX. CLK0 is the same

frequency

-- and phase as the input clock, and CLKFX is configured to be twice the

-- frequency of the input clock.

----------------------------------------------------------------------

---------

library IEEE;

library unisim;

use IEEE.std_logic_1164.all;

126 www.xilinx.com System Generator for DSP User Guide UG640 (v 12.1) April 19, 2010

Chapter 1: Hardware Design Using System Generator use unisim.vcomponents.all;

entity top_wrapper is

port (

clk : in std_logic;

din_a : in std_logic_vector(7 downto 0);

din_b : in std_logic_vector(7 downto 0);

dout_a : out std_logic_vector(7 downto 0);

dout_b : out std_logic_vector(7 downto 0)

);

end top_wrapper;

architecture structural of top_wrapper is

--------------------------------------

-- SysGen Model Component Declaration

--------------------------------------

component two_async_clks

Page 8: System Generator CDC

port (

din_a: in std_logic_vector(7 downto 0);

din_b: in std_logic_vector(7 downto 0);

ss_clk_domaina_cw_ce: in std_logic := '1';

ss_clk_domaina_cw_clk: in std_logic;

ss_clk_domainb_cw_ce: in std_logic := '1';

ss_clk_domainb_cw_clk: in std_logic;

dout_a: out std_logic_vector(7 downto 0);

dout_b: out std_logic_vector(7 downto 0)

);

end component;

component bufg

port(i: in std_logic;

o: out std_logic);

end component;

--------------------------------------

-- DCM Component Declaration

--------------------------------------

component dcm

-- synopsys translate_off

generic (clkout_phase_shift : string := "fixed";

dll_frequency_mode : string := "low";

duty_cycle_correction : boolean := true;

clkdv_divide : real := 3;

clkfx_multiply : integer := 2;

clkfx_divide : integer := 1);

-- synopsys translate_on

port (clkin : in std_logic;

clkfb : in std_logic;

dssen : in std_logic;

psincdec : in std_logic;

psen : in std_logic;

psclk : in std_logic;

rst : in std_logic;

clk0 : out std_logic;

clk90 : out std_logic;

clk180 : out std_logic;

clk270 : out std_logic;

clk2x : out std_logic;

clk2x180 : out std_logic;

clkdv : out std_logic;

clkfx : out std_logic;

clkfx180 : out std_logic;

System Generator for DSP User Guide www.xilinx.com 127 UG640 (v 12.1) April 19, 2010

Generating Multiple Cycle-True Islands for Distinct Clocks locked : out std_logic;

psdone : out std_logic;

status : out std_ulogic_vector(7 downto 0));

end component;

--------------------------------------

-- DCM Attributes

--------------------------------------

attribute dll_frequency_mode : string;

attribute duty_cycle_correction : string;

attribute startup_wait : string;

attribute clkdv_divide : string;

attribute clkfx_multiply : string;

attribute clkfx_divide : string;

attribute clkin_period : string;

attribute duty_cycle_correction of dcm0 : label is "true";

attribute startup_wait of dcm0 : label is "false";

attribute dll_frequency_mode of dcm0 : label is "low";

Page 9: System Generator CDC

attribute clkdv_divide of dcm0 : label is "3";

attribute clkfx_multiply of dcm0 : label is "2";

attribute clkfx_divide of dcm0 : label is "1";

attribute clkin_period of dcm0 : label is "10";

signal clk0unbuf : std_logic;

signal clk0buf : std_logic;

signal clkfxbuf : std_logic;

signal clk2xunbuf : std_logic;

signal clkfxunbuf : std_logic;

signal clkdvunbuf : std_logic;

signal clkdvbuf : std_logic;

signal ff1,ff2,ff3,ff4 : std_logic;

signal dcm_rst : std_logic;

signal intlock : std_logic;

----------------------------------------------------------------------

---------

-- The top level instantiates the SysGen design, a DCM, and two BUFGs.

-- The DCM generates two clocks of different frequencies.

-- These two clocks are used to drive the two different clock domains

-- in the SysGen block.

----------------------------------------------------------------------

---------

begin

dcm0: dcm

-- synopsys translate_off

generic map (dll_frequency_mode => frequency_mode,

clkdv_divide => clkdv_divide_generic,

clkfx_multiply => clkfx_multiply_generic,

clkfx_divide => clkfx_divide_generic)

-- synopsys translate_on

port map (clkin => clk,

clkfb => clk0buf,

dssen => '0',

psincdec => '0',

psen => '0',

psclk => '0',

rst => dcm_rst,

clk0 => clk0unbuf,

clk2x => clk2xunbuf,

clkfx => clkfxunbuf,

clkdv => clkdvunbuf,

locked => intlock);

bufg_clk0: bufg

port map (i => clk0unbuf,

o => clk0buf);

bufg_clkfx: bufg

port map (i => clkfxunbuf,

o => clkfxbuf);

--------------------------------------------------------------------

-- This is the DCM reset. It is a four-cycle shift register used to

-- hold the DCM in reset for a few cycles after programming.

--------------------------------------------------------------------

flop1: FDS port map (D => '0', C => clk, Q => ff1, S => '0');

flop2: FD port map (D => ff1, C => clk, Q => ff2);

flop3: FD port map (D => ff2, C => clk, Q => ff3);

flop4: FD port map (D => ff3, C => clk, Q => ff4);

dcm_rst <= ff2 or ff3 or ff4;

------------------------------------------------------------

-- SysGen Component Port Mapping

-- One clock input is being connected to clk0 of the DCM,

-- and the other clock is being connected to clkfx.

------------------------------------------------------------

two_async_clks: two_async_clks

Page 10: System Generator CDC

port map (

din_a => din_a,

din_b => din_b,

ss_clk_domaina_cw_ce => '1',

ss_clk_domaina_cw_clk => clk0buf,

ss_clk_domainb_cw_ce => '1',

ss_clk_domainb_cw_clk => clkfxbuf,

dout_b => dout_b);

end structural;

VI. Nói thêm về Xilinx FPGA Clock Resource và cách cấu hình ( Spartan-6)

1. Clock Management Tiles ( CMTs) Mỗi 1 CMT bao gồm 2 DCM và 1 PLL

- Phase Lock Loop ( PLL )

Page 11: System Generator CDC

- Digital Clock Managers

( Phần này mình chưa hiểu nên không viết thêm được )

Page 12: System Generator CDC

2. Cấu hình Clock - Mỗi 1 dòng chip FPGA luôn có các CMT khác nhau. Vì thế phải đọc Clocking Resource và

Application Notes liên quan để xem cách cấu hình.

- Công cụ cấu hình : Core Generator -> Clocking Wizard

VII. Tài liệu tham khảo :

1. System Generator User Guide

2. http://svenand.blogdrive.com/archive/149.html