OpenCores
URL https://opencores.org/ocsvn/sdram_controller/sdram_controller/trunk

Subversion Repositories sdram_controller

[/] [sdram_controller/] [trunk/] [sdram_support.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lynn0p
----------------------------------------------------------------------------------
2
-- Company: OPL Aerospatiale AG
3
-- Engineer: Owen Lynn <lynn0p@hotmail.com>
4
-- 
5
-- Create Date:    15:35:09 08/18/2009 
6
-- Design Name: 
7
-- Module Name:    sdram_support - impl 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: This contains all the dirty primitives used by all the other modules.
12
--  Anything that's small and would be considered plumbing goes in here.
13
--
14
-- Dependencies: Xilinx primitives
15
--
16
-- Revision: 
17
-- Revision 0.01 - File Created
18
-- Additional Comments: 
19
--  Copyright (c) 2009 Owen Lynn <lynn0p@hotmail.com>
20
--  Released under the GNU Lesser General Public License, Version 3
21
--
22
----------------------------------------------------------------------------------
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
use IEEE.STD_LOGIC_ARITH.ALL;
26
use IEEE.STD_LOGIC_UNSIGNED.ALL;
27
 
28
---- Uncomment the following library declaration if instantiating
29
---- any Xilinx primitives in this code.
30
--library UNISIM;
31
--use UNISIM.VComponents.all;
32
 
33
entity cmd_bank_addr_switch is
34
        port(
35
                sel      : in std_logic;
36
                cmd0_in  : in std_logic_vector(2 downto 0);
37
                bank0_in : in std_logic_vector(1 downto 0);
38
                addr0_in : in std_logic_vector(12 downto 0);
39
                cmd1_in  : in std_logic_vector(2 downto 0);
40
                bank1_in : in std_logic_vector(1 downto 0);
41
                addr1_in : in std_logic_vector(12 downto 0);
42
                cmd_out  : out std_logic_vector(2 downto 0);
43
                bank_out : out std_logic_vector(1 downto 0);
44
                addr_out : out std_logic_vector(12 downto 0)
45
        );
46
end cmd_bank_addr_switch;
47
 
48
architecture impl of cmd_bank_addr_switch is
49
begin
50
 
51
        cmd_out  <= cmd0_in  when sel = '0' else cmd1_in;
52
        bank_out <= bank0_in when sel = '0' else bank1_in;
53
        addr_out <= addr0_in when sel = '0' else addr1_in;
54
 
55
end impl;
56
 
57
 
58
library IEEE;
59
use IEEE.STD_LOGIC_1164.ALL;
60
use IEEE.STD_LOGIC_ARITH.ALL;
61
use IEEE.STD_LOGIC_UNSIGNED.ALL;
62
 
63
---- Uncomment the following library declaration if instantiating
64
---- any Xilinx primitives in this code.
65
library UNISIM;
66
use UNISIM.VComponents.all;
67
 
68
entity wait_counter is
69
        generic(
70
                BITS : integer;
71
                CLKS : integer
72
        );
73
        port(
74
            clk : in std_logic;
75
                 rst : in std_logic;
76
                done : out std_logic
77
        );
78
end wait_counter;
79
 
80
architecture impl of wait_counter is
81
 
82
        signal reg : std_logic_vector(BITS-1 downto 0);
83
 
84
begin
85
 
86
        process(clk,rst)
87
        begin
88
                if (rst = '1') then
89
                        done <= '0';
90
                        reg <= CONV_STD_LOGIC_VECTOR(CLKS, BITS);
91
                elsif (rising_edge(clk)) then
92
                        if (reg > x"00") then
93
                                done <= '0';
94
                                reg <= reg - 1;
95
                        else
96
                                done <= '1';
97
                        end if;
98
                end if;
99
        end process;
100
 
101
end architecture;
102
 
103
 
104
library IEEE;
105
use IEEE.STD_LOGIC_1164.ALL;
106
use IEEE.STD_LOGIC_ARITH.ALL;
107
use IEEE.STD_LOGIC_UNSIGNED.ALL;
108
 
109
---- Uncomment the following library declaration if instantiating
110
---- any Xilinx primitives in this code.
111
library UNISIM;
112
use UNISIM.VComponents.all;
113
 
114
entity sdram_dcm is
115
        port(
116
           reset           : in  std_logic;
117
                clk50mhz        : in  std_logic;
118
                locked          : out std_logic;
119
                dram_clkp       : out std_logic;
120
                dram_clkn       : out std_logic;
121
                clk_000         : out std_logic;
122
                clk_090         : out std_logic;
123
                clk_180         : out std_logic;
124
                clk_270         : out std_logic
125
        );
126
end sdram_dcm;
127
 
128
architecture impl of sdram_dcm is
129
 
130
        signal dcm0_locked      : std_logic;
131
        signal dcm0_clk_raw_000 : std_logic;
132
        signal dcm0_clk_000     : std_logic;
133
        signal dcm0_clk_fxr_000 : std_logic;
134
        signal dcm0_clk_fx_000  : std_logic;
135
 
136
        signal dcm1_reset       : std_logic;
137
        signal dcm1_locked      : std_logic;
138
        signal dcm1_clk_raw_000 : std_logic;
139
        signal dcm1_clk_raw_090 : std_logic;
140
        signal dcm1_clk_000     : std_logic;
141
        signal dcm1_clk_090     : std_logic;
142
        signal dcm1_clk_180     : std_logic;
143
        signal dcm1_clk_270     : std_logic;
144
 
145
begin
146
 
147
        SDRAM_DCM0 : DCM_SP
148
   generic map (
149
      CLKDV_DIVIDE => 2.0,                   --  Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5
150
                                             --     7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
151
      CLKFX_DIVIDE => 2,                     --  Can be any integer from 1 to 32 
152
      CLKFX_MULTIPLY => 4,                   --  Can be any integer from 1 to 32
153
      CLKIN_DIVIDE_BY_2 => FALSE,            --  TRUE/FALSE to enable CLKIN divide by two feature
154
      CLKIN_PERIOD => 20.0,                  --  Specify period of input clock
155
      CLKOUT_PHASE_SHIFT => "NONE",          --  Specify phase shift of "NONE", "FIXED" or "VARIABLE" 
156
      CLK_FEEDBACK => "1X",                  --  Specify clock feedback of "NONE", "1X" or "2X" 
157
      DESKEW_ADJUST => "SOURCE_SYNCHRONOUS", -- "SOURCE_SYNCHRONOUS", "SYSTEM_SYNCHRONOUS" or
158
                                             --     an integer from 0 to 15
159
      DLL_FREQUENCY_MODE => "LOW",           -- "HIGH" or "LOW" frequency mode for DLL
160
      DUTY_CYCLE_CORRECTION => TRUE,         --  Duty cycle correction, TRUE or FALSE
161
      PHASE_SHIFT => 0,                      --  Amount of fixed phase shift from -255 to 255
162
      STARTUP_WAIT => FALSE)                 --  Delay configuration DONE until DCM_SP LOCK, TRUE/FALSE
163
   port map (
164
      CLK0     => dcm0_clk_raw_000,   -- 0 degree DCM CLK ouptput
165
      CLK90    => open,               -- 90 degree DCM CLK output
166
      CLK180   => open,               -- 180 degree DCM CLK output
167
      CLK270   => open,               -- 270 degree DCM CLK output
168
      CLK2X    => open,               -- 2X DCM CLK output
169
      CLK2X180 => open,               -- 2X, 180 degree DCM CLK out
170
      CLKDV    => open,               -- Divided DCM CLK out (CLKDV_DIVIDE)
171
      CLKFX    => dcm0_clk_fxr_000,   -- DCM CLK synthesis out (M/D) 
172
      CLKFX180 => open,               -- 180 degree CLK synthesis out
173
      LOCKED   => dcm0_locked,        -- DCM LOCK status output (means feedback is in phase with main clock)
174
      PSDONE   => open,               -- Dynamic phase adjust done output
175
      STATUS   => open,               -- 8-bit DCM status bits output
176
      CLKFB    => dcm0_clk_000,       -- DCM clock feedback
177
      CLKIN    => clk50mhz,           -- Clock input (from IBUFG, BUFG or DCM)
178
      PSCLK    => '0',                -- Dynamic phase adjust clock input
179
      PSEN     => '0',                -- Dynamic phase adjust enable input
180
      PSINCDEC => '0',                -- Dynamic phase adjust increment/decrement
181
      RST      => reset               -- DCM asynchronous reset input
182
   );
183
 
184
        BUFG_DCM0_000 : BUFG
185
   port map (
186
      O => dcm0_clk_000,      -- Clock buffer output
187
      I => dcm0_clk_raw_000   -- Clock buffer input
188
   );
189
 
190
        BUFG_DCM0_FX_000 : BUFG
191
   port map (
192
      O => dcm0_clk_fx_000,   -- Clock buffer output
193
      I => dcm0_clk_fxr_000   -- Clock buffer input
194
   );
195
 
196
        SDRAM_DCM1 : DCM_SP
197
   generic map (
198
      CLKDV_DIVIDE => 2.0,                   --  Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5
199
                                             --     7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
200
      CLKFX_DIVIDE => 2,                     --  Can be any integer from 1 to 32 
201
      CLKFX_MULTIPLY => 2,                   --  Can be any integer from 1 to 32
202
      CLKIN_DIVIDE_BY_2 => FALSE,            --  TRUE/FALSE to enable CLKIN divide by two feature
203
      CLKIN_PERIOD => 10.0,                  --  Specify period of input clock
204
      CLKOUT_PHASE_SHIFT => "NONE",          --  Specify phase shift of "NONE", "FIXED" or "VARIABLE" 
205
      CLK_FEEDBACK => "1X",                  --  Specify clock feedback of "NONE", "1X" or "2X" 
206
      DESKEW_ADJUST => "SOURCE_SYNCHRONOUS", -- "SOURCE_SYNCHRONOUS", "SYSTEM_SYNCHRONOUS" or
207
                                             --     an integer from 0 to 15
208
      DLL_FREQUENCY_MODE => "LOW",           -- "HIGH" or "LOW" frequency mode for DLL
209
      DUTY_CYCLE_CORRECTION => TRUE,         --  Duty cycle correction, TRUE or FALSE
210
      PHASE_SHIFT => 0,                      --  Amount of fixed phase shift from -255 to 255
211
      STARTUP_WAIT => FALSE)                 --  Delay configuration DONE until DCM_SP LOCK, TRUE/FALSE
212
   port map (
213
      CLK0     => dcm1_clk_raw_000,      -- 0 degree DCM CLK ouptput
214
      CLK90    => dcm1_clk_raw_090,      -- 90 degree DCM CLK output
215
      CLK180   => open,                  -- 180 degree DCM CLK output
216
      CLK270   => open,                  -- 270 degree DCM CLK output
217
      CLK2X    => open,                  -- 2X DCM CLK output
218
      CLK2X180 => open,                  -- 2X, 180 degree DCM CLK out
219
      CLKDV    => open,                  -- Divided DCM CLK out (CLKDV_DIVIDE)
220
      CLKFX    => open,                  -- DCM CLK synthesis out (M/D) 
221
      CLKFX180 => open,                  -- 180 degree CLK synthesis out
222
      LOCKED   => dcm1_locked,           -- DCM LOCK status output (means feedback is in phase with main clock)
223
      PSDONE   => open,                  -- Dynamic phase adjust done output
224
      STATUS   => open,                  -- 8-bit DCM status bits output
225
      CLKFB    => dcm1_clk_000,          -- DCM clock feedback
226
      CLKIN    => dcm0_clk_fx_000,       -- Clock input (from IBUFG, BUFG or DCM)
227
      PSCLK    => '0',                   -- Dynamic phase adjust clock input
228
      PSEN     => '0',                   -- Dynamic phase adjust enable input
229
      PSINCDEC => '0',                   -- Dynamic phase adjust increment/decrement
230
      RST      => dcm1_reset             -- DCM asynchronous reset input
231
   );
232
        dcm1_reset <= reset;
233
 
234
        BUFG_DCM1_000 : BUFG
235
   port map (
236
      O => dcm1_clk_000,      -- Clock buffer output
237
      I => dcm1_clk_raw_000   -- Clock buffer input
238
   );
239
 
240
        BUFG_DCM1_090 : BUFG
241
   port map (
242
      O => dcm1_clk_090,      -- Clock buffer output
243
      I => dcm1_clk_raw_090   -- Clock buffer input
244
   );
245
 
246
        dcm1_clk_180 <= not(dcm1_clk_000);
247
        dcm1_clk_270 <= not(dcm1_clk_090);
248
 
249
        ODDR2_DRAM_CLKP : ODDR2
250
        generic map(
251
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
252
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
253
      SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
254
   port map (
255
      Q => dram_clkp,            -- 1-bit output data
256
      C0 => dcm1_clk_000,        -- 1-bit clock input
257
      C1 => dcm1_clk_180,        -- 1-bit clock input
258
      CE => '1',                 -- 1-bit clock enable input
259
      D0 => '1',                 -- 1-bit data input (associated with C0)
260
      D1 => '0',                 -- 1-bit data input (associated with C1)
261
      R => reset,                -- 1-bit reset input
262
      S => '0'                   -- 1-bit set input
263
   );
264
 
265
        ODDR2_DRAM_CLKN : ODDR2
266
        generic map(
267
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
268
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
269
      SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
270
   port map (
271
      Q => dram_clkn,            -- 1-bit output data
272
      C0 => dcm1_clk_000,        -- 1-bit clock input
273
      C1 => dcm1_clk_180,        -- 1-bit clock input
274
      CE => '1',                 -- 1-bit clock enable input
275
      D0 => '0',                 -- 1-bit data input (associated with C0)
276
      D1 => '1',                 -- 1-bit data input (associated with C1)
277
      R => reset,                -- 1-bit reset input
278
      S => '0'                   -- 1-bit set input
279
   );
280
 
281
        locked <= dcm0_locked and dcm1_locked;
282
 
283
        clk_000 <= dcm1_clk_000;
284
        clk_090 <= dcm1_clk_090;
285
        clk_180 <= dcm1_clk_180;
286
        clk_270 <= dcm1_clk_270;
287
 
288
end impl;
289
 
290
 
291
library IEEE;
292
use IEEE.STD_LOGIC_1164.ALL;
293
use IEEE.STD_LOGIC_ARITH.ALL;
294
use IEEE.STD_LOGIC_UNSIGNED.ALL;
295
 
296
---- Uncomment the following library declaration if instantiating
297
---- any Xilinx primitives in this code.
298
library UNISIM;
299
use UNISIM.VComponents.all;
300
 
301
-- just a 2 bit wide ODDR2
302
entity oddr2_2 is
303
        port(
304
                Q  : out std_logic_vector(1 downto 0);
305
                C0 : in std_logic;
306
                C1 : in std_logic;
307
                CE : in std_logic;
308
                D0 : in std_logic_vector(1 downto 0);
309
                D1 : in std_logic_vector(1 downto 0);
310
                R  : in std_logic;
311
                S  : in std_logic );
312
end oddr2_2;
313
 
314
architecture impl of oddr2_2 is
315
begin
316
        ODDR2_0 : ODDR2
317
        generic map(
318
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
319
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
320
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
321
   port map (
322
      Q => Q(0),       -- 1-bit output data
323
      C0 => C0,        -- 1-bit clock input
324
      C1 => C1,        -- 1-bit clock input
325
      CE => CE,        -- 1-bit clock enable input
326
      D0 => D0(0),     -- 1-bit data input (associated with C0)
327
      D1 => D1(0),     -- 1-bit data input (associated with C1)
328
      R => R,          -- 1-bit reset input
329
      S => S           -- 1-bit set input
330
   );
331
 
332
  ODDR2_1 : ODDR2
333
  generic map(
334
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
335
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
336
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
337
   port map (
338
      Q => Q(1),       -- 1-bit output data
339
      C0 => C0,        -- 1-bit clock input
340
      C1 => C1,        -- 1-bit clock input
341
      CE => CE,        -- 1-bit clock enable input
342
      D0 => D0(1),     -- 1-bit data input (associated with C0)
343
      D1 => D1(1),     -- 1-bit data input (associated with C1)
344
      R => R,          -- 1-bit reset input
345
      S => S           -- 1-bit set input
346
   );
347
end impl;
348
 
349
 
350
 
351
library IEEE;
352
use IEEE.STD_LOGIC_1164.ALL;
353
use IEEE.STD_LOGIC_ARITH.ALL;
354
use IEEE.STD_LOGIC_UNSIGNED.ALL;
355
 
356
---- Uncomment the following library declaration if instantiating
357
---- any Xilinx primitives in this code.
358
library UNISIM;
359
use UNISIM.VComponents.all;
360
 
361
-- just a 3 bit wide ODDR2
362
entity oddr2_3 is
363
        port(
364
                Q  : out std_logic_vector(2 downto 0);
365
                C0 : in std_logic;
366
                C1 : in std_logic;
367
                CE : in std_logic;
368
                D0 : in std_logic_vector(2 downto 0);
369
                D1 : in std_logic_vector(2 downto 0);
370
                R  : in std_logic;
371
                S  : in std_logic );
372
end oddr2_3;
373
 
374
architecture impl of oddr2_3 is
375
begin
376
        ODDR2_0 : ODDR2
377
        generic map(
378
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
379
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
380
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
381
   port map (
382
      Q => Q(0),       -- 1-bit output data
383
      C0 => C0,        -- 1-bit clock input
384
      C1 => C1,        -- 1-bit clock input
385
      CE => CE,        -- 1-bit clock enable input
386
      D0 => D0(0),     -- 1-bit data input (associated with C0)
387
      D1 => D1(0),     -- 1-bit data input (associated with C1)
388
      R => R,          -- 1-bit reset input
389
      S => S           -- 1-bit set input
390
   );
391
 
392
  ODDR2_1 : ODDR2
393
  generic map(
394
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
395
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
396
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
397
   port map (
398
      Q => Q(1),       -- 1-bit output data
399
      C0 => C0,        -- 1-bit clock input
400
      C1 => C1,        -- 1-bit clock input
401
      CE => CE,        -- 1-bit clock enable input
402
      D0 => D0(1),     -- 1-bit data input (associated with C0)
403
      D1 => D1(1),     -- 1-bit data input (associated with C1)
404
      R => R,          -- 1-bit reset input
405
      S => S           -- 1-bit set input
406
   );
407
 
408
  ODDR2_2 : ODDR2
409
  generic map(
410
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
411
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
412
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
413
   port map (
414
      Q => Q(2),       -- 1-bit output data
415
      C0 => C0,        -- 1-bit clock input
416
      C1 => C1,        -- 1-bit clock input
417
      CE => CE,        -- 1-bit clock enable input
418
      D0 => D0(2),     -- 1-bit data input (associated with C0)
419
      D1 => D1(2),     -- 1-bit data input (associated with C1)
420
      R => R,          -- 1-bit reset input
421
      S => S           -- 1-bit set input
422
   );
423
end impl;
424
 
425
 
426
 
427
library IEEE;
428
use IEEE.STD_LOGIC_1164.ALL;
429
use IEEE.STD_LOGIC_ARITH.ALL;
430
use IEEE.STD_LOGIC_UNSIGNED.ALL;
431
 
432
---- Uncomment the following library declaration if instantiating
433
---- any Xilinx primitives in this code.
434
library UNISIM;
435
use UNISIM.VComponents.all;
436
 
437
-- 2 oddr2_2's
438
entity oddr2_4 is
439
   port( Q  : out std_logic_vector(3 downto 0);
440
         C0 : in std_logic;
441
         C1 : in std_logic;
442
         CE : in std_logic;
443
         D0 : in std_logic_vector(3 downto 0);
444
         D1 : in std_logic_vector(3 downto 0);
445
         R  : in std_logic;
446
         S  : in std_logic );
447
end oddr2_4;
448
 
449
architecture impl of oddr2_4 is
450
 
451
        component oddr2_2 is
452
    port(
453
                Q  : out std_logic_vector(1 downto 0);
454
                C0 : in std_logic;
455
                C1 : in std_logic;
456
                CE : in std_logic;
457
                D0 : in std_logic_vector(1 downto 0);
458
                D1 : in std_logic_vector(1 downto 0);
459
                R  : in std_logic;
460
                S  : in std_logic );
461
        end component;
462
 
463
begin
464
  ODDR2_0 : oddr2_2
465
  port map (
466
      Q => Q(1 downto 0),       -- 1-bit output data
467
      C0 => C0,                 -- 1-bit clock input
468
      C1 => C1,                 -- 1-bit clock input
469
      CE => CE,                 -- 1-bit clock enable input
470
      D0 => D0(1 downto 0),     -- 1-bit data input (associated with C0)
471
      D1 => D1(1 downto 0),     -- 1-bit data input (associated with C1)
472
      R => R,                   -- 1-bit reset input
473
      S => S                    -- 1-bit set input
474
   );
475
 
476
  ODDR2_1 : oddr2_2
477
   port map (
478
      Q => Q(3 downto 2),       -- 1-bit output data
479
      C0 => C0,                 -- 1-bit clock input
480
      C1 => C1,                 -- 1-bit clock input
481
      CE => CE,                 -- 1-bit clock enable input
482
      D0 => D0(3 downto 2),     -- 1-bit data input (associated with C0)
483
      D1 => D1(3 downto 2),     -- 1-bit data input (associated with C1)
484
      R => R,                   -- 1-bit reset input
485
      S => S                    -- 1-bit set input
486
   );
487
end impl;
488
 
489
 
490
library IEEE;
491
use IEEE.STD_LOGIC_1164.ALL;
492
use IEEE.STD_LOGIC_ARITH.ALL;
493
use IEEE.STD_LOGIC_UNSIGNED.ALL;
494
 
495
---- Uncomment the following library declaration if instantiating
496
---- any Xilinx primitives in this code.
497
library UNISIM;
498
use UNISIM.VComponents.all;
499
 
500
-- one ODDR2 and 3 4-bit oddr2_4's
501
entity oddr2_13 is
502
   port( Q  : out std_logic_vector(12 downto 0);
503
         C0 : in std_logic;
504
         C1 : in std_logic;
505
         CE : in std_logic;
506
         D0 : in std_logic_vector(12 downto 0);
507
         D1 : in std_logic_vector(12 downto 0);
508
         R  : in std_logic;
509
         S  : in std_logic );
510
end oddr2_13;
511
 
512
architecture impl of oddr2_13 is
513
 
514
        component oddr2_4 is
515
                port(
516
                        Q  : out std_logic_vector(3 downto 0);
517
                        C0 : in std_logic;
518
                        C1 : in std_logic;
519
                        CE : in std_logic;
520
                        D0 : in std_logic_vector(3 downto 0);
521
                        D1 : in std_logic_vector(3 downto 0);
522
                        R  : in std_logic;
523
                        S  : in std_logic );
524
  end component;
525
 
526
begin
527
 
528
  ODDR2_0 : ODDR2
529
  generic map(
530
      DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1" 
531
      INIT => '0', -- Sets initial state of the Q output to '0' or '1'
532
      SRTYPE => "ASYNC") -- Specifies "SYNC" or "ASYNC" set/reset
533
   port map (
534
      Q => Q(0),       -- 1-bit output data
535
      C0 => C0,        -- 1-bit clock input
536
      C1 => C1,        -- 1-bit clock input
537
      CE => CE,        -- 1-bit clock enable input
538
      D0 => D0(0),     -- 1-bit data input (associated with C0)
539
      D1 => D1(0),     -- 1-bit data input (associated with C1)
540
      R => R,          -- 1-bit reset input
541
      S => S           -- 1-bit set input
542
   );
543
 
544
   ODDR2_1 : oddr2_4
545
   port map(
546
      Q => Q(4 downto 1),
547
      C0 => C0,
548
      C1 => C1,
549
      CE => CE,
550
      D0 => D0(4 downto 1),
551
      D1 => D1(4 downto 1),
552
      R => R,
553
      S => S
554
   );
555
 
556
   ODDR2_2 : oddr2_4
557
   port map(
558
      Q => Q(8 downto 5),
559
      C0 => C0,
560
      C1 => C1,
561
      CE => CE,
562
      D0 => D0(8 downto 5),
563
      D1 => D1(8 downto 5),
564
      R => R,
565
      S => S
566
   );
567
 
568
   ODDR2_3 : oddr2_4
569
   port map(
570
      Q => Q(12 downto 9),
571
      C0 => C0,
572
      C1 => C1,
573
      CE => CE,
574
      D0 => D0(12 downto 9),
575
      D1 => D1(12 downto 9),
576
      R => R,
577
      S => S
578
   );
579
end impl;
580
 
581
 
582
 
583
library IEEE;
584
use IEEE.STD_LOGIC_1164.ALL;
585
use IEEE.STD_LOGIC_ARITH.ALL;
586
use IEEE.STD_LOGIC_UNSIGNED.ALL;
587
 
588
---- Uncomment the following library declaration if instantiating
589
---- any Xilinx primitives in this code.
590
library UNISIM;
591
use UNISIM.VComponents.all;
592
 
593
-- 4 4-bit oddr2_4's
594
entity oddr2_16 is
595
   port( Q  : out std_logic_vector(15 downto 0);
596
         C0 : in std_logic;
597
         C1 : in std_logic;
598
         CE : in std_logic;
599
         D0 : in std_logic_vector(15 downto 0);
600
         D1 : in std_logic_vector(15 downto 0);
601
         R  : in std_logic;
602
         S  : in std_logic );
603
end oddr2_16;
604
 
605
architecture impl of oddr2_16 is
606
 
607
        component oddr2_4 is
608
                port(
609
                        Q  : out std_logic_vector(3 downto 0);
610
                        C0 : in std_logic;
611
                        C1 : in std_logic;
612
                        CE : in std_logic;
613
                        D0 : in std_logic_vector(3 downto 0);
614
                        D1 : in std_logic_vector(3 downto 0);
615
                        R  : in std_logic;
616
                        S  : in std_logic );
617
  end component;
618
 
619
begin
620
        ODDR2_0 : oddr2_4
621
        port map (
622
      Q => Q(3 downto 0),
623
      C0 => C0,
624
      C1 => C1,
625
      CE => CE,
626
      D0 => D0(3 downto 0),
627
      D1 => D1(3 downto 0),
628
      R => R,
629
      S => S
630
   );
631
 
632
        ODDR2_1 : oddr2_4
633
        port map (
634
      Q => Q(7 downto 4),
635
      C0 => C0,
636
      C1 => C1,
637
      CE => CE,
638
      D0 => D0(7 downto 4),
639
      D1 => D1(7 downto 4),
640
      R => R,
641
      S => S
642
   );
643
 
644
        ODDR2_2 : oddr2_4
645
        port map (
646
      Q => Q(11 downto 8),
647
      C0 => C0,
648
      C1 => C1,
649
      CE => CE,
650
      D0 => D0(11 downto 8),
651
      D1 => D1(11 downto 8),
652
      R => R,
653
      S => S
654
   );
655
 
656
        ODDR2_3 : oddr2_4
657
        port map (
658
      Q => Q(15 downto 12),
659
      C0 => C0,
660
      C1 => C1,
661
      CE => CE,
662
      D0 => D0(15 downto 12),
663
      D1 => D1(15 downto 12),
664
      R => R,
665
      S => S
666
   );
667
end;
668
 
669
 
670
library IEEE;
671
use IEEE.STD_LOGIC_1164.ALL;
672
use IEEE.STD_LOGIC_ARITH.ALL;
673
use IEEE.STD_LOGIC_UNSIGNED.ALL;
674
 
675
---- Uncomment the following library declaration if instantiating
676
---- any Xilinx primitives in this code.
677
library UNISIM;
678
use UNISIM.VComponents.all;
679
 
680
entity inout_switch_2 is
681
        port (
682
                ioport : inout std_logic_vector(1 downto 0);
683
                   dir : in std_logic;
684
                data_i : in std_logic_vector(1 downto 0)
685
        );
686
end inout_switch_2;
687
 
688
architecture impl of inout_switch_2 is
689
begin
690
        ioport <= data_i when dir = '1' else "ZZ";
691
end impl;
692
 
693
 
694
library IEEE;
695
use IEEE.STD_LOGIC_1164.ALL;
696
use IEEE.STD_LOGIC_ARITH.ALL;
697
use IEEE.STD_LOGIC_UNSIGNED.ALL;
698
 
699
---- Uncomment the following library declaration if instantiating
700
---- any Xilinx primitives in this code.
701
library UNISIM;
702
use UNISIM.VComponents.all;
703
 
704
entity inout_switch_16 is
705
        port (
706
                ioport : inout std_logic_vector(15 downto 0);
707
                   dir : in    std_logic;
708
                data_o : out   std_logic_vector(15 downto 0);
709
                data_i : in    std_logic_vector(15 downto 0)
710
        );
711
end inout_switch_16;
712
 
713
architecture impl of inout_switch_16 is
714
begin
715
        data_o <= ioport when dir = '0' else "ZZZZZZZZZZZZZZZZ";
716
        ioport <= data_i when dir = '1' else "ZZZZZZZZZZZZZZZZ";
717
end impl;
718
 
719
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.