Forum Discussion
32-bit SSRAM must have byteenable for Nios II?
One question -
For 32-bit external SSRAM (or async. SRAM), does it have to have byte write mode enabled in order to work with Nios II processor? In other words, can Nios II handle all instructions and data exclusively in 32-bit mode? If my program uses data type of 16-bit or 8-bit, how is it handled if I don't have byte mode enabled? How about 16-bit external memory? Can it work with Nios without byte write mode enabled? Thanks for your help in advance!!!12 Replies
- Altera_Forum
Honored Contributor
I know it's a bit old thread but still... Byteenable's for NIOS are important if you're using EPCS or equivalent device to boot FPGA and SW code. Since Flash devices(serial) are usually 8 bit wide, the bootloader packs the SSRAM using byte enables... so if you don't have them connected or misconnected the processor will fail to run although the FPGA boots correctly.
- Altera_Forum
Honored Contributor
FWIW, a late follow up: the most recent version of YARI uses the SSRAM for the main memory and framebuffer, so this is pretty thoroughly tested. Check out the most recent version on http://repo.or.cz/w/yari.git
It's currently just using the SSRAM at 50 MHz, but pending changes pushes it close to 200 MHz. (*) YARI is a MIPS I compatible soft core + peripherals for the DE2-70 and others. All logic is written from scratch by me, including all peripherals and memory controllers. Tommy - Altera_Forum
Honored Contributor
--- Quote Start --- HI, Thank you very much for your quick reply.. I could display a constatnt colour on to screen by synchronisation probelm is there so the picture is not stand still it is just moving top to bottom .. what should i do /?/ Thnaks, srinath. --- Quote End --- Eh, what? I didn't understand a word you just said. Don't forget that the best way to get a quality answer is to ask a quality question. Make it absolutely clear: - what you tried, - what you expected to happend, and - what you experienced instead. Remember, none of here are (I hope) mind readers. - Altera_Forum
Honored Contributor
HI,
Thank you very much for your quick reply.. I could display a constatnt colour on to screen by synchronisation probelm is there so the picture is not stand still it is just moving top to bottom .. what should i do /?/ Thnaks, srinath. - Altera_Forum
Honored Contributor
Hmm, I got the following silly example working on DE2-70, but haven't yet written a more robust memory control, assigned timing constraints, used a PLL, or used the burst mode. Also, I don't have the Cyclone III kit, so it'll likely take some adoption to get it running.
The example waits for a char c over the serial port and it, as well as c+1 and c+2 in a buffer, then proceeds to replay the whole buffer. The char '0' resets the buffer. Unlike what I suggested and what is recommended everywhere, using an inverted clock didn't work well for me. The essence is this (WARNING, this isn't production quality code, just a quick example):
See the attachment for a full example for the DE2-70. If someone in the Santa Clara area could lend me a Cyclone III kit, I could probably adopt it to that.assign oSRAM_CLK = iCLK_50; assign oSRAM_ADSP_N = 1; // We use ADSC# assign oSRAM_BE_N =~0; // byte write enable assign oSRAM_CE1_N = 0; // chip enable assign oSRAM_CE2 = 1; // chip enable assign oSRAM_CE3_N = 0; // chip enable reg SRAM_D_ena = 0; reg SRAM_DPA_out = 0; reg SRAM_D = 0; assign SRAM_DPA = SRAM_D_ena ? SRAM_DPA_out : 4'hZ; assign SRAM_DQ = SRAM_D_ena ? SRAM_D : 32'hZ; /* Demo state machine: When we get a serial char, we add it to the buffer and prints the whole buffer again */ reg state = 0; reg wp = 0; reg rp = 0; always @(posedge iCLK_50) begin // Set up default values so that writes below are one-shot oSRAM_ADSC_N <= 1; oSRAM_GW_N <= 1; oSRAM_ADV_N <= 1; oLEDR <= state; case (state) 0: begin // wait for input oSRAM_OE_N <= 1; // close the SSRAM DQ drivers SRAM_D_ena <= 1; // be ready for writing if (rs232in_attention) begin oSRAM_ADSC_N <= 0; oSRAM_A <= wp; oSRAM_GW_N <= rs232in_read_data == 48; SRAM_D <= rs232in_read_data; // WRITE! state <= 10; if (rs232in_read_data != 48) wp <= wp + 1; else begin wp <= 0; state <= 0; end rp <= 0; end end ...... 1: begin // wait a cycle just in case state <= 2; SRAM_D_ena <= 0; // Turn off the drivers oSRAM_OE_N <= 0; // Open the SSRAM drivers end 2: begin // issue read oSRAM_ADSC_N <= 0; oSRAM_A <= rp; rp <= rp + 1; state <= 3; end 3: state <= 4; // READ latency 4: state <= 5; // READ latency 5: begin // receive data rs232out_write_data <= SRAM_DQ; // READ! rs232out_write_enable <= 1; state <= 6; end - Altera_Forum
Honored Contributor
Hi,
Could you please send me the verilog code for SSRAM in cyclone III kit,, I tried in ll means to get it work , but every thing was a flop. Please send me the ssram verilogcode or atleast the simulation model so that i can get to know the exact timings and when to give address and data / PLease send me as soon as possible . Eagerly waiting for your reply. Thanks, Srinath. - Altera_Forum
Honored Contributor
Srinath, it would be useful to know what you tried and where you got stuck.
Did you read the datasheet? (http://www.issi.com/pdf/61vps_lps25636a_51218a.pdf) Pay especially attention to the figure on page 18. You should feed the ssram a 180 degree shifted clock. Simply assign ssram_clk = ~clk; may work, but the proper way is to use a pll to generate ssram_clk. Keep ADSP#, CE, ADV# high, and CE#, CE2# low. To read one word, set ADSC# low and present the address for _one_ cycle. Keep OE# low. You can pick up the data on DQ in two cycles. To write, turn OE# high, wait a cycle, drive the data to DQ, present the address, and set ADSC# and GW# low for one cycle. If this isn't enough, I'm working on a small demo for the ssram on the DE2-70 kit that I can post later. The same should work for you kit with minor modifications. - Altera_Forum
Honored Contributor
Hi,
Could you please provide me how to read and write in to SSRAM on the Nios II Evaluation Board (Cyclone III EP3c25F324C6) . I am not using Nios for my project , So please guide me how to wrte and read in to SSRAM with out NIOS II Processot. Hope you reply soon. Thanks , Srinath. - Altera_Forum
Honored Contributor
Does NIOS II have the option of write back data caches with miss-allocate? If so, the need for byte enables evaporates.
- Altera_Forum
Honored Contributor
You are correct. The performance impact this will have depends on your system and software design. Your processor will not necessarily run half as fast. The data and instruction caches will hide some of the performance loss. Any instruction that directly accesses the memory will suffer from an extra cycle penalty.
Jake