loki3118
Junior Member level 2
- Joined
- Jun 26, 2013
- Messages
- 23
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 238
Hello Mr. Flibble,
I've spent a good deal of time this weekend trying to figure out how to implement the ODDR2 clock nets. I have several questions that arose from your previous comments.
So to the best of my knowledge you described a system that uses 4 ODDR2 to forward clk_0, clk_90, clk_180, and clk_270. After reading the documentation on the Xilinx Clocking Wizard to one instance of the ODDR2. It appears that to avoid introducing any duty-cycle distortion I should implement a 180 phase shifted signal. You mentioned to employ two clk_0 signals and two clk_90 signals. These signals will be feed into C0, however what will C1 be?
In addition What DDR flip-flop selection would you recommend. I have reviewed all of the different selections however, I do not have enough experience to make the proper decision let alone know if it really matters.
OFDDRRSE
A DDR output D register with synchronous reset (CE), set (S), clock enable (CE), and one output buffer.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
entity Counter4 is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
DIRECTION0 : in STD_LOGIC;
DIRECTION90 : in STD_LOGIC;
DIRECTION180 : in STD_LOGIC;
DIRECTION270 : in STD_LOGIC;
COUNT_OUT0 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT90 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT180 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT270 : out STD_LOGIC_VECTOR (3 downto 0));
end Counter4;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
architecture Behavioral of Counter4 is
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
COMPONENT DCM4
PORT(
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK90_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
CLK270_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
COMPONENT ODDR2_0
PORT(
CE_IN : IN std_logic;
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
R_IN : IN std_logic;
S_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
DDR_CLK0_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
COMPONENT ODDR2_90
PORT(
CE_IN : IN std_logic;
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
R_IN : IN std_logic;
S_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
DDR_CLK0_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
COMPONENT ODDR2_180
PORT(
CE_IN : IN std_logic;
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
R_IN : IN std_logic;
S_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
DDR_CLK0_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
COMPONENT ODDR2_270
PORT(
CE_IN : IN std_logic;
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
R_IN : IN std_logic;
S_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
DDR_CLK0_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
signal count_int0 : std_logic_vector(3 downto 0) := "0001";
signal count_int90 : std_logic_vector(3 downto 0) := "0001";
signal count_int180 : std_logic_vector(3 downto 0) := "0000";
signal count_int270 : std_logic_vector(3 downto 0) := "0000";
signal locked : std_logic;
signal clk0 : std_logic; -- stores clock from DCM
signal clk90 : std_logic; -- stores clock from DCM
signal clk180 : std_logic; -- stores clock from DCM
signal clk270 : std_logic; -- stores clock from DCM
signal ODDR2_clk0 : std_logic; -- used to output the clock signal?
signal ODDR2_clk90 : std_logic; -- used to output the clock signal?
signal ODDR2_clk180 : std_logic; -- used to output the clock signal?
signal ODDR2_clk270 : std_logic; -- used to output the clock signal?
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
begin
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Inst_DCM4: DCM4 PORT MAP(
CLKIN_IN => clk,
RST_IN => reset,
CLKIN_IBUFG_OUT => open,
CLK0_OUT => clk0,
CLK2X_OUT => open,
CLK90_OUT => clk90,
CLK180_OUT => clk180,
CLK270_OUT => clk270,
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
Inst_ODDR2_0: ODDR2_0 PORT MAP(
[B][U]CE_IN => ,[/U][/B]
CLKIN_IN => clk0,
RST_IN => reset,
R_IN => 0, -- unsure if this is correct
S_IN => 0, -- unsure if this is correct
CLKIN_IBUFG_OUT => open,
CLK0_OUT => ODDR2_clk0, -- stores the clock to be forward?
[B][U]CLK2X_OUT => ,[/U][/B]
[B][U]CLK180_OUT => ,[/U][/B]
[B][U]DDR_CLK0_OUT => ,[/U][/B]
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
Inst_ODDR2_90: ODDR2_90 PORT MAP(
[B][U]CE_IN => ,[/U][/B]
CLKIN_IN => clk90,
RST_IN => reset,
R_IN => 0, -- unsure if this is correct
S_IN => 0, -- unsure if this is correct
CLKIN_IBUFG_OUT => open,
CLK0_OUT => ODDR2_clk90, -- stores the clock to be forward?
[B][U]CLK2X_OUT => ,[/U][/B]
[B][U]CLK180_OUT => ,[/U][/B]
[B][U]DDR_CLK0_OUT => ,[/U][/B]
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
Inst_ODDR2_180: ODDR2_180 PORT MAP(
[B][U]CE_IN => ,[/U][/B]
CLKIN_IN => clk180,
RST_IN => reset,
R_IN => 0, -- unsure if this is correct
S_IN => 0, -- unsure if this is correct
CLKIN_IBUFG_OUT => open,
CLK0_OUT => ODDR2_clk180, -- stores the clock to be forward?
[B][U]CLK2X_OUT => ,[/U][/B]
[B][U]CLK180_OUT => ,[/U][/B]
[B][U]DDR_CLK0_OUT => ,[/U][/B]
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
Inst_ODDR2_270: ODDR2_270 PORT MAP(
[B][U]CE_IN => ,[/U][/B]
CLKIN_IN => clk270,
RST_IN => reset,
R_IN => 0, -- unsure if this is correct
S_IN => 0, -- unsure if this is correct
CLKIN_IBUFG_OUT => open,
CLK0_OUT => ODDR2_clk270, -- stores the clock to be forward?
[B][U]CLK2X_OUT => ,[/U][/B]
[B][U]CLK180_OUT => ,[/U][/B]
[B][U]DDR_CLK0_OUT => ,[/U][/B]
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk0)
begin
if clk0='1' and clk0'event then
if DIRECTION0='1' then
count_int0 <= count_int0 - 1;
else
count_int0 <= count_int0 + 1;
end if;
end if;
end process;
COUNT_OUT0 <= count_int0;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk90)
begin
if clk90='1' and clk90'event then
if DIRECTION90='1' then
count_int90 <= count_int90 - 1;
else
count_int90 <= count_int90 + 1;
end if;
end if;
end process;
COUNT_OUT90 <= count_int90;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk180)
begin
if clk180='1' and clk180'event then
if DIRECTION180='1' then
count_int180 <= count_int180 - 1;
else
count_int180 <= count_int180 + 1;
end if;
end if;
end process;
COUNT_OUT180 <= count_int180;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk270)
begin
if clk270='1' and clk270'event then
if DIRECTION270='1' then
count_int270 <= count_int270 - 1;
else
count_int270 <= count_int270 + 1;
end if;
end if;
end process;
COUNT_OUT270 <= count_int270;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
end Behavioral;
RTFM said:VHDL Instantiation Template
Unless they already exist, copy the following two statements and paste them before the entity declaration.
Library UNISIM;
use UNISIM.vcomponents.all;
-- ODDR2: Output Double Data Rate Output Register with Set, Reset
-- and Clock Enable.
-- Spartan-3E
-- Xilinx HDL Libraries Guide, version 13.1
ODDR2_inst : ODDR2
generic map(
DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1"
INIT => ’0’, -- Sets initial state of the Q output to ’0’ or ’1’
SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
port map (
Q => Q, -- 1-bit output data
C0 => C0, -- 1-bit clock input
C1 => C1, -- 1-bit clock input
CE => CE, -- 1-bit clock enable input
D0 => D0, -- 1-bit data input (associated with C0)
D1 => D1, -- 1-bit data input (associated with C1)
R => R, -- 1-bit reset input
S => S -- 1-bit set input
);
-- End of ODDR2_inst instantiation
-- VHDL Instantiation Created from source file ODDR2_0.vhd -- 17:23:28 07/11/2013
--
-- Notes:
-- 1) This instantiation template has been automatically generated using types
-- std_logic and std_logic_vector for the ports of the instantiated module
-- 2) To use this template to instantiate this entity, cut-and-paste and then edit
COMPONENT ODDR2_0
PORT(
CE_IN : IN std_logic;
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
R_IN : IN std_logic;
S_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
DDR_CLK0_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
Inst_ODDR2_0: ODDR2_0 PORT MAP(
CE_IN => ,
CLKIN_IN => ,
RST_IN => ,
R_IN => ,
S_IN => ,
CLKIN_IBUFG_OUT => ,
CLK0_OUT => ,
CLK2X_OUT => ,
CLK180_OUT => ,
DDR_CLK0_OUT => ,
LOCKED_OUT =>
);
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Library UNISIM;
use UNISIM.vcomponents.all;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
entity Counter4 is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
DIRECTION0 : in STD_LOGIC;
DIRECTION90 : in STD_LOGIC;
DIRECTION180 : in STD_LOGIC;
DIRECTION270 : in STD_LOGIC;
COUNT_OUT0 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT90 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT180 : out STD_LOGIC_VECTOR (3 downto 0);
COUNT_OUT270 : out STD_LOGIC_VECTOR (3 downto 0));
end Counter4;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
architecture Behavioral of Counter4 is
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
COMPONENT DCM
PORT(
CLKIN_IN : IN std_logic;
RST_IN : IN std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic;
CLK2X_OUT : OUT std_logic;
CLK90_OUT : OUT std_logic;
CLK180_OUT : OUT std_logic;
CLK270_OUT : OUT std_logic;
LOCKED_OUT : OUT std_logic
);
END COMPONENT;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
signal count_int0 : std_logic_vector(3 downto 0) := "0001";
signal count_int90 : std_logic_vector(3 downto 0) := "0001";
signal count_int180 : std_logic_vector(3 downto 0) := "0000";
signal count_int270 : std_logic_vector(3 downto 0) := "0000";
signal locked : std_logic;
signal clk0 : std_logic;
signal clk90 : std_logic;
signal clk180 : std_logic;
signal clk270 : std_logic;
signal clk0_out : std_logic;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
begin
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Inst_DCM: DCM PORT MAP(
CLKIN_IN => clk,
RST_IN => reset,
CLKIN_IBUFG_OUT => open,
CLK0_OUT => clk0,
CLK2X_OUT => open,
CLK90_OUT => clk90,
CLK180_OUT => clk180,
CLK270_OUT => clk270,
LOCKED_OUT => locked
);
----------------------------------------------------------------------------------
ODDR2_inst : ODDR2
generic map(
DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1"
INIT => '0', -- Sets initial state of the Q output to '0' or '1'
SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
port map (
Q => clk0_out, -- 1-bit output data
C0 => clk0, -- 1-bit clock input
C1 => clk180, -- 1-bit clock input
CE => 1, -- 1-bit clock enable input
D0 => 1, -- 1-bit data input (associated with C0)
D1 => 1, -- 1-bit data input (associated with C1)
R => reset, -- 1-bit reset input
S => 1 -- 1-bit set input
);
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk0)
begin
if clk0='1' and clk0'event then
if DIRECTION0='1' then
count_int0 <= count_int0 - 1;
else
count_int0 <= count_int0 + 1;
end if;
end if;
end process;
COUNT_OUT0 <= count_int0;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk90)
begin
if clk90='1' and clk90'event then
if DIRECTION90='1' then
count_int90 <= count_int90 - 1;
else
count_int90 <= count_int90 + 1;
end if;
end if;
end process;
COUNT_OUT90 <= count_int90;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk180)
begin
if clk180='1' and clk180'event then
if DIRECTION180='1' then
count_int180 <= count_int180 - 1;
else
count_int180 <= count_int180 + 1;
end if;
end if;
end process;
COUNT_OUT180 <= count_int180;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
process (clk270)
begin
if clk270='1' and clk270'event then
if DIRECTION270='1' then
count_int270 <= count_int270 - 1;
else
count_int270 <= count_int270 + 1;
end if;
end if;
end process;
COUNT_OUT270 <= count_int270;
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
end Behavioral;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?