
Introduction:
=============

This design implemented by Verilog language is targeted to LFXP10C-5F388C for running
DDR memory test at 166.67MHz on LatticeXP Advanced Evaluation Board.

There is a 200-pin SO-DIMM DDR memory socket on the evaluation board where 
DDR memory module can be installed.

Three DDR memory modules from different vendors were tested and all worked successfully 
with the design.

These DDR modules are

  Micron's MT8VDDT3264HDG-40B 
  http://www.micron.com/products/modules/ddrsdram/part.aspx?part=MT8VDDT3264HDG-40B 

  Corsair's VS512SDS400 
  http://www.corsairmicro.com/corsair/valueselect.html

  Pqi's MD4212UOE 
  http://www.pqimemory.com/power_memory.asp

  Infineon's HYS64D32020GDL-5-B
  http://www.infineon.com/cgi/ecrm.dll/ecrm/scripts/prod_ov.jsp?oid=32338&cat_oid=-9476

For accessing the SO-DIMM DDR memory module, Lattice IP core "Lattice DDR SDRAM 
Controller - Pipelined for LatticeECP/EC (DDRCT-GEN-E2-N1)" is used.

Therefore, only a small portion of the memory module is tested.
There are 2 bitstream files included in this ZIP file for supporting 133MHz DDR266 
and 166MHz DDR333.  Please make sure the 33.33MHz oscillator is installed to provide 
clock through ball A10.  These 2 bitstream files are:

ddr_verilog_pnr_166MHz_DDR333.jed
ddr_verilog_pnr_133MHz_DDR266.jed

Board Setup
===========

1. Set the Vccio pins of banks 0, 1, 6, 7 to 2.5V by moving all jumpers from JP1, JP2 or JP4 to JP3.
2. Install four jumpers on either JP7, JP9, or JP11 to select the core voltage for LFXP10C.
3. Set the pins (CFG1, CFG0) of SW4 OFF. (Pull the SW4 pins up.)
4. SW1 pin 8 is the "rst_n" reset signal. This needs to be pulled up to lease the reset state.
5. Enable the power circuit by installing jumper between pin 2 and pin 3 of JP15-JP18: 
   The pin 2 and pin 3 of JP15 and JP16 are the left hand side two pins.
   The pin 2 and pin 3 of JP17 and JP18 are the lower two pins.
6. The 33.33MHz oscillator must be installed in pins 1, 7 (GND), 10 (CLK) and 16 (3.3V) of the DIP-16 socket.
   This will provide a clock signal to the FPGA through ball A10.
7. Install the SO-DIMM DDR memory module
8. Use a 5V power supply that can provide adequate current to the board.

Limitation:
===========

The 200-pin SO-DIMM DDR module contains 64-bit wide data bus, however, in order 
to reserve I/Os for demonstrating other features on the evaluation board only 
16 data bits are connected to LFXP10C FPGA.

This design is using the evaluation version of the Lattice IP core, the 
configuration is limited to 12-bit row address, 9-bit column address, and 1 chip 
select(rank).

Memory Testing Algorithm:
=========================

The test is completed by writing test_data into address space (from 0 to 7FFFFC) 
of the user interface and then read the data back for checking.

The test starts from writing 0x01 to byte_1 (D15-D8) and 0xfe to byte_0 (D7-D0) 
of address 0x00000, then the test data will be rotated within the byte and the 
address will be increased by 4 for the next write cycle.

When the write reaches address 0x7ffff, reading and verification will be started 
from address 0x00000, and then address 0x00004, ...

After the read reaches address 0x7ffff, one test is considered as completed and 
the test_data will be changed for the next test.

In order to prevent writing the same pattern to the same address location for 
every test, the test_data is rotated and then inverted at address 0x00000 before 
a new test starts.

The following are the testing sequences:

                           byte_1  byte_0
                           D15-D8  D7-D0
Test 1 started----------------------------
Write to address 0x00000:  0x01    0xfe
Write to address 0x00004:  0x02    0xfd
Write to address 0x00008:  0x04    0xfb
Write to address 0x0000c:  0x08    0xf7
Write to address 0x00010:  0x10    0xef
Write to address 0x00014:  0x20    0xdf
Write to address 0x00018:  0x40    0xbf
Write to address 0x0001c:  0x80    0x7f
Write to address 0x00020:  0x01    0xfe
Write to address 0x00024:  0x02    0xfd
Write to address 0x00028:  0x04    0xfb
Write to address 0x0002c:  0x08    0xf7
 :
 :
Write to address 0x7ffff:  0x80    0x7f
Read from address 0x00000
Read from address 0x00004
 :
 :
Read from address 0x7ffff
Test 2 started----------------------------
Write to address 0x00000:  0xfd    0x02
Write to address 0x00004:  0xfb    0x04
Write to address 0x00008:  0xf7    0x08
Write to address 0x0000c:  0xef    0x10
Write to address 0x00010:  0xdf    0x20
Write to address 0x00014:  0xbf    0x40
Write to address 0x00018:  0x7f    0x80
Write to address 0x0001c:  0xfe    0x01
Write to address 0x00020:  0xfd    0x02
Write to address 0x00024:  0xfb    0x04
Write to address 0x00028:  0xf7    0x08
Write to address 0x0002c:  0xef    0x10
 :
 :
Write to address 0x7ffff:  0xfe    0x01
Read from address 0x00000
Read from address 0x00004
 :
 :
Read from address 0x7ffff
Test 3 started----------------------------
Write to address 0x00000:  0x04    0xfb
Write to address 0x00004:  0x08    0xf7
Write to address 0x00008:  0x10    0xef
Write to address 0x0000c:  0x20    0xdf
Write to address 0x00010:  0x40    0xbf
Write to address 0x00014:  0x80    0x7f
Write to address 0x00018:  0x01    0xfe
Write to address 0x0001c:  0x02    0xfd
Write to address 0x00020:  0x04    0xfb
Write to address 0x00024:  0x08    0xf7
Write to address 0x00028:  0x10    0xef
Write to address 0x0002c:  0x20    0xdf
 :
 :
Write to address 0x7ffff:  0x02    0xfd
Read from address 0x00000
Read from address 0x00004
 :
 :
Read from address 0x7ffff
Test 3 started----------------------------
Write to address 0x00000:  0xf7    0x08
 :
 :
 
Test results:
=============

There are two counters implemented for showing the number of successful tests 
and failed tests.

While reading data back for verification, if any data in any address location 
is incorrect, the failure counter will be increased by one.

Only if all the data in all address locations are correct, the success counter 
will be increased.

   number_of_tests_passed: displayed on LEDs D8(MSB), D7, D6, D5(LSB)
   number_of_tests_failed: displayed on LEDs D4(MSB), D3, D2, D1(LSB)

Waveform Measuring:
===================

For measuring write cycle timing, set trigger at falling edge of ball F2 (signal cmd[0]).

For measuring read cycle timing, set trigger at rising edge of ball F2 (signal cmd[0]).
