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

Subversion Repositories hssdrc

[/] [hssdrc/] [trunk/] [rtl/] [hssdrc_addr_path.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
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:52:43 $ 
11
// 
12
// Workfile     : hssdrc_addr_path.v
13
// 
14
// Description  : coder for translate logical onehot command to sdram command
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
`include "hssdrc_timescale.vh"
40
 
41
`include "hssdrc_define.vh"
42
 
43
 
44
module hssdrc_addr_path(
45
  clk         ,
46
  reset       ,
47
  sclr        ,
48
  //        
49
  arb_pre_all ,
50
  arb_refr    ,
51
  arb_pre     ,
52
  arb_act     ,
53
  arb_read    ,
54
  arb_write   ,
55
  arb_lmr     ,
56
  arb_rowa    ,
57
  arb_cola    ,
58
  arb_ba      ,
59
  //
60
  addr        ,
61
  ba          ,
62
  cke         ,
63
  cs_n        ,
64
  ras_n       ,
65
  cas_n       ,
66
  we_n
67
  );
68
 
69
  input wire clk;
70
  input wire reset;
71
  input wire sclr;
72
 
73
  //-------------------------------------------------------------------------------------------------- 
74
  // interface from output arbiter 
75
  //-------------------------------------------------------------------------------------------------- 
76
 
77
  input wire    arb_pre_all  ;
78
  input wire    arb_refr     ;
79
  input wire    arb_pre      ;
80
  input wire    arb_act      ;
81
  input wire    arb_read     ;
82
  input wire    arb_write    ;
83
  input wire    arb_lmr      ;
84
  input rowa_t  arb_rowa     ;
85
  input cola_t  arb_cola     ;
86
  input ba_t    arb_ba       ;
87
 
88
  //-------------------------------------------------------------------------------------------------- 
89
  // interface to sdram 
90
  //-------------------------------------------------------------------------------------------------- 
91
 
92
  output  sdram_addr_t  addr;
93
  output  ba_t          ba;
94
  output  logic         cke;
95
  output  logic         cs_n;
96
  output  logic         ras_n;
97
  output  logic         cas_n;
98
  output  logic         we_n;
99
 
100
  //-------------------------------------------------------------------------------------------------- 
101
  //
102
  //--------------------------------------------------------------------------------------------------  
103
 
104
  logic [3:0] cs_n__ras_n__cas_n__we_n;
105
 
106
  // synthesis translate_off 
107
  wire [6:0] arb_cmd = {arb_pre_all, arb_refr, arb_pre, arb_act, arb_write, arb_read, arb_lmr};
108
  arb_cmd_assert : assert property (@(posedge clk) disable iff (reset) (arb_cmd !== 0) |-> $onehot(arb_cmd));
109
  // synthesis translate_on 
110
 
111
  always_comb begin : logical_command_decode
112
 
113
    cs_n__ras_n__cas_n__we_n = 4'b0111; // nop
114
 
115
    unique case (1'b1)
116
      arb_pre_all  : cs_n__ras_n__cas_n__we_n = 4'b0010; // Pre
117
      arb_refr     : cs_n__ras_n__cas_n__we_n = 4'b0001; // Refr
118
      arb_pre      : cs_n__ras_n__cas_n__we_n = 4'b0010; // Pre
119
      arb_act      : cs_n__ras_n__cas_n__we_n = 4'b0011; // Act
120
      arb_write    : cs_n__ras_n__cas_n__we_n = 4'b0100; // Write
121
      arb_read     : cs_n__ras_n__cas_n__we_n = 4'b0101; // Read
122
      arb_lmr      : cs_n__ras_n__cas_n__we_n = 4'b0000; // Lmr (data == address) 
123
      default      : begin end
124
    endcase
125
  end
126
 
127
  //
128
  // don't use clocking disable 
129
  //
130
 
131
  assign cke = 1'b1;
132
 
133
  // synthesis translate_off 
134
  initial begin
135
    {cs_n, ras_n, cas_n, we_n} <= 4'b1111;  // only to disable mt48lc2m warnings
136
  end
137
  // synthesis translate_on
138
 
139
  always_ff @(posedge clk or posedge reset) begin : sdram_control_register
140
    if (reset)      {cs_n, ras_n, cas_n, we_n} <= 4'b1111;  // inheribit nop
141
    else if (sclr)  {cs_n, ras_n, cas_n, we_n} <= 4'b1111;  // inheribit nop
142
    else            {cs_n, ras_n, cas_n, we_n} <= cs_n__ras_n__cas_n__we_n;
143
  end
144
 
145
  always_ff @(posedge clk) begin : sdram_mux_addr_path
146
 
147
    ba <= arb_ba;
148
 
149
    if (arb_act | arb_lmr)
150
      addr <= ResizeRowa(arb_rowa);
151
    else
152
      addr <= ResizeCola(arb_cola, arb_pre_all);
153
 
154
  end
155
 
156
  //-------------------------------------------------------------------------------------------------- 
157
  // function to get sdram address from row address. row address is transfered during 
158
  // act/lmr sdram command and is directly mapped to row address.
159
  //--------------------------------------------------------------------------------------------------  
160
 
161
  function sdram_addr_t ResizeRowa (input rowa_t rowa);
162
    int i;
163
    sdram_addr_t addr_resized;
164
 
165
    for (i = 0; i < pSdramAddrBits; i++) begin
166
      if (pRowaBits > i)
167
          addr_resized[i] = rowa[i];
168
        else
169
          addr_resized[i] = 1'b0;
170
    end
171
 
172
    return addr_resized;
173
  endfunction
174
 
175
  //--------------------------------------------------------------------------------------------------  
176
  // function to get sdram address from column address. column address is transfered during :
177
  // 1. read/write sdram command and A10 is autoprecharge bit and if pColaBits > 10 then 
178
  //    cola [$:10] is mapped to addr [$:11]. 
179
  // 2. pre sdram command and A10 is select all banks bit 
180
  //--------------------------------------------------------------------------------------------------  
181
 
182
  function sdram_addr_t ResizeCola (input cola_t cola, input bit pre_all);
183
    int i;
184
    sdram_addr_t addr_resized;
185
 
186
    for (i = 0; i < pSdramAddrBits; i++) begin
187
      if (i < 10) begin
188
        if (pColaBits > i)
189
          addr_resized[i] = cola[i];
190
        else
191
          addr_resized[i] = 1'b0;
192
      end
193
      else if (i == 10) begin
194
        addr_resized[i] = pre_all; // Autoprecharge is not used -> A10 is always 1'b0 then read/write active
195
      end
196
      else begin
197
        if (pColaBits > i)
198
          addr_resized[i] = cola[i-1];
199
        else
200
          addr_resized[i] = 1'b0;
201
      end
202
    end
203
 
204
    return addr_resized;
205
  endfunction
206
 
207
endmodule

powered by: WebSVN 2.1.0

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