Flash debugging of diy_de2

Source: Internet
Author: User

One 8 Mb parallel flash memory is used in diy_de2. The flash operation methods can be divided into hardware debugging and software debugging.

Debugging environment: Quartus II 9.0 + niosii 9.0

1. hardware debugging

Perform operations based on The Datasheet of flash in the following way,

Such as Erasure:

Module flash_erase (
Clock_50,
Flash_d,
Flash_a,
Flash_we,
Flash_ce,
Flash_oe,
Flash_rst,
LED
);
Input clock_50;
// Output [7: 0] odata;
Inout [7:0] flash_d;
Output [21:0] flash_a;
Output flash_we, flash_ce, flash_oe, flash_rst, led;

// Reg [7: 0] odata;
Reg [21:0] flash_a;
Reg [10: 0] I;
Reg [7:0] data_out;
Reg flash_we, flash_ce, flash_oe, flash_rst;
Wire [7: 0] led;

Initial
Begin
Flash_ce <= 0;
Flash_rst <= 1;
Flash_we <= 1;
Flash_oe <= 1;
Data_out <= 8 'hzz;
End

Assign flash_d = data_out;
Assign led = flash_d;

Always @ (posedge clock_50)
Begin
If (I <29)
I <= I + 1 'b1;
If (I <= 1) // The first cycle
Begin
Flash_a <= 22 'haaa;
// Data_out <= 8' haa;
End
If (I <= 2)
Flash_we <= 0;
If (I <= 3)
Data_out <= 8' haa;
If (I <= 4)
Flash_we <= 1;
// If (I <= 5)
// Data_out <= 8 'hzz;

If (I <= 6) // The second cycle
Begin
Flash_a <= 22 'h555;
// Data_out <= 8 'h55;
End
If (I <= 7)
Flash_we <= 0;
If (I <= 8)
Data_out <= 8'h55;
If (I <= 9)
Flash_we <= 1;
// If (I <= 10)
// Data_out <= 8 'hzz;

If (I <= 11) // The third cycle
Begin
Flash_a <= 22 'haaa;
// Data_out <= 8' ha0;
End
If (I <= 12)
Flash_we <= 0;
If (I <= 13)
Data_out <= 8'h80;
If (I <= 14)
Flash_we <= 1;


If (I <= 15) // The forth cycle
Begin
Flash_a <= 22 'haaa;
// Data_out <= 8' haa;
End
If (I <= 16)
Flash_we <= 0;
If (I <= 17)
Data_out <= 8' haa;
If (I <= 18)
Flash_we <= 1;
// If (I <= 5)
// Data_out <= 8 'hzz;

If (I <= 19) // The th cycle
Begin
Flash_a <= 22 'h555;
// Data_out <= 8 'h55;
End
If (I <= 20)
Flash_we <= 0;
If (I <= 21)
Data_out <= 8'h55;
If (I <= 22)
Flash_we <= 1;

If (I <= 23)
Begin
Flash_a [] <= 6 'h000000; // sector sa0
// Flash_a <= 22 'h200000;
// Flash_a <= 22 'haaa;
// Data_out <= 8 'h55;
End
If (I <= 24)
Flash_we <= 0;
If (I <= 25)
Data_out <= 8'h30;
If (I <= 26)
Flash_we <= 1;

/* If (I <= 27)
Flash_oe <= 0;
If (I <= 28)
Begin
Flash_oe <= 1;
Odata <= flash_d;
End
*/
End

Endmodule

Read/write operations:

Module flash_write (
Clock_50,
Flash_d,
Flash_a,
Flash_we,
Flash_ce,
Flash_oe,
Flash_reset,
LED
);
Input clock_50;
Inout [7:0] flash_d;
Output [21:0] flash_a;
Output flash_we, flash_ce, flash_oe, flash_reset;
Output led;

Reg [7:0] odata;
Reg [21:0] flash_a;
Reg [10: 0] I;
Reg [7:0] data_out;
Reg flash_we, flash_ce, flash_oe, flash_reset;
Wire [7: 0] led;

Initial
Begin
Flash_ce = 0;
Flash_reset = 1;
Flash_we = 1;
Flash_oe = 1;
Data_out = 8 'hzz;
End

Assign flash_d = data_out;
Assign led = odata;

Always @ (posedge clock_50)
Begin
If (I <941)
Begin
I <= I + 1 'b1;
If (I = 1) // program command 1
Begin
Flash_a <= 22 'haaa;
End
If (I = 2)
Flash_we <= 0;
If (I = 3)
Data_out <= 8' haa;
If (I = 4)
Flash_we <= 1;
// If (I = 5)
// Data_out <= 8 'hzz;

If (I = 6) // program command 2
Begin
Flash_a <= 22 'h555;
End
If (I = 7)
Flash_we <= 0;
If (I = 8)
Data_out <= 8'h55;
If (I = 9)
Flash_we <= 1;
// If (I = 10)
// Data_out <= 8 'hzz;

If (I = 11) // program command 3
Begin
Flash_a <= 22 'haaa;
End
If (I = 12)
Flash_we <= 0;
If (I = 13)
Data_out <= 8' ha0;
If (I = 14)
Flash_we <= 1;

If (I = 15) // write the first byte
Begin
Flash_a <= 22 'h00001;
End
If (I = 16)
Flash_we <= 0;
If (I = 17)
Data_out <= 8' H66;
If (I = 18)
Flash_we <= 1;
/*
If (I = 19) // program command 1
Begin
Flash_a <= 22 'haaa;
End
If (I = 20)
Flash_we <= 0;
If (I = 21)
Data_out <= 8' haa;
If (I = 22)
Flash_we <= 1;
// If (I = 5)
// Data_out <= 8 'hzz;

If (I = 23) // program command 2
Begin
Flash_a <= 22 'h555;
End
If (I = 24)
Flash_we <= 0;
If (I = 25)
Data_out <= 8'h55;
If (I = 26)
Flash_we <= 1;
// If (I = 10)

If (I = 27) // program command 3
Begin
Flash_a <= 22 'haaa;
End
If (I = 28)
Flash_we <= 0;
If (I = 29)
Data_out <= 8' ha0;
If (I = 30)
Flash_we <= 1;


If (I = 31) // write the second byte
Begin
Flash_a <= 22 'h200002;
End
If (I = 32)
Flash_we <= 0;
If (I = 33)
Data_out <= 8' HBB;
If (I = 34)
Flash_we <= 1;
If (I = 35)
Data_out <= 8 'hzz;
*/
If (I = 36) // read the first byte
Flash_a <= 22 'h1;
If (I = 37)
Flash_oe <= 0;
If (I = 38)
Begin
Flash_oe <= 1;
Odata <= flash_d;
End

/*
If (I = 338) // read the second byte
Flash_a <= 22 'h4;
If (I = 339)
Flash_oe <= 0;
If (I = 340)
Begin
Flash_oe <= 1;
Odata <= flash_d;
End

If (I = 638) // read the third byte
Flash_a <= 22 'h5;
If (I = 639)
Flash_oe <= 0;
If (I = 640)
Begin
Flash_oe <= 1;
Odata <= flash_d;
End


If (I = 938) // read the forth byte
Flash_a <= 22 'h1;
If (I = 939)
Flash_oe <= 0;
If (I = 940)
Begin
Flash_oe <= 1;
Odata <= flash_d;
End
*/

End
End

Endmodule

Complete the basic flash operations through the above operations.

 

2. Software Debugging

This part can also be tested on flash with the help of the niosii soft-core system. There are two methods:

I. Use the soft check flash for erasure and read/write operations

When this method is debugged, an error message is displayed:

 

Ii. soft CoresProgramSolidified in Flash

The soft core program is solidified in flash and powered on again. If the system can be started normally and the program runs normally, flash debugging is successful.

Flash burning method:

Add the download. Sof option directly on the flash burning interface, and burn the configuration file and FLASH file to the corresponding memory. As shown in.

If the configuration file. Sof is not downloaded before flash writing, the following error occurs.

If the configuration file. POF or. JIC is downloaded before flash writing, the following error occurs.

 

Problems:

1. Virtual soldering and virtual soldering lead to poor pin contact, which is also the most important reason;

 

PS: hardware debugging and software debugging projects have been uploaded.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.