wrapper.vhd


1
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    00:52:54 06/14/2009 
6
-- Design Name: 
7
-- Module Name:    wrapper - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
library UNISIM;
28
use UNISIM.VComponents.all;
29
30
entity wrapper is
31
    Port ( CLK     : in   STD_LOGIC;
32
           CLK35     : in   STD_LOGIC;
33
           CLK35N   : in   STD_LOGIC;
34
        RST      : in   STD_LOGIC;  
35
           DataIn   : in   STD_LOGIC_VECTOR (20 downto 0);
36
           TxOUT    : out  STD_LOGIC_VECTOR (2 downto 0);
37
           TxCLK    : out  STD_LOGIC);
38
end wrapper;
39
40
architecture Behavioral of wrapper is
41
Signal RST_Int                : STD_LOGIC:='1';
42
Signal CLK_Edge1, Stop          : STD_LOGIC:='1';
43
Signal Data1, Data2            : STD_LOGIC_VECTOR(20 downto 0);
44
45
Signal ShiftClkp, ShiftClkn      : STD_LOGIC_VECTOR( 6 downto 0);
46
Signal Shift0p, Shift0n          : STD_LOGIC_VECTOR( 6 downto 0);
47
Signal Shift0p_load, Shift0n_load  : STD_LOGIC_VECTOR( 6 downto 0);
48
Signal Shift1p, Shift1n          : STD_LOGIC_VECTOR( 6 downto 0);
49
Signal Shift1p_load, Shift1n_load  : STD_LOGIC_VECTOR( 6 downto 0);
50
Signal Shift2p, Shift2n          : STD_LOGIC_VECTOR( 6 downto 0);
51
Signal Shift2p_load, Shift2n_load  : STD_LOGIC_VECTOR( 6 downto 0);
52
Signal Shift_Count_P, Shift_Count_N  : integer range 0 to 6:=6;
53
54
Signal DataTxCLK              : STD_LOGIC_VECTOR( 1 downto 0):=(others=>'0');  -- Signal vom Wrapper zum DDR-FF für den Takt
55
Signal DataTxOUT              : STD_LOGIC_VECTOR( 5 downto 0):=(others=>'0');  -- Signal vom Wrapper zum DDR-FF für die Daten
56
57
  COMPONENT FDDRCPE
58
   port (Q           : out STD_ULOGIC;
59
         C0         : in STD_ULOGIC;
60
         C1         : in STD_ULOGIC;
61
         CE         : in STD_ULOGIC;
62
         CLR         : in STD_ULOGIC;
63
         D0         : in STD_ULOGIC;
64
         D1         : in STD_ULOGIC;
65
         PRE         : in STD_ULOGIC);
66
  END COMPONENT;
67
68
begin
69
70
-- Synchrones Reset(Start)-Signal
71
process(CLK35)
72
begin
73
if rising_edge(CLK35) then
74
  CLK_Edge1    <= CLK;
75
  if RST = '1' then
76
    Stop      <= '1';
77
    RST_Int    <= '1';
78
  else
79
    if Stop = '1' then
80
     -- Damit der Start nach der Low=>High Flanke des CLK-Taktes anfängt.
81
    -- Die Takte sind per DCM synchron, deshalb sollte es keine Metazustände 
82
    -- durch die Takte geben, weil erst nach der steigenden Flanke von CLK abgefragt wird
83
    -- In 2 Normalen Takten sind 7 schnellere die alle 2Takte zum gleichen Zeitpunkt die 
84
    -- steigende Flanke haben.
85
      if CLK_Edge1 = '0' and CLK = '1' and RST = '0' then
86
        RST_Int    <= '0';
87
      Stop      <= '0';
88
      else
89
        RST_Int    <= '1';
90
      end if;
91
   end if;
92
  end if;
93
end if;
94
end process;
95
96
97
-- Datenzwischenspeicher, alle 2Takte werden die Daten in die 
98
-- Schieberegister geladen.
99
process(CLK, RST)
100
begin
101
if RST = '1' then
102
  Data1    <= "000000000000000000000";
103
  Data2    <= "000000000000000000000";
104
elsif rising_edge(CLK) then
105
  Data1    <= DataIn;
106
  Data2    <= Data1;
107
end if;
108
end process;
109
110
111
-- Zusammenstellung der Daten für die Schieberegister
112
-- Kanal 0
113
Shift0p_load  <= Data2( 5) & Data2( 3) & Data2( 1) & Data1( 6) & Data1( 4) & Data1( 2) & Data1( 0);
114
Shift0n_load   <= Data2( 6) & Data2( 4) & Data2( 2) & Data2( 0) & Data1( 5) & Data1( 3) & Data1( 1);
115
-- Kanal 1
116
Shift1p_load  <= Data2(12) & Data2(10) & Data2( 8) & Data1(13) & Data1(11) & Data1( 9) & Data1( 7);
117
Shift1n_load   <= Data2(13) & Data2(11) & Data2( 9) & Data2( 7) & Data1(12) & Data1(10) & Data1( 8);
118
-- Kanal 2
119
Shift2p_load  <= Data2(19) & Data2(17) & Data2(15) & Data1(20) & Data1(18) & Data1(16) & Data1(14);
120
Shift2n_load   <= Data2(20) & Data2(18) & Data2(16) & Data2(14) & Data1(19) & Data1(17) & Data1(15);
121
122
123
-- Schieberegister für normalen 3,5-fachen Takt
124
-- Das Signal auf dem normalen Takt wird als zweites ausgegeben
125
process(CLK35)
126
begin
127
if rising_edge(CLK35) then
128
  if RST_Int = '1' then
129
    Shift_Count_P    <= 6;
130
   ShiftClkp      <= "0000000";
131
   Shift0p        <= "0000000";
132
   Shift1p        <= "0000000";
133
   Shift2p        <= "0000000";
134
  else
135
    if Shift_Count_P = 6 then
136
      Shift_Count_P   <= 0;
137
     ShiftClkp    <= "1011001";
138
     Shift0p      <= Shift0p_load;
139
     Shift1p      <= Shift1p_load;
140
     Shift2p      <= Shift2p_load;
141
    else
142
      Shift_Count_P   <= Shift_Count_P + 1;
143
    ShiftClkp    <= ShiftClkp(5 downto 0) & '0';
144
      Shift0p      <= Shift0p(5 downto 0) & '0';
145
      Shift1p      <= Shift1p(5 downto 0) & '0';
146
      Shift2p      <= Shift2p(5 downto 0) & '0';
147
    end if;
148
  end if;
149
end if;
150
end process;
151
-- Datenzuweisung zu den DDR-Zellen
152
DataTxCLK(1)      <= ShiftClkp(6);
153
DataTxOUT(3)      <= Shift0p(6);
154
DataTxOUT(4)      <= Shift1p(6);
155
DataTxOUT(5)      <= Shift2p(6);
156
157
158
-- Schieberegister für negierten 3,5-fachen Takt
159
-- Das Signal auf dem negiertem Takt wird als erstes ausgegeben
160
process(CLK35N)
161
begin
162
if rising_edge(CLK35N) then
163
  if RST_Int = '1' then
164
    Shift_Count_N    <= 6;
165
   ShiftClkn      <= "0000000";
166
   Shift0n        <= "0000000";
167
   Shift1n        <= "0000000";
168
   Shift2n        <= "0000000";
169
  else
170
    if Shift_Count_N = 6 then
171
      Shift_Count_N   <= 0;
172
     ShiftClkn    <= "1001101";
173
     Shift0n      <= Shift0n_load;
174
     Shift1n      <= Shift1n_load;
175
     Shift2n      <= Shift2n_load;
176
    else
177
      Shift_Count_N   <= Shift_Count_N + 1;
178
    ShiftClkn    <= ShiftClkn(5 downto 0) & '0';
179
      Shift0n      <= Shift0n(5 downto 0) & '0';
180
      Shift1n      <= Shift1n(5 downto 0) & '0';
181
      Shift2n      <= Shift2n(5 downto 0) & '0';
182
    end if;
183
  end if;
184
end if;
185
end process;
186
-- Datenzuweisung zu den DDR-Zellen
187
DataTxCLK(0)      <= ShiftClkn(6);
188
DataTxOUT(0)      <= Shift0n(6);
189
DataTxOUT(1)      <= Shift1n(6);
190
DataTxOUT(2)      <= Shift2n(6);
191
192
193
-- DDR Zelle TxCLK
194
   FDDRCPE_TxOUT : FDDRCPE
195
   port map (
196
      Q    => TxCLK,        -- Data output (connect directly to top-level port)
197
      C0    => CLK35,        -- 0 degree clock input
198
      C1    => CLK35N,        -- 180 degree clock input
199
      CE    => '1',          -- Clock enable input
200
      D0    => DataTxCLK(1),  -- Posedge data input
201
      D1    => DataTxCLK(0),  -- Negedge data input
202
      CLR  => '0',         -- Synchronous reset input
203
      PRE  => '0'           -- Synchronous preset input
204
   );
205
206
-- DDR Zelle TxOUT(i)
207
loop0 : for i in 0 to 2 generate 
208
   FDDRCPE_TxOUT : FDDRCPE
209
   port map (
210
      Q    => TxOUT(i),      -- Data output (connect directly to top-level port)
211
      C0    => CLK35,        -- 0 degree clock input
212
      C1    => CLK35N,        -- 180 degree clock input
213
      CE    => '1',          -- Clock enable input
214
      D0    => DataTxOUT(i+3),-- Posedge data input
215
      D1    => DataTxOUT(i),  -- Negedge data input
216
      CLR  => '0',         -- Synchronous reset input
217
      PRE  => '0'           -- Synchronous preset input
218
   );
219
end generate ;
220
221
end Behavioral;