1 |
2 |
des00 |
//
|
2 |
|
|
// Project : High-Speed SDRAM Controller with adaptive bank management and command pipeline
|
3 |
|
|
//
|
4 |
|
|
// Project Nick : HSSDRC
|
5 |
|
|
//
|
6 |
|
|
// Version : 1.0-beta
|
7 |
|
|
//
|
8 |
|
|
// Revision : $Revision: 1.1 $
|
9 |
|
|
//
|
10 |
|
|
// Date : $Date: 2008-03-06 13:51:55 $
|
11 |
|
|
//
|
12 |
|
|
// Workfile : hssdrc_define.vh
|
13 |
|
|
//
|
14 |
|
|
// Description : controller hardware paramters & settings
|
15 |
|
|
//
|
16 |
|
|
// HSSDRC is licensed under MIT License
|
17 |
|
|
//
|
18 |
|
|
// Copyright (c) 2007-2008, Denis V.Shekhalev (des00@opencores.org)
|
19 |
|
|
//
|
20 |
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
21 |
|
|
// this software and associated documentation files (the "Software"), to deal in
|
22 |
|
|
// the Software without restriction, including without limitation the rights to
|
23 |
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
24 |
|
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
25 |
|
|
// subject to the following conditions:
|
26 |
|
|
//
|
27 |
|
|
// The above copyright notice and this permission notice shall be included in all
|
28 |
|
|
// copies or substantial portions of the Software.
|
29 |
|
|
//
|
30 |
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
31 |
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
32 |
|
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
33 |
|
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
34 |
|
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
35 |
|
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
36 |
|
|
//
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
`ifndef __HSSDRC_DEFINE_VH__
|
40 |
|
|
|
41 |
|
|
`define __HSSDRC_DEFINE_VH__
|
42 |
|
|
|
43 |
|
|
//`define HSSDRC_DQ_PIPELINE // uncomment when need dq data register output
|
44 |
|
|
//`define HSSDRC_REFR_HI_DISABLE // uncomment when not need high priority refresh logic
|
45 |
|
|
//`define HSSDRC_REFR_LOW_DISABLE // uncomment when not need low priority refresh logic
|
46 |
|
|
//----------------------------------------------------------------------------------
|
47 |
|
|
// default : controller used use_wdata signal with register output type
|
48 |
|
|
// optionaly : controller can use combinative use_wdata signal which set 1 cycle early
|
49 |
|
|
//----------------------------------------------------------------------------------
|
50 |
|
|
//`define HSSDRC_COMBINATORY_USE_WDATA // uncomment when need to use non register use_wdata signal
|
51 |
|
|
//----------------------------------------------------------------------------------
|
52 |
|
|
// default : decoders sharing PRE & ACT command inside sdram command pipeline waiting
|
53 |
|
|
//----------------------------------------------------------------------------------
|
54 |
|
|
//`define HSSDRC_NOT_SHARE_ACT_COMMAND // uncomment for not generate logic for share ACT command
|
55 |
|
|
//----------------------------------------------------------------------------------
|
56 |
|
|
// default : 2 decoders sharing sdram command pipeline inside PRE & ACT command waiting
|
57 |
|
|
//----------------------------------------------------------------------------------
|
58 |
|
|
//`define HSSDRC_SHARE_ONE_DECODER // uncoment for only 1 decoder share
|
59 |
|
|
//`define HSSDRC_SHARE_NONE_DECODER // uncoment for none decoder share
|
60 |
|
|
//----------------------------------------------------------------------------------
|
61 |
|
|
// sdram controller command interface parameters
|
62 |
|
|
//----------------------------------------------------------------------------------
|
63 |
|
|
parameter int pRowaBits = 11; // >= 11 (0..10)
|
64 |
|
|
parameter int pColaBits = 8; // <= pRowBits
|
65 |
|
|
parameter int pBaBits = 2; // fixed == 2 (don't change !!!)
|
66 |
|
|
parameter int pBurstBits = 4; // <= 4
|
67 |
|
|
parameter int pChIdBits = 2; // >= 1
|
68 |
|
|
//----------------------------------------------------------------------------------
|
69 |
|
|
// sdram controller data interface & sdram chip data interface parameters
|
70 |
|
|
//----------------------------------------------------------------------------------
|
71 |
|
|
parameter int pDataBits = 32; // >= 8
|
72 |
|
|
parameter int pDatamBits = byte_lanes(pDataBits);
|
73 |
|
|
//----------------------------------------------------------------------------------
|
74 |
|
|
// sdram controller command interface parameters
|
75 |
|
|
//----------------------------------------------------------------------------------
|
76 |
|
|
parameter int pSdramAddrBits = 11; // (>= pRowaBits & >= 11)
|
77 |
|
|
parameter int pSdramBurstBits = 2; // fixed == 2 (don't change !!!)
|
78 |
|
|
parameter int cSdramBL = 2**pSdramBurstBits;
|
79 |
|
|
//----------------------------------------------------------------------------------
|
80 |
|
|
// sdram controller mode parameters (don't change except CL !!!!)
|
81 |
|
|
//----------------------------------------------------------------------------------
|
82 |
|
|
parameter bit pInitWBM = 1'b0; // write burst mode = programed burst
|
83 |
|
|
parameter bit [1:0] pInitOM = 1'b0; // operation mode = standart
|
84 |
|
|
parameter bit [2:0] pCL = 3'b011; // cas latency = 3
|
85 |
|
|
parameter bit pInitBT = 1'b0; // burst type = sequental
|
86 |
|
|
parameter bit [2:0] pInitBL = 3'b010; // burst = 4
|
87 |
|
|
|
88 |
|
|
parameter bit [pSdramAddrBits-1:10] pReserved = '0;
|
89 |
|
|
parameter bit [pSdramAddrBits-1: 0] cInitLmrValue = {pReserved, pInitWBM, pInitOM, pCL, pInitBT, pInitBL};
|
90 |
|
|
//----------------------------------------------------------------------------------
|
91 |
|
|
// used types
|
92 |
|
|
//----------------------------------------------------------------------------------
|
93 |
|
|
typedef logic [pColaBits - 1 : 0] cola_t;
|
94 |
|
|
typedef logic [pRowaBits - 1 : 0] rowa_t;
|
95 |
|
|
typedef logic [pBaBits - 1 : 0] ba_t;
|
96 |
|
|
typedef logic [pBurstBits - 1 : 0] burst_t;
|
97 |
|
|
typedef logic [pChIdBits - 1 : 0] chid_t;
|
98 |
|
|
typedef logic [pDataBits - 1 : 0] data_t;
|
99 |
|
|
typedef logic [pDatamBits - 1 : 0] datam_t;
|
100 |
|
|
|
101 |
|
|
typedef logic [pSdramAddrBits-1 :0] sdram_addr_t;
|
102 |
|
|
typedef logic [pSdramBurstBits-1:0] sdram_burst_t;
|
103 |
|
|
//----------------------------------------------------------------------------------
|
104 |
|
|
//
|
105 |
|
|
//----------------------------------------------------------------------------------
|
106 |
|
|
function automatic int clogb2 (input int data);
|
107 |
|
|
int i;
|
108 |
|
|
|
109 |
|
|
for (i = 0; 2**i < data; i++)
|
110 |
|
|
clogb2 = i + 1;
|
111 |
|
|
endfunction
|
112 |
|
|
//----------------------------------------------------------------------------------
|
113 |
|
|
//
|
114 |
|
|
//----------------------------------------------------------------------------------
|
115 |
|
|
function automatic int byte_lanes (input int data);
|
116 |
|
|
int num;
|
117 |
|
|
|
118 |
|
|
byte_lanes = 0;
|
119 |
|
|
|
120 |
|
|
num = data;
|
121 |
|
|
// synthesis translate_off
|
122 |
|
|
assert (num != 0) else $error ("wrong data parameter");
|
123 |
|
|
// synthesis translate_on
|
124 |
|
|
while (num > 0) begin
|
125 |
|
|
byte_lanes++;
|
126 |
|
|
num = num - 8;
|
127 |
|
|
end
|
128 |
|
|
|
129 |
|
|
endfunction
|
130 |
|
|
//----------------------------------------------------------------------------------
|
131 |
|
|
//
|
132 |
|
|
//----------------------------------------------------------------------------------
|
133 |
|
|
function automatic int unsigned max(input int unsigned a, b);
|
134 |
|
|
if (a >= b) max = a;
|
135 |
|
|
else max = b;
|
136 |
|
|
endfunction
|
137 |
|
|
|
138 |
|
|
`endif
|
139 |
|
|
|