Forum Discussion
Help with Flash memory reading
hi,
I am new to digital design and FPGAs, and I am having trouble with the flash Memory on the Cyclone II development board. I am playing around with a simple (6502) based cpu core (actually the FPGA64 commodore 64 emulator) and I am trying to use the flashRAM as a ROM. The addresses to the flash are being held steady for over 400ns but all I get back on the flash data lines is $FE, which never changes even when the address changes. I have a simple wave file exported from Signal TapII, along with the vhdl of my memory manger code which I will try to attach as a zip file. I wrote a simple verilog program to increment the memory address of the flash every two clock cycles (using the 27mhz clock), and that seemed to work just fine. I have no idea why this code doesn't work. I would really appreciate some input as I have read plenty but this is my first time using real physical hardware and I am struggling :( Thanks Simon :)18 Replies
- Altera_Forum
Honored Contributor
I guess, that the hardware is Cyclone II Starter Board. In this case, at least the FLASH_CE signal is missing from the SignalTap recording and also from the design. Without asserting CE low, no output from flash can be expected. Another question is which data has been programmed to flash.
- Altera_Forum
Honored Contributor
Yes I am using the Cyclone II starter kit.
The flash was 'burned' using their example control panel file that comes with the board. I used this to upload my raw data from my binary dump files, there are 3 images, one from $A000-$BFFF, one from $D000-$DFFF and one from $E000-$FFFF. I have checked the flash data both with the example control panel application and with a simple verilog program I wrote that simply set flash address to $F000 and incremented it every two clock cycles (27mhz clock). I checked the data that I got back from polling the flash data pins using signal tap II. On the cyclone II development board there does not appear to be a pin out for the flash CE signal. The reference documents give no pin number for its connection. Also their example starter file, while it does declare a FLASH_CE signal in the verilog header, has no matching pin assignment in the assignment file. I have not looked at the schematics but am guessing that this is held low all the time. I certainly would be interested if there is indeed a connection for this pin. Simon :) - Altera_Forum
Honored Contributor
I had checked the schematics before my reply. FLASH_CE is at pin AB15.
- Altera_Forum
Honored Contributor
Thank you, thank you, thank you, thank you. I have spent the last week frustrated on this problem!
It is now working. Yeah. I am mystified though why the reference documents are incorrect, and also the example files don't have a pin assignment for flash_ce_n. It always seemed weird to me looking through the docs because there was a ce signal for the other chips. Looking at the schematics it is tied to a pull up resistor, so I don't know why I was able to get my verilog code to work without specifying the flash_ce_n pin. I admit though that sometimes that code would work and sometimes it wouldn't, but I don't know why that would be though, seems like it would always be tri-stated. Anyway thanks again for the help, I am going to go study those schematics now..... Simon - Altera_Forum
Honored Contributor
The Altera documentation shows the flash part number as S29AL032DTFN.
Spansion data sheet shows the S29AL032DTFN only avaliable in the 90ns speed grade. If you are changing the address every 74ns(1/27MHz*2), you will not be meeting the specs of the flash device. Page 30 http://www.altera.com/literature/manual/mnl_cii_starter_board_rm.pdf Page 11 http://www.spansion.com/datasheets/s29al032d_00_a8_e.pdf - Altera_Forum
Honored Contributor
Hello,
I have a problem with the flash, too. I want to write an HEX-Code to the flash and after changing the position of the switch I want to read the code from the flash and give it out at the LED's. It have to be a simple programm for testing how I can work with the flash. I use the DE2-70 board with cyclone II an the flash is: S29GL064A90TFIR4 Here is my code: module TE1 ( Adress, Data, CE, OE, WE, WP, RESET, BYTE, LED, SW_OE, SW_WE, LEDG, LEDG2, LEDG3, CLK_50 ); input CLK_50; output [21:0] Adress; output CE; output OE; output WE; output WP; output RESET; output BYTE; output SW_OE; output SW_WE; output [15:0] LED; output LEDG; output LEDG2; output LEDG3; inout [15:0] Data; reg [15:0] LED; reg LEDG; reg LEDG2; reg LEDG3; reg [15:0] Data; reg OE; reg WE; assign Adress = 22'h000001; assign CE = 0; assign WP = 1; assign RESET = 1; assign BYTE = 1; always @(posedge CLK_50) begin if ((SW_OE == 0)) begin OE <= SW_OE; WE <= !SW_OE; Data <= 16'hBDE7; LEDG <= 1; end else if ((SW_OE == 1)) begin OE <= SW_OE; WE <= !SW_OE; LED <= Data; LEDG2 <= 1; end else LEDG3 <= 1; end endmodule when I load the programm at the board LEDG lights up an after changing the switch position nothing happens. The LEDG's are only to show where the programm stopps. Why did nothing else happen after changing the position of the switch?any idea? I'm from germany so say something if you dont understand what I mean!^^ thanks - Altera_Forum
Honored Contributor
I see several points why your code doesn't work as expected.
As a very general point, you can't write data to a flash memory by simply activating WE. Consult the flash datasheet at the DE2-70 system cd, you'll see that it's a rather complex action to write data to a flash. Basically it can be done in HDL code, but not in a few lines of code. As a more simple point, you're apparently using the flash control signals inverted. They are active low, shown by a# suffix in datasheet, but you set OE=1 and WE=0 and expect data at the data bus. I wonder if DE2-70 has suitable examples to evaluate such basic operations, but I'm not very familiar to the Terasic hardware or software. - Altera_Forum
Honored Contributor
yes sure... the flash datasheet says, for the write operation I need to set the pins as follow:
CE->0 OE->1 WE->0 WP->1 because I have nothing to protect RESET->1 for No Reset BYTE->1 for use the DATA -Bits DQ0 to DQ15 an these I have set... or what do you exactly mean? di I forgot something or missunderstand something? ok..."#" mean that they are active low...ok...that was something I don't know... so maybe the other pins are incorrect set... - Altera_Forum
Honored Contributor
--- Quote Start --- OE->1 WE->0 ... an these I have set --- Quote End --- you set the opposite polarity in the code below --- Quote Start --- if ((SW_OE == 0)) begin OE <= SW_OE; -- oe <= '0' WE <= !SW_OE; -- we <= '1' Data <= 16'hBDE7; --- Quote End --- As I said, this was the simple point. The other point is, that writing to the flash this way doesn't actually store anything in the memory array. - Altera_Forum
Honored Contributor
I changed the code completely because I have too much misstakes!^^
now these I have done: module test_veri( SW_OE, SW_WE, CLK_50, LEDG, CE, WP, RESET, BYTE, OE, WE, Adress, Data, LED ); input CLK_50; input SW_OE; input SW_WE; output [2:0] LEDG; output CE; output WP; output RESET; output BYTE; output OE; output WE; output [21:0] Adress; output [15:0] LED; inout [15:0] Data; reg [2:0] LEDG; reg [15:0] LED; reg [15:0] Data; assign CE = 0; assign WP = 1; assign RESET = 1; assign BYTE = 1; assign OE = SW_OE; assign WE = SW_WE; assign Adress = 1; always @(posedge CLK_50) begin if((SW_OE==0)&&(SW_WE==1)) begin LEDG = 3'b100; LED = Data; end else if ((SW_OE==1)&&(SW_WE==0)) begin LEDG = 3'b010; Data = 16'hBDE7; end else begin LEDG = 3'b001; LED = 0; end end endmodule is that what you mean with the OE and the WE? in the datasheet is wrote that for the read-operation for example the CE# has to be at Low, have it to be 1 or 0 ? its a little bit confusing. is it now right?^^ ok...and the other point...why would it not work?I mean...I have the read and write operation in it...what do I need else that it would work?