为什么NAND闪存单元只有空的时候才能直接写入?
我试图理解为什么在写入 SSD 之前必须先擦除单元,以及它们如何随着时间的推移而变慢。
I'm trying to understand why you have to erase cells before writing to them with respect to SSDs and how they slow down over time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
根据现代闪存芯片的设计方式,在一个方向上对单元进行编程比在另一个方向上更容易。如果一个芯片在 256 个 65,536 字节的块中保存 16,777,216 字节,每个块只能作为一个单元进行擦除,那么它将需要约 1.28 亿个“小”电路来允许对各个位进行编程,并需要 256 个“大”电路来擦除这些块。对于允许擦除 256 字节页的芯片来说,需要 65,536 个这样的“大”电路。我不确定芯片的哪一部分会被这么多页擦除电路耗尽,但这将是重要的。使用更大的擦除块可以使芯片的制造成本更便宜;对于许多应用来说,具有大擦除块的较便宜的芯片比具有较小擦除块的较昂贵的芯片更可取。
The way modern flash chips are designed, it's easier to program a cell in one direction than the other. If a chip holding 16,777,216 bytes in 256 blocks of 65,536 bytes each can only be erased as a unit, then it will require ~128 million "little" circuits to allow programming of the individual bits, and 256 "large" circuits to erase those blocks. For the chip to allow pages of 256 bytes to be erased would require 65,536 of those "large" circuits. I'm not sure what fraction of the chip would be used up by that many page-erase circuits, but it would be significant. Using larger erase blocks allows chips to be manufactured more cheaply; for many applications, a cheaper chip with large erase blocks is preferable to a more costly chip with smaller ones.
在写入之前不必擦除闪存单元。但是,您一次只能写入一整块单元格。通常,这些单元块的大小至少为 128KB。
假设您正在向 SSD 写入一个 4KB 文件。嗯,您必须一次写入一个 128KB 的块。如果该 128KB 块中已经有数据,则驱动器固件必须将 128KB 块读入其内存,修改要写入的 4KB 部分,然后将整个 128KB 块写回闪存。
You don't have to erase a flash memory cell before writing to it. However, you can only write to one entire block of cells at a time. Typically these blocks of cells are at least 128KB in size.
So suppose you are writing a 4KB file to your SSD. Well, you have to write one 128KB block at a time. If there is already data in that 128KB block, the drive firmware has to read the 128KB block into its memory, modify the 4KB section you are writing to, and then write the entire 128KB block back out to the flash memory.
维基百科文章似乎至少暗示了答案。看来“隧道注入”用于写入,“隧道释放”用于擦除。我将让物理学家来准确解释其含义。
The Wikipedia article seems to at least hint at the answer. It appears that "tunnel injection" is used for writing and "tunnel release" for erasing. I'll leave it to the physicists to explain exactly what the implications of that are.
为什么要先擦除再写入?
擦除单元意味着从其浮动栅极中去除大部分电子。浮栅中没有电子通常代表二进制 1:
此图和下图来自 “闪存如何工作?(SSD)” 作者:闪电战。
假设一个单元格代表一位(称为单级单元格,或简称 SLC),您可以非正式地说擦除是写入操作:通过擦除单元将单元/位设置为 1,这意味着从浮栅中移除大部分电子。另一方面,用电子填充浮动栅极是将位设置为 0 的物理实现方式:
A non - 具有有效电子量的空单元(代表 SLC 的零)被称为编程单元。
这里重要的是,闪存中的擦除(将位设置为 1)是相当粗粒度的:您擦除通常由大约 40,000 个单元组成的整个块。批量擦除单元比擦除单个单元更快。这种全块擦除策略是 EEPROM 与闪存的区别。顺便说一句,这也是闪存名称的由来:
当一个单元通过其包含的电子数量表示多个位时,我可以想到在将电子放入电池之前要清空电池的两个原因:
随着时间的推移,电池的速度减慢
将电子移入和移出浮栅会物理损坏浮栅周围的绝缘屏障。在足够的写入和擦除后,二氧化硅 SiO2 开始泄漏存储在浮置栅极中的电子。如果不加以处理,这些泄漏会导致数据损坏。例如,由于失去电子,电池的值自行从
101
变为011
。为了避免数据损坏,SSD 会定期刷新这些单元。老化电池的另一个问题是,读取或写入它们可能需要更长时间,因为在太多电子穿过浮栅周围的二氧化硅绝缘体后,它们变得更加不可靠。
如以下带注释的屏幕截图所示,摘自 精彩视频 ://www.youtube.com/c/BranchEducation" rel="nofollow noreferrer">Branch Education,那些二氧化硅 (SiO2) 绝缘体可以少于 100 个原子,大约 8 个纳米,宽:
Why erasure before write?
Erasing a cell means removing most electrons from its floating gate. No electrons in the floating gate commonly represents binary 1:
This and the next illustration are from "How Does Flash Memory Work? (SSD)" by BLITZ.
Assuming one cell represents one bit (that's called single-level cell, or SLC for short), you could informally say that erasing is the write operation: You set the cell/bit to 1 by erasing the cell which means removing most electrons from the floating gate. On the other hand, filling the floating gate with electrons is how setting the bit to 0 is physically implemented:
A non-empty cell with a valid amount of electrons—representing a zero for SLC—is referred to as a programmed cell.
Of significance here is that erasure (setting bits to 1) is rather coarse-grained in flash memory: You erase whole blocks which typically consist of about 40.000 cells. Erasing cells in bulk is faster than erasing individual cells. This whole-block-erasing strategy is what differentiates EEPROM from flash memory. Tangentially, that's also what gave flash memory its name:
When one cell represents multiple bits via the amount of electrons it contains, I can think of two reasons why you'd want to empty the cell before putting electrons into it:
Slowdown of cells over time
Moving electrons in and out of the floating gate physically damages the insulating barriers around the floating gate. The silicon dioxide, SiO₂, starts leaking the electrons stored in the floating gate after enough writes and erasures. If untreated, those leaks cause data corruption. For example, the cell's value changes from
101
to011
by itself due to lost electrons. To avoid data corruption, the SSD regularly refreshes those cells.Another problem in aging cells is that reading from or writing to them might take longer since they got more unreliable after too many electrons have been shot through the silicon dioxide insulators around the floating gate.
As shown in the following annotated screenshot from an excellent video by Branch Education, those silicon dioxide (SiO₂) insulators can be fewer than 100 atoms, about 8 nanometres, wide:
以下是写入 NAND 和擦除的工作原理:
当擦除一个块时,所有位都设置为 1。要将位从 1 更改为 0,需要对位进行编程(写入)。编程无法将位从 0 更改为 1。
假设您必须存储值 11001100。首先,需要擦除该块以表示全 1 (11111111)。然后,对特定位进行编程(11001100)。现在,相同的内存位置无法编程为 11111100,因为编程无法将 0 更改为 1。
这就是 NAND 找到全 1 的空闲/空页,然后将特定位从 1 更改为 0 的原因。传统的想法是写入可以将 1 变为 0,而 0 变为 1,对于 NAND 闪存来说则不然。事实上,NAND 编程操作只能将位从 1 更改为 0,这意味着我们在开始写入之前需要擦除页。
下图展示了页面和块的关系,来自flashdba.com 上的一篇文章:
有关更多信息,请参阅美光 NAND 闪存介绍。
Here is how writing to NAND and erasing works:
When a block is erased, all the bits are set to 1. To change bits from 1 to 0, bits are programmed (written to). Programming cannot change bits from 0 to 1.
Let's suppose you have to store the value 11001100. First, the block needs to erased to represent all 1s (11111111). Then, the particular bits are programmed (11001100). Now, the same memory location cannot be programmed to 11111100, because programming cannot change a 0 to 1.
This is the reason NAND finds a free/empty page with all 1s and then changes the specific bits from 1 to 0. The conventional idea that writing can change 1s to 0s and 0s to 1s is not true for NAND flash. The fact that the NAND programming operation can only change bits from 1 to 0, means that we need an erased page before we start writing.
The following figure shows the relationship between pages and blocks, from an article on flashdba.com:
For more, consult this introduction to NAND flash by Micron.