標(biāo)題: 如何以32 bit的方式存取SDRAM [打印本頁]

作者: 51黑黑黑    時間: 2016-2-23 03:35
標(biāo)題: 如何以32 bit的方式存取SDRAM
Abstract
在DE2因?yàn)橹挥幸活w16 bit的SDRAM,儘管Nios II CPU是32 bit,存取SDRAM時必須透過Dyanamic Bus Sizing機(jī)制,花2個clk才能將32 bit資料讀取/寫入SDRAM;但DE2-70有2顆16 bit SDRAM,是否使用雙通道的方式,將這2顆16 bit SDRAM看成1顆32 bit SDRAM使用呢?
  Introduction
這個做法是Mithril所提供,感謝Mithril無私的分享,我只是加以整理。
  使用環(huán)境:Quartus II 8.1 + DE2-70 (Cyclone II EP2C70F896C6N)
  在與DE2-70 CD中提供的範(fàn)例,如DE2_70_NET、DE2_70_NIOS_DEVICE_LED、DE2_70_NIOS_HOST_MOUSE_VGA、DE2_70_SD_Card_Audio_Player中,都是使用2個16 bit SDRAM controller,各自對應(yīng)到2顆SDRAM。
  
  不過可惜的是,SDRAM Controller的Data width只有16 bit,而Nios II CPU與其他ip都是32 bit,由於Data width不同,Avalon bus會啟動Dynamic Bus Sizing機(jī)制,2個clk才能完成32 bit傳輸。
  
  將2顆16 bit SDRAM當(dāng)成1顆32 bit SDRAM使用
Step 1:
只留下1個SDRAM controller即可

  
  Step 2:
Data width改成32 bit,其餘不用改

     
  注意結(jié)果仍為64MB,顯然沒有因?yàn)橹挥昧艘粋SDRAM controller而少抓memory size。
  DE2_70_NIOS.v / Verilog

  

Filename    : DE2_70_NIOS.v
  5Compiler    : Quartus II 8.1
  6Description : DE2_70_NIOS reference design 1.1
  7Release     : 11/25/2008 1.0
  8*/

DE2_70_NIOS (
11  input         iCLK_28,        // 28.63636 MHz
12  input         iCLK_50,        // 50 MHz
13  input         iCLK_50_2,      // 50 MHz
14  input         iCLK_50_3,      // 50 MHz
15  input         iCLK_50_4,      // 50 MHz
16  input         iEXT_CLOCK,     // External Clock
17  ////////////////////////////// Push Button ////////////////////////
18  input  [3:0]  iKEY,           // Pushbutton[3:0]
19  ////////////////////////////// DPDT Switch ////////////////////////
20  input  [17:0] iSW,            // Toggle Switch[17:0]
21  ////////////////////////////// 7-SEG Dispaly  ////////////////////////
22  output [6:0]  oHEX0_D,        // Seven Segment Digit 0
23  output        oHEX0_DP,       // Seven Segment Digit 0 decimal point
24  output [6:0]  oHEX1_D,        // Seven Segment Digit 1
25  output        oHEX1_DP,       // Seven Segment Digit 1 decimal point
26  output [6:0]  oHEX2_D,        // Seven Segment Digit 2
27  output        oHEX2_DP,       // Seven Segment Digit 2 decimal point
28  output [6:0]  oHEX3_D,        // Seven Segment Digit 3
29  output        oHEX3_DP,       // Seven Segment Digit 3 decimal point
30  output [6:0]  oHEX4_D,        // Seven Segment Digit 4
31  output        oHEX4_DP,       // Seven Segment Digit 4 decimal point
32  output [6:0]  oHEX5_D,        // Seven Segment Digit 5
33  output        oHEX5_DP,       // Seven Segment Digit 5 decimal point
34  output [6:0]  oHEX6_D,        // Seven Segment Digit 6
35  output        oHEX6_DP,       // Seven Segment Digit 6 decimal point
36  output [6:0]  oHEX7_D,        // Seven Segment Digit 7
37  output        oHEX7_DP,       // Seven Segment Digit 7 decimal point
38  //////////////////////////////// LED ////////////////////////////
39  output [8:0]  oLEDG,          // LED Green[8:0]
40  output [17:0] oLEDR,          // LED Red[17:0]
41  //////////////////////////////// UART ////////////////////////////
42  output        oUART_TXD,      // UART Transmitter
43  input         iUART_RXD,      // UART Receiver
44  output        oUART_CTS,      // UART Clear To Send
45  input         iUART_RTS,      // UART Requst To Send
46  //////////////////////////////// IRDA ////////////////////////////
47  output        oIRDA_TXD,      // IRDA Transmitter
48  input         iIRDA_RXD,      // IRDA Receiver
49  //////////////////////////////// SDRAM Interface ////////////////////////
50  inout  [31:0] DRAM_DQ,        // SDRAM Data bus 32 Bits
51  output [12:0] oDRAM0_A,       // SDRAM0 Address bus 12 Bits
52  output [12:0] oDRAM1_A,       // SDRAM1 Address bus 12 Bits
53  output        oDRAM0_LDQM0,   // SDRAM0 Low-byte Data Mask
54  output        oDRAM1_LDQM0,   // SDRAM1 Low-byte Data Mask
55  output        oDRAM0_UDQM1,   // SDRAM0 High-byte Data Mask
56  output        oDRAM1_UDQM1,   // SDRAM1 High-byte Data Mask
57  output        oDRAM0_WE_N,    // SDRAM0 Write Enable
58  output        oDRAM1_WE_N,    // SDRAM1 Write Enable
59  output        oDRAM0_CAS_N,   // SDRAM0 Column Address Strobe
60  output        oDRAM1_CAS_N,   // SDRAM1 Column Address Strobe
61  output        oDRAM0_RAS_N,   // SDRAM0 Row Address Strobe
62  output        oDRAM1_RAS_N,   // SDRAM1 Row Address Strobe
63  output        oDRAM0_CS_N,    // SDRAM0 Chip Select
64  output        oDRAM1_CS_N,    // SDRAM1 Chip Select
65  output [1:0]  oDRAM0_BA,      // SDRAM0 Bank Address
66  output [1:0]  oDRAM1_BA,      // SDRAM1 Bank Address
67  output        oDRAM0_CLK,     // SDRAM0 Clock
68  output        oDRAM1_CLK,     // SDRAM0 Clock
69  output        oDRAM0_CKE,     // SDRAM0 Clock Enable
70  output        oDRAM1_CKE,     // SDRAM1 Clock Enable
71  //////////////////////////////// Flash Interface ////////////////////////
72  inout  [14:0] FLASH_DQ,       // FLASH Data bus 15 Bits (0 to 14)
73  inout         FLASH_DQ15_AM1, // FLASH Data bus Bit 15 or Address A-1
74  output [25:0] oFLASH_A,       // FLASH Address bus 26 Bits
75  output        oFLASH_WE_N,    // FLASH Write Enable
76  output        oFLASH_RST_N,   // FLASH Reset
77  output        oFLASH_WP_N,    // FLASH Write Protect /Programming Acceleration
78  input         iFLASH_RY_N,    // FLASH Ready/Busy output
79  output        oFLASH_BYTE_N,  // FLASH Byte/Word Mode Configuration
80  output        oFLASH_OE_N,    // FLASH Output Enable
81  output        oFLASH_CE_N,    // FLASH Chip Enable
82  //////////////////////////////// SRAM Interface ////////////////////////
83  inout  [31:0] SRAM_DQ,        // SRAM Data Bus 32 Bits
84  inout  [3:0]  SRAM_DPA,       // SRAM Parity Data Bus
85  output [20:0] oSRAM_A,        // SRAM Address bus 21 Bits
86  output        oSRAM_ADSC_N,   // RAM Controller Address Status     
87  output        oSRAM_ADSP_N,   // SRAM Processor Address Status
88  output        oSRAM_ADV_N,    // SRAM Burst Address Advance
89  output [3:0]  oSRAM_BE_N,     // SRAM Byte Write Enable
90  output        oSRAM_CE1_N,    // SRAM Chip Enable
91  output        oSRAM_CE2,      // SRAM Chip Enable
92  output        oSRAM_CE3_N,    // SRAM Chip Enable
93  output        oSRAM_CLK,      // SRAM Clock
94  output        oSRAM_GW_N,     // SRAM Global Write Enable
95  output        oSRAM_OE_N,     // SRAM Output Enable
96  output        oSRAM_WE_N,     // SRAM Write Enable
97  //////////////////////////////// ISP1362 Interface ////////////////////////
98  inout  [15:0] OTG_D,          // ISP1362 Data bus 16 Bits
99  output [1:0]  oOTG_A,         // ISP1362 Address 2 Bits
100  output        oOTG_CS_N,      // ISP1362 Chip Select
101  output        oOTG_OE_N,      // ISP1362 Read
102  output        oOTG_WE_N,      // ISP1362 Write
103  output        oOTG_RESET_N,   // ISP1362 Reset
104  inout         OTG_FSPEED,     // USB Full Speed, 0 = Enable, Z = Disable
105  inout         OTG_LSPEED,     // USB Low Speed,     0 = Enable, Z = Disable
106  input         iOTG_INT0,      // ISP1362 Interrupt 0
107  input         iOTG_INT1,      // ISP1362 Interrupt 1
108  input         iOTG_DREQ0,     // ISP1362 DMA Request 0
109  input         iOTG_DREQ1,     // ISP1362 DMA Request 1
110  output        oOTG_DACK0_N,   // ISP1362 DMA Acknowledge 0
111  output        oOTG_DACK1_N,   // ISP1362 DMA Acknowledge 1
112  //////////////////////////////// LCD Module 16X2 ////////////////////////////
113  inout  [7:0]  LCD_D,          // LCD Data bus 8 bits
114  output        oLCD_ON,        // LCD Power ON/OFF
115  output        oLCD_BLON,      // LCD Back Light ON/OFF
116  output        oLCD_RW,        // LCD Read/Write Select, 0 = Write, 1 = Read
117  output        oLCD_EN,        // LCD Enable
118  output        oLCD_RS,        // LCD Command/Data Select, 0 = Command, 1 = Data
119  //////////////////////////////// SD Card Interface ////////////////////////
120  inout         SD_DAT,         // SD Card Data
121  inout         SD_DAT3,        // SD Card Data 3
122  inout         SD_CMD,         // SD Card Command Signal
123  output        oSD_CLK,        // SD Card Clock
124  //////////////////////////////// I2C ////////////////////////////////
125  inout         I2C_SDAT,       // I2C Data
126  output        oI2C_SCLK,      // I2C Clock
127  //////////////////////////////// PS2 ////////////////////////////
128  inout         PS2_KBDAT,      // PS2 Keyboard Data
129  inout         PS2_KBCLK,      // PS2 Keyboard Clock
130  inout         PS2_MSDAT,      // PS2 Mouse Data
131  inout         PS2_MSCLK,      // PS2 Mouse Clock
132  //////////////////////////////// VGA ////////////////////////////
133  output        oVGA_CLOCK,     // VGA Clock
134  output        oVGA_HS,        // VGA H_SYNC
135  output        oVGA_VS,        // VGA V_SYNC
136  output        oVGA_BLANK_N,   // VGA BLANK
137  output        oVGA_SYNC_N,    // VGA SYNC
138  output [9:0]  oVGA_R,         // VGA Red[9:0]
139  output [9:0]  oVGA_G,         // VGA Green[9:0]
140  output [9:0]  oVGA_B,         // VGA Blue[9:0]
141  //////////////////////////////// Ethernet Interface ////////////////////////////
142  inout  [15:0] ENET_D,         // DM9000A DATA bus 16Bits
143  output        oENET_CMD,      // DM9000A Command/Data Select, 0 = Command, 1 = Data
144  output        oENET_CS_N,     // DM9000A Chip Select
145  output        oENET_IOW_N,    // DM9000A Write
146  output        oENET_IOR_N,    // DM9000A Read
147  output        oENET_RESET_N,  // DM9000A Reset
148  input         iENET_INT,      // DM9000A Interrupt
149  output        oENET_CLK,      // DM9000A Clock 25 MHz
150  //////////////////////////////// Audio CODEC ////////////////////////////
151  inout         AUD_ADCLRCK,    // Audio CODEC ADC LR Clock
152  input         iAUD_ADCDAT,    // Audio CODEC ADC Data
153  inout         AUD_DACLRCK,    // Audio CODEC DAC LR Clock
154  output        oAUD_DACDAT,    // Audio CODEC DAC Data
155  inout         AUD_BCLK,       // Audio CODEC Bit-Stream Clock
156  output        oAUD_XCK,       // Audio CODEC Chip Clock
157  //////////////////////////////// TV Devoder ////////////////////////////
158  input         iTD1_CLK27,     // TV Decoder1 Line_Lock Output Clock
159  input  [7:0]  iTD1_D,         // TV Decoder1 Data bus 8 bits
160  input         iTD1_HS,        // TV Decoder1 H_SYNC
161  input         iTD1_VS,        // TV Decoder1 V_SYNC
162  output        oTD1_RESET_N,   // TV Decoder1 Reset
163  input         iTD2_CLK27,     // TV Decoder2 Line_Lock Output Clock         
164  input  [7:0]  iTD2_D,         // TV Decoder2 Data bus 8 bits
165  input         iTD2_HS,        // TV Decoder2 H_SYNC
166  input         iTD2_VS,        // TV Decoder2 V_SYNC
167  output        oTD2_RESET_N,   // TV Decoder2 Reset
168  //////////////////////////////// GPIO ////////////////////////////////
169  inout  [31:0] GPIO_0,         // GPIO Connection 0 I/O
170  input         GPIO_CLKIN_N0,  // GPIO Connection 0 Clock Input 0
171  input         GPIO_CLKIN_P0,  // GPIO Connection 0 Clock Input 1
172  output        GPIO_CLKOUT_N0, // GPIO Connection 0 Clock Output 0
173  output        GPIO_CLKOUT_P0, // GPIO Connection 0 Clock Output 1
174  inout  [31:0] GPIO_1,         // GPIO Connection 1 I/O
175  input         GPIO_CLKIN_N1,  // GPIO Connection 1 Clock Input 0
176  input         GPIO_CLKIN_P1,  // GPIO Connection 1 Clock Input 1
177  output        GPIO_CLKOUT_N1, // GPIO Connection 1 Clock Output 0
178  output        GPIO_CLKOUT_P1  // PIO Connection 1 Clock Output 1

181// All inout port turn to tri-state
182assign SD_DAT      =1'bz;
183assign GPIO_0      =32'hzzzzzzzzz;
184assign GPIO_1      =32'hzzzzzzzzz;
185assign AUD_ADCLRCK =1'bz;


188assign oTD1_RESET_N =1'bz;
189assign oTD2_RESET_N =1'bz;





195assign oLCD_ON   =1'b1; // LCD ON
196assign oLCD_BLON =1'b1; // LCD Back Light

198// Disable USB speed select




FLASH_16BIT_IP_A0;
204assign oFLASH_BYTE_N =1'b1; // FLASH Byte/Word Mode Configuration
205assign oFLASH_RST_N  =1'b1; // FLASH Reset
206assign oFLASH_WP_N   =1'b1; // FLASH Write Protect /Programming Acceleration


SRAM_CLK;
210wire [1:0] SRAM_DUMMY_ADDR;         // used to ignore the A0/A1 pin from Cypress SSRAM IP core

212assign oSRAM_ADSP_N =1'b1;         // SRAM Processor Address Status
213assign oSRAM_ADV_N  =1'b1;         // SRAM Burst Address Advance
214assign oSRAM_CE2    =~oSRAM_CE1_N; // SRAM Chip Enable
215assign oSRAM_CE3_N  = oSRAM_CE1_N;  // SRAM Chip Enable
216assign oSRAM_GW_N   =1'b1;         // SRAM Global Write Enable

SDRAM
220// the sdram is shahred with rtl and nios
        dram_cs_n;
226wire [3:0

231assign oDRAM0_CLK = SRAM_CLK;        // SDRAM0 Clock
232assign oDRAM1_CLK = SRAM_CLK;        // SDRAM1 Clock

dram_a;
235assign oDRAM0_BA    = dram_ba;
236assign oDRAM0_CAS_N = dram_cas_n;
237assign oDRAM0_CKE   = dram_cke;
238assign oDRAM0_CS_N  = dram_cs_n;
239assign oDRAM0_LDQM0 = dram_dqm[0];
240assign oDRAM0_UDQM1 = dram_dqm[1 dram_ras_n;
242assign oDRAM0_WE_N  =

dram_a;
246assign oDRAM1_BA    = dram_ba;
247assign oDRAM1_CAS_N = dram_cas_n;
248assign oDRAM1_CKE   = dram_cke;
249assign oDRAM1_CS_N  = dram_cs_n;
250assign oDRAM1_LDQM0 = dram_dqm[2];
251assign oDRAM1_UDQM1 = dram_dqm[3 dram_ras_n;
253assign oDRAM1_WE_N  =

256assign OTG_FSPEED =1'bz; // USB Full Speed, 0 = Enable, Z = Disable
257assign OTG_LSPEED =1'bz; // USB Low Speed,  0 = Enable, Z = Disable



iCLK_50)
263  iCLK_25 <=~


Reset_Delay delay0 (
270  .iRST(iKEY[0

nios_ii nios_ii0 (
277  // 1) global signals:
  .pll_c0_system(CPU_CLK),
280  .pll_c1_memory(SRAM_CLK),
281  .pll_c2_audio(oAUD_XCK),
282  .clk_25(iCLK_25),
284  // the_DM9000A_IF_0
  .avs_s1_export_ENET_CLK_from_the_DM9000A(oENET_CLK),
286  .avs_s1_export_ENET_CMD_from_the_DM9000A(oENET_CMD),
287  .avs_s1_export_ENET_CS_N_from_the_DM9000A(oENET_CS_N),
288  .avs_s1_export_ENET_DATA_to_and_from_the_DM9000A(ENET_D),
289  .avs_s1_export_ENET_INT_to_the_DM9000A(iENET_INT),
290  .avs_s1_export_ENET_RD_N_from_the_DM9000A(oENET_IOR_N),
291  .avs_s1_export_ENET_RST_N_from_the_DM9000A(oENET_RESET_N),
292  .avs_s1_export_ENET_WR_N_from_the_DM9000A(oENET_IOW_N),
293  // the_ISP1362
  .avs_hc_export_OTG_ADDR_from_the_ISP1362(oOTG_A),
295  .avs_hc_export_OTG_CS_N_from_the_ISP1362(oOTG_CS_N),
296  .avs_hc_export_OTG_DATA_to_and_from_the_ISP1362(OTG_D),
297  .avs_hc_export_OTG_INT0_to_the_ISP1362(iOTG_INT0),
298  .avs_hc_export_OTG_RD_N_from_the_ISP1362(oOTG_OE_N),
299  .avs_hc_export_OTG_RST_N_from_the_ISP1362(oOTG_RESET_N),
300  .avs_hc_export_OTG_WR_N_from_the_ISP1362(oOTG_WE_N),
301  .avs_dc_export_OTG_INT1_to_the_ISP1362(iOTG_INT1),
302  // the_audio
  .avs_s1_export_BCLK_to_the_AUDIO(AUD_BCLK),
304  .avs_s1_export_DACLRC_to_the_AUDIO(AUD_DACLRCK),
305  .avs_s1_export_DACDAT_from_the_AUDIO(oAUD_DACDAT),
306  .avs_s1_export_ADCLRC_to_the_AUDIO(AUD_ADCLRCK),
307  .avs_s1_export_ADCDAT_to_the_AUDIO(iAUD_ADCDAT),
308  // the_i2c_sclk
  .out_port_from_the_i2c_sclk(oI2C_SCLK),
310  // the_i2c_sdat
  .bidir_port_to_and_from_the_i2c_sdat(I2C_SDAT),
312  // the_lcd
  .LCD_E_from_the_lcd(oLCD_EN),
314  .LCD_RS_from_the_lcd(oLCD_RS),
315  .LCD_RW_from_the_lcd(oLCD_RW),
316  .LCD_data_to_and_from_the_lcd(LCD_D),
317  // the_pio_button
  .in_port_to_the_pio_button(iKEY),
319  // the_pio_green_led
  .out_port_from_the_pio_green_led(oLEDG),
321  // the_pio_red_led
  .out_port_from_the_pio_red_led(oLEDR),
323  // the_seg7  
  .avs_s1_export_seg7_from_the_SEG7({oHEX7_DP, oHEX7_D, oHEX6_DP, oHEX6_D, oHEX5_DP,
325    oHEX5_D, oHEX4_DP,oHEX4_D, oHEX3_DP, oHEX3_D, oHEX2_DP, oHEX2_D, oHEX1_DP, oHEX1_D,
326    oHEX0_DP, oHEX0_D}),
327  // the_pio_switch
  .in_port_to_the_pio_switch(iSW),
329  // the_sd_clk
  .out_port_from_the_sd_clk(oSD_CLK),
331  // the_sd_cmd
  .bidir_port_to_and_from_the_sd_cmd(SD_CMD),
333  // the_sd_dat
  .bidir_port_to_and_from_the_sd_dat(SD_DAT),
335  // the_sd_dat3
  .bidir_port_to_and_from_the_sd_dat3(SD_DAT3),
337  // the_sdram (u1)
  .zs_addr_from_the_sdram_u1(dram_a),
339  .zs_ba_from_the_sdram_u1(dram_ba),
340  .zs_cas_n_from_the_sdram_u1(dram_cas_n),
341  .zs_cke_from_the_sdram_u1(dram_cke),
342  .zs_cs_n_from_the_sdram_u1(dram_cs_n),
343  .zs_dq_to_and_from_the_sdram_u1(DRAM_DQ),
344  .zs_dqm_from_the_sdram_u1(dram_dqm),
345  .zs_ras_n_from_the_sdram_u1(dram_ras_n),
346  .zs_we_n_from_the_sdram_u1(dram_we_n),
347  // the_tristate_bridge_avalon_slave (flash)
348  .address_to_the_cfi_flash({oFLASH_A[21:0  .data_to_and_from_the_cfi_flash({FLASH_DQ15_AM1,FLASH_DQ}),
350  .read_n_to_the_cfi_flash(oFLASH_OE_N),
351  .select_n_to_the_cfi_flash(oFLASH_CE_N),
352  .write_n_to_the_cfi_flash(oFLASH_WE_N),
353  // the_tristate_bridge_1_avalon_slave (ssram)
354  .address_to_the_ssram({oSRAM_A[17:0  .adsc_n_to_the_ssram(oSRAM_ADSC_N),
356  .bw_n_to_the_ssram(oSRAM_BE_N),
357  .bwe_n_to_the_ssram(oSRAM_WE_N),
358  .chipenable1_n_to_the_ssram(oSRAM_CE1_N),
359  .data_to_and_from_the_ssram((SRAM_DQ)),
360  .outputenable_n_to_the_ssram(oSRAM_OE_N),
361  // the_uart
  .cts_n_to_the_uart(oUART_CTS),
363  .rts_n_from_the_uart(iUART_RTS),
364  .rxd_to_the_uart(iUART_RXD),
365  .txd_from_the_uart(oUART_TXD),
366

  
219行
  // SDRAM
// the sdram is shahred with rtl and nios

assign oDRAM0_CLK = SRAM_CLK;        // SDRAM0 Clock
assign oDRAM1_CLK = SRAM_CLK;        // SDRAM1 Clock

dram_a;
assign oDRAM0_BA    = dram_ba;
assign oDRAM0_CAS_N = dram_cas_n;
assign oDRAM0_CKE   = dram_cke;
assign oDRAM0_CS_N  = dram_cs_n;
assign oDRAM0_LDQM0 = dram_dqm[0];
assign oDRAM0_UDQM1 = dram_dqm[1 dram_ras_n;
assign oDRAM0_WE_N  =
dram_a;
assign oDRAM1_BA    = dram_ba;
assign oDRAM1_CAS_N = dram_cas_n;
assign oDRAM1_CKE   = dram_cke;
assign oDRAM1_CS_N  = dram_cs_n;
assign oDRAM1_LDQM0 = dram_dqm[2];
assign oDRAM1_UDQM1 = dram_dqm[3 dram_ras_n;
assign oDRAM1_WE_N  = dram_we_n;
  
宣告從SOPC的SDRAM port所連出的wire,並且連到top module的SDRAM port。
  關(guān)鍵在於DRAM_DQ是個inout [31:0],不能設(shè)成wire,必須要直接從SOPC接出來,我第一次就是這樣失敗的。
  337行

  
.zs_addr_from_the_sdram_u1(dram_a),
.zs_ba_from_the_sdram_u1(dram_ba),
.zs_cas_n_from_the_sdram_u1(dram_cas_n),
.zs_cke_from_the_sdram_u1(dram_cke),
.zs_cs_n_from_the_sdram_u1(dram_cs_n),
.zs_dq_to_and_from_the_sdram_u1(DRAM_DQ),
.zs_dqm_from_the_sdram_u1(dram_dqm),
.zs_ras_n_from_the_sdram_u1(dram_ras_n),
.zs_we_n_from_the_sdram_u1(dram_we_n),

  
從SOPC的SDRAM port連出的wire。
  證明這種方式的正確性
從三個方式來證明:
1.執(zhí)行Hello World project template,並將Nios II程式跑在SDRAM上。
2.執(zhí)行Hello MicroC/OS-II project template,並將Nios II程式跑在SDRAM上。
3.執(zhí)行Memory Test project template,證明64MB SDRAM皆可正常存取。
  1.Hello World
  
  執(zhí)行結(jié)果
  
  2.Hello MicroC/OS-II
  
  執(zhí)行結(jié)果
  
  3.Memory Test
儘管能順利的在SDRAM執(zhí)行Hello World與Hello MicroC/OS-II,還是很令人擔(dān)心這種方式是否能正確的存取DE2-70的64MB SDRAM,為了客觀起見,我們使用了Nios II內(nèi)建的Memory Test project template。
  Step 1:
使用Memory Test project template

  
  Step 2:
將Nios II跑在SSRAM

  因?yàn)镾DRAM即將接受測試,所以將Nios II程式跑在SSRAM上
  
  
  因?yàn)橐獪y試SDRAM,所以輸入a繼續(xù)。
  
  接著要我們輸入要測試的memory起始位置與結(jié)束位置,該怎麼填呢?回想一下SOPC Builder怎麼對SDRAM定址。
  
  根據(jù)SOPC Builder,0x04000000為SDRAM的起始位置,0x07ffffff為結(jié)束位置。
  執(zhí)行結(jié)果
  
  證明64MB SDRAM通過測試。
  Conclusion
或許有些人喜歡將2顆SDRAM分開使用,甚至有人1顆SDRAM是掛在Avalon bus上,另外1顆直接使用Sdram_Control_4Port控制;這就類似有人喜歡一顆硬碟分割成好幾個磁區(qū),也有人喜歡將好幾顆硬碟合併成一顆使用。不過以傳輸來說,既然Nios II CPU是32 bit,所有的ip都是32 bit,SDRAM的16 bit反而是傳輸上的瓶頸,透過本文雙通道的方式,將2顆16 bit SDRAM合併成1顆32 bit SDRAM使用,可以讓整個系統(tǒng)順暢的以32 bit運(yùn)行,不再需要Avalon bus的Dynamic Bus Sizing機(jī)制,充分發(fā)揮DE2-70兩顆SDRAM的優(yōu)勢。






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1