DDR3 Refresh and Micron DDR3 model - Page 1
Forum section: electronics / general

author: ddr_controller
author_rank: Contributor
timestamp: January 24, 2023, 12:54:58 pm
content: I am trying to implement a DDR3 controller for Arty A7 and have found many useful threads in this forum, however, one question I have not been able to solve is refresh timings.I initialized the DDR and performed a Write and close the row without errors, then I ran the simulation for at least 10ms but the model does not show any error regarding not refreshing during this time. From the docs. I read that on average refresh commands should be sent every 7.8us (page 121).Do I have to activate the error message with some sort of #define or it just doesn't check for refresh violations?

author: BrianHG
author_rank: Super Contributor
timestamp: January 24, 2023, 02:14:07 pm
content: That's the maximum average. This is the slowest if you wish to evenly space your refreshes.You only need to refresh the entire chip every 64ms if the chip is set to maximum 85deg C.Check out the maxtRFC in the datasheet. It is actually 70.2ms.Run your sim for 70.2ms without any refresh commands, and it should spit out an error.Remember, it is possible to wait 60ms without any refreshing and then burst refresh commands back-back to do the entire chip in one shot without any error.See Micron 4gb DDR3 data sheet, page 86, table 58, 'Refresh Timing'.Download this data sheet:Micron DDR3 datasheetCareful, running the DDR3 at 105 deg C shortens this 64ms time to 16ms meaning you also need to shrink the average refresh period if you run the DDR3 in this mode.(Doesn't Xilinx have a free DDR3 ram controller?)

author: ddr_controller
author_rank: Contributor
timestamp: January 24, 2023, 02:23:34 pm
content: Shouldn't it be 70.2us? Intable 58t_RFC MAX = 70,200ns

author: BrianHG
author_rank: Super Contributor
timestamp: January 24, 2023, 02:25:48 pm
content: Read the next page, and I did say the max was 70.2 at the top of my post...I shrunk the time down to 60ms to give you time to do all 8192 back to back refresh commands before the 64ms time runs out.Actually, with the larger DDR3 chips having a slower refresh, cut my 60ms down to <50ms.

author: ddr_controller
author_rank: Contributor
timestamp: January 24, 2023, 02:49:34 pm
content: I think I replied before your editAbout Xilinx free controller: I am trying to learn how a DRAM controller works so I want to build one...Anyway, I think I just don't understandwhenandhowrefreshed are done. I got lost in the documentation, can you point me to the key pages on the docs. where I can find a complete description of how to refresh?

author: BrianHG
author_rank: Super Contributor
timestamp: January 24, 2023, 03:34:30 pm
content: If you are learning about writing a DDR3 controller, just read the entire document.You will find all your answers there as I have.My DDR3 controller:https://github.com/BrianHGinc/BrianHG-DDR3-ControllerYou do not necessarily need to take it as far as I did.To refresh the entire chip, it must be done 8192 times within 64ms as stated on page 87:QuoteIn other words, 8192 refresh commands X 7.8us = 63.9ms.All that is important is that every 1 of the 8192 refresh commands must repeat within 64ms. You are permitted to stuff all those 8192 refresh commands all the way at the end of the 64ms so long as the first of the 8192 happens still less than 64ms since that last time that one of 8192 was called and there are 8192 which need to be called since 8192 rows need to be refreshed.IE: It takes 8192 refresh commands to refresh the entire DDR3 ram chip.There is a complete section on refresh in the data sheet.

author: ddr_controller
author_rank: Contributor
timestamp: January 24, 2023, 03:45:59 pm
content: On the note of simulation. I have run 80ms after precharge and no refresh error has popped. Is this the expected behaviour of the Micron ddr3.v?

author: BrianHG
author_rank: Super Contributor
timestamp: January 24, 2023, 04:40:57 pm
content: Try opening a closed bank & row and try a read BL8.Sorry, I do not have time to see what happens with my controller's refresh forced off.

author: ddr_controller
author_rank: Contributor
timestamp: January 24, 2023, 04:48:55 pm
content: No worries, you are being very helpful! Thanks a lot!You said that there is an entire section talking about refresh but I only foundpage 123and it doesn't give me many clues...I know that there are multiple ways of refreshing, RAS# based, CAS# (CBR)... But I can't find the description of how each of them works. In my mind, I just imagine that the REFRESH command just refreshes all the banks and that if you want to target specific lines you just open and close that line, but then you have to keep track of the time to know the next refresh.

author: asmi
author_rank: Super Contributor
timestamp: January 24, 2023, 05:06:40 pm
content: Quote from: ddr_controller on January 24, 2023, 04:48:55 pmNo, that's not how it works. What exactly gets refreshed is none of your controller's business, all it needs to do is issue a refresh command every 7.8 us on average, addressing is generated internally, in other words, memory device tracks what is to be refreshed by itself. Here is the relevant section from the datasheet:Quote

author: BrianHG
author_rank: Super Contributor
timestamp: January 24, 2023, 05:59:49 pm
content: Quote from: ddr_controller on January 24, 2023, 04:48:55 pmThe refresh command just refreshes 1 row group (only a few rows can be refreshed at once) in all the banks simultaneously out of 8192 row groups which each bank has.Internally in the DDR3, every time you send a refresh that row counter increases by 1.See block diagram figure 5 on page 16 of the Micron data sheet. You will see the block 'refresh counter' which has 13 bits, hence 8192 possible refresh address positions. (Note that the other 2 block diagrams has the refresh counter at 16 bits. I'm not sure what is going on here. The slower refresh time for the larger ram chips may just be internally incrementing this counter during the longer refresh period to make up for more rows.)

author: trossin
author_rank: Contributor
timestamp: August 21, 2023, 06:58:25 pm
content: DRAMs do more than refresh in response to a refresh command so they don’t like you to save up more than 8 or 16 ( I can’t remember) before busting them. There is this ugly thing called row hammer that vendors fixed up by doing some magic during refresh. They also do some internal calibration magic.Unless you are super worried about latency, there is not much reason to delay refresh. Just stop what you are doing, close your open pages and issue the refresh. I’m not a fan of open page mode for applications that don’t have much locality as there are a crap load of rows per bank. It takes longer to close the page and open a new one which sucks for throughput.DDR5 gave us per bank set(same bank of all groups) refresh which is a fun way to cut down on latency as you are not blocking traffic to the entire device. It complicates your blocking logic though.Don’t forget to be a nice person and do ZQCal 8 times a second.