used :retab and fixed tab spacing
This commit is contained in:
parent
c5d387fa24
commit
adb21070d4
|
|
@ -55,9 +55,9 @@ module ddr3_controller #(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////// COMMAND PARAMETERS //////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////// COMMAND PARAMETERS //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//DDR3 commands {cs_n, ras_n, cas_n, we_n} (JEDEC DDR3 doc pg. 33 )
|
//DDR3 commands {cs_n, ras_n, cas_n, we_n} (JEDEC DDR3 doc pg. 33 )
|
||||||
localparam[3:0]CMD_MRS = 4'b0000, // Mode Register Set
|
localparam[3:0]CMD_MRS = 4'b0000, // Mode Register Set
|
||||||
CMD_REF = 4'b0001, // Refresh
|
CMD_REF = 4'b0001, // Refresh
|
||||||
CMD_PRE = 4'b0010, // Precharge (A10-AP: 0 = Single Bank Precharge, 1 = Precharge All Banks)
|
CMD_PRE = 4'b0010, // Precharge (A10-AP: 0 = Single Bank Precharge, 1 = Precharge All Banks)
|
||||||
|
|
@ -68,95 +68,95 @@ module ddr3_controller #(
|
||||||
CMD_DES = 4'b1000, // Deselect command performs the same function as No Operation command (JEDEC DDR3 doc pg. 34 NOTE 11)
|
CMD_DES = 4'b1000, // Deselect command performs the same function as No Operation command (JEDEC DDR3 doc pg. 34 NOTE 11)
|
||||||
CMD_ZQC = 4'b0110; // ZQ Calibration (A10-AP: 0 = ZQ Calibration Short, 1 = ZQ Calibration Long)
|
CMD_ZQC = 4'b0110; // ZQ Calibration (A10-AP: 0 = ZQ Calibration Short, 1 = ZQ Calibration Long)
|
||||||
|
|
||||||
localparam RST_DONE = 27, //Command bit that determines if the command is for power-on sequence only (not on power-stable sequence)
|
localparam RST_DONE = 27, //Command bit that determines if the command is for power-on sequence only (not on power-stable sequence)
|
||||||
RST_USE_TIMER = 26, // Command bit that determines if timer will be used
|
RST_USE_TIMER = 26, // Command bit that determines if timer will be used
|
||||||
RST_STAY_COMMAND = 25, //Command bit that determines if command will last for entire timer duration (or if
|
RST_STAY_COMMAND = 25, //Command bit that determines if command will last for entire timer duration (or if
|
||||||
RST_CKE = 24, //Control clock-enable input to DDR3
|
RST_CKE = 24, //Control clock-enable input to DDR3
|
||||||
RST_RESET_N = 23; //Control reset to DDR3
|
RST_RESET_N = 23; //Control reset to DDR3
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////// SET MODE REGISTERS //////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////// SET MODE REGISTERS //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// MR2 (JEDEC DDR3 doc pg. 30)
|
// MR2 (JEDEC DDR3 doc pg. 30)
|
||||||
localparam[2:0] PASR = 3'b000; //Partial Array Self-Refresh: Full Array
|
localparam[2:0] PASR = 3'b000; //Partial Array Self-Refresh: Full Array
|
||||||
localparam[2:0] CWL = 3'b011; //CAS write Latency: 8 (1.5 ns > tCK(avg) >= 1.25 ns) CREATE A FUNCTION FOR THIS
|
localparam[2:0] CWL = 3'b011; //CAS write Latency: 8 (1.5 ns > tCK(avg) >= 1.25 ns) CREATE A FUNCTION FOR THIS
|
||||||
localparam[0:0] ASR = 1'b1; //Auto Self-Refresh: on
|
localparam[0:0] ASR = 1'b1; //Auto Self-Refresh: on
|
||||||
localparam[0:0] SRT = 1'b0; //Self-Refresh Temperature Range:0 (If ASR = 1, SRT bit must be set to 0)
|
localparam[0:0] SRT = 1'b0; //Self-Refresh Temperature Range:0 (If ASR = 1, SRT bit must be set to 0)
|
||||||
localparam[1:0] RTT_WR = 2'b00; //Dynamic ODT: off
|
localparam[1:0] RTT_WR = 2'b00; //Dynamic ODT: off
|
||||||
localparam[2:0] MR2_SEL = 3'b010; //Selected Mode Register
|
localparam[2:0] MR2_SEL = 3'b010; //Selected Mode Register
|
||||||
localparam[18:0] MR2 = {MR2_SEL, 5'b00000, RTT_WR, 1'b0, SRT, ASR, CWL, PASR};
|
localparam[18:0] MR2 = {MR2_SEL, 5'b00000, RTT_WR, 1'b0, SRT, ASR, CWL, PASR};
|
||||||
|
|
||||||
// MR3 (JEDEC DDR3 doc pg. 32)
|
// MR3 (JEDEC DDR3 doc pg. 32)
|
||||||
localparam[1:0] MPR_LOC = 2'b00; //Data location for MPR Reads: Predefined Pattern 0_1_0_1_0_1_0_1
|
localparam[1:0] MPR_LOC = 2'b00; //Data location for MPR Reads: Predefined Pattern 0_1_0_1_0_1_0_1
|
||||||
localparam[0:0] MPR_EN = 1'b0; //MPR Enable: Enable MPR reads and calibration during initialization
|
localparam[0:0] MPR_EN = 1'b0; //MPR Enable: Enable MPR reads and calibration during initialization
|
||||||
localparam[2:0] MR3_SEL = 3'b011; //MPR Selected
|
localparam[2:0] MR3_SEL = 3'b011; //MPR Selected
|
||||||
localparam[18:0] MR3 = {MR3_SEL, 13'b0_0000_0000_0000, MPR_EN, MPR_LOC};
|
localparam[18:0] MR3 = {MR3_SEL, 13'b0_0000_0000_0000, MPR_EN, MPR_LOC};
|
||||||
|
|
||||||
// MR1 (JEDEC DDR3 doc pg. 27)
|
// MR1 (JEDEC DDR3 doc pg. 27)
|
||||||
localparam DLL_EN = 1'b0; //DLL Enable/Disable: Enabled(0)
|
localparam DLL_EN = 1'b0; //DLL Enable/Disable: Enabled(0)
|
||||||
localparam[1:0] DIC = 2'b00; //Output Driver Impedance Control (IS THIS THE SAME WITH RTT_NOM???????????? Search later)
|
localparam[1:0] DIC = 2'b00; //Output Driver Impedance Control (IS THIS THE SAME WITH RTT_NOM???????????? Search later)
|
||||||
localparam[2:0] RTT_NOM = 3'b011; //RTT Nominal: 40ohms (RQZ/6) is the impedance of the PCB trace
|
localparam[2:0] RTT_NOM = 3'b011; //RTT Nominal: 40ohms (RQZ/6) is the impedance of the PCB trace
|
||||||
localparam[0:0] WL_EN = 1'b0; //Write Leveling Enable: Disabled
|
localparam[0:0] WL_EN = 1'b0; //Write Leveling Enable: Disabled
|
||||||
localparam[1:0] AL = 2'b00; //Additive Latency: Disabled
|
localparam[1:0] AL = 2'b00; //Additive Latency: Disabled
|
||||||
localparam[0:0] TDQS = 1'b0; //Termination Data Strobe: Disabled (provides additional termination resistance outputs. When the TDQS function is disabled, the DM function is provided (vice-versa).TDQS function is only available for X8 DRAM and must be disabled for X4 and X16.
|
localparam[0:0] TDQS = 1'b0; //Termination Data Strobe: Disabled (provides additional termination resistance outputs. When the TDQS function is disabled, the DM function is provided (vice-versa).TDQS function is only available for X8 DRAM and must be disabled for X4 and X16.
|
||||||
localparam[0:0] QOFF = 1'b0; //Output Buffer Control: Enabled
|
localparam[0:0] QOFF = 1'b0; //Output Buffer Control: Enabled
|
||||||
localparam[2:0] MR1_SEL = 3'b001; //Selected Mode Register
|
localparam[2:0] MR1_SEL = 3'b001; //Selected Mode Register
|
||||||
localparam[18:0] MR1 = {MR1_SEL, 3'b000, QOFF, TDQS, 1'b0, RTT_NOM[2], 1'b0, WL_EN, RTT_NOM[1], DIC[1], AL, RTT_NOM[0], DIC[0], DLL_EN};
|
localparam[18:0] MR1 = {MR1_SEL, 3'b000, QOFF, TDQS, 1'b0, RTT_NOM[2], 1'b0, WL_EN, RTT_NOM[1], DIC[1], AL, RTT_NOM[0], DIC[0], DLL_EN};
|
||||||
|
|
||||||
//MR0 (JEDEC DDR3 doc pg. 24)
|
//MR0 (JEDEC DDR3 doc pg. 24)
|
||||||
localparam[1:0] BL = 2'b00; //Burst Length: 8 (Fixed)
|
localparam[1:0] BL = 2'b00; //Burst Length: 8 (Fixed)
|
||||||
localparam[3:0] CL = 4'b1100; //CAS Read Latency: 10, can support DDR-1600 speedbin 8-8-8, 9-9-9, and 10-10-10 (Check JEDEC DDR doc pg. 162) CREATE A FUNCTION FOR THIS
|
localparam[3:0] CL = 4'b1100; //CAS Read Latency: 10, can support DDR-1600 speedbin 8-8-8, 9-9-9, and 10-10-10 (Check JEDEC DDR doc pg. 162) CREATE A FUNCTION FOR THIS
|
||||||
localparam[0:0] RBT = 1'b0; //Read Burst Type: Nibble Sequential
|
localparam[0:0] RBT = 1'b0; //Read Burst Type: Nibble Sequential
|
||||||
localparam[0:0] DLL_RST = 1'b1; //DLL Reset: Yes (this is self-clearing and must be applied after DLL enable)
|
localparam[0:0] DLL_RST = 1'b1; //DLL Reset: Yes (this is self-clearing and must be applied after DLL enable)
|
||||||
localparam[2:0] WR = WRA_mode_register_value($ceil(tWR/DDR3_CLK_PERIOD)); //Write recovery for autoprecharge (
|
localparam[2:0] WR = WRA_mode_register_value($ceil(tWR/DDR3_CLK_PERIOD)); //Write recovery for autoprecharge (
|
||||||
localparam[0:0] PPD = 1'b0; //DLL Control for Precharge PD: Slow exit (DLL off)
|
localparam[0:0] PPD = 1'b0; //DLL Control for Precharge PD: Slow exit (DLL off)
|
||||||
localparam[2:0] MR0_SEL = 3'b000;
|
localparam[2:0] MR0_SEL = 3'b000;
|
||||||
localparam[18:0] MR0 = {MR0_SEL, 3'b000, PPD, WR, DLL_RST, 1'b0, CL[3:1], RBT, CL[0], BL};
|
localparam[18:0] MR0 = {MR0_SEL, 3'b000, PPD, WR, DLL_RST, 1'b0, CL[3:1], RBT, CL[0], BL};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////// TIMING PARAMETERS ////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////// TIMING PARAMETERS ////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
localparam POWER_ON_RESET_HIGH = 200_000; // 200us reset must be active at initialization
|
localparam POWER_ON_RESET_HIGH = 200_000; // 200us reset must be active at initialization
|
||||||
localparam INITIAL_CKE_LOW = 500_000; // 500us cke must be low before activating
|
localparam INITIAL_CKE_LOW = 500_000; // 500us cke must be low before activating
|
||||||
|
|
||||||
`ifdef DDR3_1600_11_11_11 //DDR3-1600 (11-11-11) speed bin
|
`ifdef DDR3_1600_11_11_11 //DDR3-1600 (11-11-11) speed bin
|
||||||
localparam tRAS = 35.0; // ns Minimum Active to Precharge command time
|
localparam tRAS = 35.0; // ns Minimum Active to Precharge command time
|
||||||
localparam tRC = 48.750; //ns Active to Active/Auto Refresh command time
|
localparam tRC = 48.750; //ns Active to Active/Auto Refresh command time
|
||||||
localparam tRCD = 13.750; // ns Active to Read/Write command time
|
localparam tRCD = 13.750; // ns Active to Read/Write command time
|
||||||
localparam tRP = 13.750; // ns Precharge command period
|
localparam tRP = 13.750; // ns Precharge command period
|
||||||
|
|
||||||
`endif
|
`endif
|
||||||
|
|
||||||
`ifdef RAM_1Gb
|
`ifdef RAM_1Gb
|
||||||
localparam tRFC = 110.0; // ns Refresh command to ACT or REF
|
localparam tRFC = 110.0; // ns Refresh command to ACT or REF
|
||||||
`elsif RAM_2Gb
|
`elsif RAM_2Gb
|
||||||
localparam tRFC = 160.0; // ns Refresh command to ACT or REF
|
localparam tRFC = 160.0; // ns Refresh command to ACT or REF
|
||||||
`elsif RAM_4Gb
|
`elsif RAM_4Gb
|
||||||
localparam tRFC = 300.0; // ns Refresh command to ACT or REF
|
localparam tRFC = 300.0; // ns Refresh command to ACT or REF
|
||||||
`else
|
`else
|
||||||
localparam tRFC = 350.0; // ns Refresh command to ACT or REF
|
localparam tRFC = 350.0; // ns Refresh command to ACT or REF
|
||||||
`endif
|
`endif
|
||||||
|
|
||||||
localparam tXPR = max(5*DDR3_CLK_PERIOD,tRFC+10); // ns Exit Reset from CKE HIGH to a valid command
|
localparam tXPR = max(5*DDR3_CLK_PERIOD,tRFC+10); // ns Exit Reset from CKE HIGH to a valid command
|
||||||
localparam tMRD = 4; // nCK Mode Register Set command cycle time
|
localparam tMRD = 4; // nCK Mode Register Set command cycle time
|
||||||
localparam tWR = 15.0; // ns Write Recovery Time
|
localparam tWR = 15.0; // ns Write Recovery Time
|
||||||
localparam tDLLK = 512.0; //nCK DLL Locking time
|
localparam tDLLK = 512.0; //nCK DLL Locking time
|
||||||
localparam[DELAY_SLOT_WIDTH - 1:0] tMOD = max(nCK_to_cycles(12), ns_to_cycles(15)); //cycles (controller) Mode Register Set command update delay
|
localparam[DELAY_SLOT_WIDTH - 1:0] tMOD = max(nCK_to_cycles(12), ns_to_cycles(15)); //cycles (controller) Mode Register Set command update delay
|
||||||
localparam[DELAY_SLOT_WIDTH - 1:0] tZQinit = max(nCK_to_cycles(512), ns_to_cycles(640));//cycles (controller) Power-up and RESET calibration time
|
localparam[DELAY_SLOT_WIDTH - 1:0] tZQinit = max(nCK_to_cycles(512), ns_to_cycles(640));//cycles (controller) Power-up and RESET calibration time
|
||||||
localparam[DELAY_SLOT_WIDTH - 1:0] tZQoper = max(nCK_to_cycles(256), ns_to_cycles(320)); //cycles (controller) Normal operation Full calibration time
|
localparam[DELAY_SLOT_WIDTH - 1:0] tZQoper = max(nCK_to_cycles(256), ns_to_cycles(320)); //cycles (controller) Normal operation Full calibration time
|
||||||
|
|
||||||
localparam DELAY_MAX_VALUE = ns_to_cycles(INITIAL_CKE_LOW); //Largest possible delay needed by the reset and refresh sequence
|
localparam DELAY_MAX_VALUE = ns_to_cycles(INITIAL_CKE_LOW); //Largest possible delay needed by the reset and refresh sequence
|
||||||
localparam DELAY_COUNTER_WIDTH= $clog2(DELAY_MAX_VALUE); //Bitwidth needed by the maximum possible delay, this will be the delay counter width
|
localparam DELAY_COUNTER_WIDTH= $clog2(DELAY_MAX_VALUE); //Bitwidth needed by the maximum possible delay, this will be the delay counter width
|
||||||
localparam DELAY_SLOT_WIDTH = $bits(MR0); //Bitwidth of the delay slot and mode register slot on the reset rom will be at the same size as the Mode Register
|
localparam DELAY_SLOT_WIDTH = $bits(MR0); //Bitwidth of the delay slot and mode register slot on the reset rom will be at the same size as the Mode Register
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
localparam AP = 10 ; // the address bit that controls auto-precharge and precharge-all
|
localparam AP = 10 ; // the address bit that controls auto-precharge and precharge-all
|
||||||
localparam BC = 12; // the address bit that controls burst chop
|
localparam BC = 12; // the address bit that controls burst chop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue