MMultidimensional Flash Codes
Eitan Yaakobi, Alexander Vardy, Paul H. Siegel, and Jack K. Wolf
University of California, San DiegoLa Jolla, CA − , USAEmails: [email protected], [email protected], [email protected], [email protected] Abstract — Flash memory is a non-volatile computer memorycomprised of blocks of cells, wherein each cell can take on q different levels corresponding to the number of electrons itcontains. Increasing the cell level is easy; however, reducing acell level forces all the other cells in the same block to be erased.This erasing operation is undesirable and therefore has to beused as infrequently as possible. We consider the problem ofdesigning codes for this purpose, where k bits are stored usinga block of n cells with q levels each. The goal is to maximizethe number of bit writes before an erase operation is required.We present an efficient construction of codes that can store anarbitrary number of bits. Our construction can be viewed as anextension to multiple dimensions of the earlier work of Jiang andBruck, where single-dimensional codes that can store only bitswere proposed. I. I
NTRODUCTION
Flash memories are, by far, the most important type of non-volatile computer memory in use today. They are employedwidely in mobile, embedded, and mass-storage applications,and the growth in this sector continues at a staggering pace.A flash memory consists of an array of floating-gate cells ,organized into blocks (a typical block comprises to cells). Hot-electron injection [16] is used to inject electronsinto a cell, where they become trapped. The Fowler-Nordheimtunneling [19] mechanism (field emission) can be used toremove electrons from an entire block of cells, thereby dis-charging them. The level or “state” of a cell is a function ofthe amount of charge (electrons) trapped within it. Historically,flash cells have been designed to store only two values(one bit); however, multilevel flash cells are actively beingdeveloped and are already in use in some devices [2], [7].In multilevel flash cells, voltage is quantized to q discretethreshold values, say , , . . . , q − . The parameter q can rangefrom q = 2 (the conventional two-state case) up to q = 256 .The most conspicuous property of flash storage is its inher-ent asymmetry between cell programming (charge placement)and cell erasing (charge removal). While adding charge to asingle cell is a fast and simple operation, removing chargefrom a cell is very difficult. In fact, flash memories do notallow a single cell to be erased — rather only entire blocks (comprising up to cells) can be erased. Thus, a single-cellerase operation requires the cumbersome process of copyingan entire block to a temporary location, erasing it, and thenre-programming all the cells except one. Moreover, since over-programming (raising the charge of a cell above its intendedlevel) can only be corrected by a block erasure, in practicea conservative procedure is used for programming a cell. Charge is injected into the cell over numerous rounds; afterevery round, the charge level is measured and the next-roundinjection is configured, so that the charge gradually approachesits desired level. All this is extremely costly in time and energy.Codes designed to address this problem were first intro-duced in [10], [11], [12], and are called floating codes . Herewe address these codes slightly differently under the nameof flash codes . Flash codes are a sweeping generalization ofwrite-once memory codes [4], [6], [18], designed to maximizethe number of times information can be rewritten before blockerasures are required. In a nutshell, the idea is to use n q -levelcells to store k < n log q bits, thereby storing less bits thanpossible (the rate of the flash code is k/ ( n log q ) ). The bits arerepresented in a clever way to guarantee that every sequenceof up to t writes (of a single bit) does not lead to any of the n cells exceeding its maximum value q − . Recently, severalmore papers have appeared [1], [3], [5], [8], [9], [13], [14],[15], [17] that discuss coding techniques for this model offlash memories.Let us begin by giving a precise definition of flash codes .An insightful way to do so is in terms of a pair of graphsand a pair of mappings between these graphs. The first graphis the familiar hypercube H k . The vertices of H k , called the variable vectors , are the k binary vectors of length k , withtwo such vertices α, β ∈ F k being adjacent iff d H ( α, β ) = 1 ( d H ( α, β ) denotes the Hamming distance between α and β ).This graph constitutes the state transition diagram of the k information bits. A single-bit write operation corresponds tothe traversal of an edge in H k , and a sequence of t writes isa walk of length t in H k . To describe the second graph, set A q = { , , . . . , q − } , and think of A q as a subset of theintegers. Now consider the directed graph G n whose verticesare the q n vectors of length n over A q , and are called the cell state vectors . There is a directed edge from x ∈ A nq to y ∈ A nq in G n iff d H ( x , y ) = 1 and in the single position i where x and y differ, we have y i = x i + 1 . The graph G n is the state transition diagram of n flash memory cells.Observe that there is a path from x to y in G n iff y i ≥ x i forall i = 1 , , . . . , n , which reflects the condition that the chargeof memory cells can only increase. The graphs H k and G n areillustrated in Figure 1 for the case k = 3 , n = 2 , and q = 8 .An ( n, k ) q flash code C can now be specified in termsof two maps: a decoding map ∆ and a transition map f .The decoding map ∆ : A nq → F k simply indicates for eachcell state vector x ∈ V ( G n ) the value of the variable vectorassociated with the corresponding cell state vector. This map a r X i v : . [ c s . I T ] A p r Fig. 1. State transition diagrams for k = 3 bits, and for n = 2 memorycells with q = 8 levels. can be, in principle, arbitrary, although it must be chosencarefully in order to obtain flash codes with good performance.For each α ∈ F k , let G n ( α ) denote the set of vertices x ∈ V ( G n ) such that ∆( x ) = α . With this, the transition map f : E ( H k ) ×A nq → A nq ∪ { E } can be described as follows. Forevery edge ( α, β ) ∈ E ( H k ) and every vertex x ∈ G n ( α ) , thevalue of f ( α, β ; x ) is a vertex y ∈ G n ( β ) such that y i ≥ x i for all i (so that there exists a path from x to y in G n ).Or, if no such vertex exists, f ( α, β ; x ) = E indicating thata block erasure is required. It is clear from the definition that (∆ , f ) map walks in H k onto directed paths in G n , potentiallyterminating in the block-erasure symbol E . Definition 1:
A flash code C (∆ , f ) guarantees t writes ifall walks of length t in H k , starting at the vertex (0 , , . . . , ,map onto valid paths in G n , never producing the symbol E .The weight of a cell state vector x ∈ A nq is defined to be w x = (cid:80) ni =1 x i , and for convenience will be called the cellstate weight . We note that at each write operation the increasein the cell state weight is at least one, and hence a trivial upperbound for the number of writes, t , is n ( q − . Definition 2:
If a flash code guarantees at least t writesbefore erasing, then its write deficiency (or simply deficiency )is defined to be δ = n ( q − − t .In [12], a code for storing two bits is presented. The codeis constructed for arbitrary n and q and guarantees t = ( n − q −
1) + (cid:4) q − (cid:5) writes. A general upper bound on t whichholds for any k, (cid:96), n, q ( (cid:96) is the variable alphabet size, andusually (cid:96) = 2 ) is presented as well, and assures that this two-bits construction is optimal. Theorem 1: [12] For any code that uses n q -level cells andguarantees t writes before erasing, if n ≥ k ( l − − , then t ≤ ( n − k ( l −
1) + 1) · ( q −
1) + (cid:106) ( k ( l − − · ( q − (cid:107) ; if n For any code that uses n q -level cells andguarantees t writes before erasing, the code deficiency satisfies δ ≥ ( k ( l − − · ( q − − (cid:106) ( k ( l − − · ( q − (cid:107) if n ≥ k ( l − − , and δ ≥ n ( q − − (cid:106) n ( q − (cid:107) if n < k ( l − − .Furthermore, the bound in [12] implies that for n large enough the write deficiency of the code is not dependent on n . Definition 3: Let q be a fixed number of cell levels, and k a fixed number of variables. A family of ( n i , k ) q flash codes C i (where lim i →∞ n i = ∞ ) that guarantees t ( n i , q ) writesis called asymptotically optimal if lim i →∞ t ( n i , q ) n i ( q − 1) = 1 . Asymptotically optimal constructions are presented in [12]for storing two and three bits. These constructions are laterenhanced and generalized for ≤ k ≤ bits in [13].Also, in [13] a new construction of codes, called indexedcodes , is presented and supports the storage of an arbitrarynumber of variables. This construction, though shown to beasymptotically optimal, has deficiency that is dependent onthe number of cells, n , and hence is still far from the lowerbound on the deficiency.The rest of the paper is organized as follows. In Section IIwe present another optimal construction for storing two bits. InSection III we demonstrate the basic idea of how to representan arbitrary number of bits inside a multidimensional box. Ourmain construction is given in Section IV. We construct codesfor efficient storage of bits such that the write deficiency doesnot depend on the number of cells. Finally, conclusions andan open problem are given in Section V.II. A NOTHER O PTIMAL C ONSTRUCTION FOR T WO B ITS The construction presented in [12] for storing two bitsusing an arbitrary number of q -level cells is optimal. Wepresent here another optimal construction which we believeis simpler. In this construction, the leftmost (rightmost) cellsof the memory correspond to the first (second) bit. In writing,if we change the first (second) bit then we increase by onethe leftmost (rightmost) cell having level less than q − .We repeat this process until the cells coincide and then theonly cell of level less than q − represents the two bits.In general, the cell state vector has the following form: ( q − , . . . , q − , x i , , . . . , , x j , q − , . . . , q − , where < x i , x j ≤ q − . We present here the construction for oddvalues of q , but it is easily modified to handle even values aswell. Encoding: We consider the following cases:1) There are at least two cells of level less than q − . Ifwe change the level of v ( v ) then we increase by onethe leftmost (rightmost) cell having level less than q − .If after this change there is only one cell of level lessthan q − , then it has to represent two bits. We changeits level such that its residue modulo correspondsto the four possible variable vectors. If the cell levelhas residue modulo equal to , , , or , then thecorresponding variable vector is (0 , , (0 , , (1 , , or (1 , , respectively.2) There is only one cell of level less than q − . In thiscase the cell represents both bits and we increase itslevel to the correct residue modulo according to thenew value of the variable vector. ecoding: The equivalent cases are considered:1) There are at least two cells of level less than q − .Let i ( i ) be the index of the leftmost (rightmost) cellhaving level less than q − . Then, we decode v = x i (mod 2) , v = x i (mod 2) . 2) There is one cell of level less than q − , and it is the i -th cell. Then we decode v = (cid:98) ( x i (mod 4)) / (cid:99) , v = ( x i (mod 4))(mod 2) . 3) All cells have level q − . We decode according to theprevious rule with x i = q − .For even values of q , the construction is very similar. Again,the last available cell represents two bits. However, now thevalue of the two bits, given by the last available cell, is theirrelative difference from the value of the two bits given by allother cells. We note that since q is even, a cell of level q − represents a bit of value and not as we had in the caseof odd q . Furthermore, if we use the last available cell up tolevel q − then it will be impossible to distinguish whichcell represents two bits in case all of them are at level q − .Therefore, we use the last available cell only until level q − .This construction is optimal as well. Theorem 2: If there are n q -level cells, then the codedescribed above guarantees at least t = ( n − q − (cid:4) q − (cid:5) writes before erasing. Proof: As long as there is more than one cell of levelless than q − , the cell state weight increases by one after eachwrite. This may change only after at least ( n − q − writes.Let us assume that there is only one available cell of level lessthan q − after s = ( n − q − 1) + j writes, where j ≥ .Starting at this write, the different residues modulo of thiscell correspond to the four possible variable vectors. Therefore,at the s -th write, we also need to increase the level of the lastavailable cell so it will correspond to the variable vector at the s -th write. For all succeeding writes, if we change the first bitthen the cell level increases by two. If however we change thesecond bit then the increase in the cell level alternates betweenone and three. Hence, if there are m writes to the last availablecell, then the cell level increases by at most m + 1 . Considerthe case where the last available cell starts representing thetwo bits together. If its level, before it starts representing thetwo bits together and after updating its level to correspond tothe variable vector at the s -th write, is x , then there are at least (cid:98) ( q − − x ) / (cid:99) more writes. Next, we consider all possibleoptions for the values of j and the variable vector at the s -thwrite in order to calculate the number of guaranteed writesbefore erasing.1) Suppose j ( mod 4) = 0 , the value of both bits is , andthe level of the last available cell does not increase atthe s -th write. Hence, there are at least (cid:98) ( q − − j ) / (cid:99) more writes and a total of at least ( n − q − 1) + j + (cid:98) ( q − − j ) / (cid:99) ≥ ( n − q − 1) + (cid:98) ( q − / (cid:99) writes.2) Suppose j ( mod 4) = 1 , one of the bits has value andthe other one . If the variable vector is ( v , v ) = (0 , then at the s -th write the level of the last availablecell does not increase and if it is ( v , v ) = (1 , then its level increases by one. There are at least (cid:98) ( q − − ( j + 1)) / (cid:99) more writes, where j ≥ and atotal of at least ( n − q − 1) + j + (cid:98) ( q − − j ) / (cid:99) ≥ ( n − q − 1) + (cid:98) ( q − / (cid:99) writes.3) Suppose j (mod 4) = 2 , the value of both bits is and we increase the level of the last available cellby two at the s -th write. Therefore, there are at least (cid:98) ( q − − ( j + 2)) / (cid:99) more writes, where j ≥ and atotal of at least ( n − q − 1) + j + (cid:98) ( q − − j ) / (cid:99) ≥ ( n − q − 1) + (cid:98) ( q − / (cid:99) writes.4) Suppose j (mod 4) = 3 , one of the bits has value and the other one . If the variable vector is ( v , v ) =(0 , then the level of the last available cell increasesby two, and if it is ( v , v ) = (1 , then we increaseby three the level of the last available cell at the s -th write. Thus, there are at least (cid:98) ( q − − ( j + 3)) / (cid:99) more writes, where j ≥ and a total of at least ( n − q − 1) + j + (cid:98) ( q − − j ) / (cid:99) ≥ ( n − q − 1) + (cid:98) ( q − / (cid:99) writes.In any case, the guaranteed number of writes is ( n − q − 1) + (cid:4) q − (cid:5) .III. B ASIC M ULTIDIMENSIONAL C ONSTRUCTION In this section we start the discussion of how to store anarbitrary number of bits. We demonstrate a basic constructionfor representing the bits inside a multidimensional box. Themain drawback of this construction is its relatively high writedeficiency that depends on the number of cells. In the nextsection we will show an alternative construction with a betterdeficiency.Assume we want to store four bits using n q -level cells.We represent the memory as a matrix of n × n cells, where n n = n . In each column two bits are stored. The first andsecond bits are stored using the left columns. The leftmostcolumn is used first, then the second leftmost and so on.Similarly, the third and fourth bits are stored using the rightcolumns right-to-left. In each column we store the bits fromthe opposite directions as in the previous two-bits construction.However, in this case we don’t use the last available cell torepresent two bits, but leave it as a separation cell. Assume wechange the value of one of the first two bits, if it is possible toupdate this change in the current column that represents thesebits, we do so. Otherwise, and if there is at least one morecolumn for separation, we use the next column. An exampleof the memory state of this construction is demonstrated inFigure 2(a). The worst case scenario for the number of writesbefore erasing occurs when:1) One column is used for separation.2) Another column is only partially used and representsone write operation. That is, there was only one writeto this column and still it is impossible to update thecurrent write in this column.3) In two other previous columns there is one more cellthat is also only partially used and represents one write a)(b)Fig. 2. Figure 2(a) describes an example of the memory state for thebasic multidimensional construction, and Figure 2(b) demonstrates an examplefor the worst case scenario of the guaranteed number of writes when it isimpossible to write the first bit. operation.Hence, the guaranteed number of writes is ( n − n − q − − (( n − q − − − q − − , where n n = n .Another example of the memory state that corresponds to theworst case scenario is given in Figure 2(b).The generalization of this construction to three dimensionssupports the storage of up to eight bits. Each plane stores fourbits. The lower planes represent the first four bits and the upperplanes represent the last four bits. In each plane we use theprevious construction in order to represent four bits. We canuse all the columns in each plane except for one that is left forseparation between the two groups of two bits in this plane.Also, one more plane is used for separation between the twogroups of four bits. The equivalent worst case scenario for thenumber of writes before erasing occurs as follows:1) One plane is used for separation.2) Another plane is partially used and represents only onewrite operation.3) In two previous planes there is one more column that represents only one write and two more cells thatrepresent only one write as well.Therefore, the guaranteed number of writes is ( n − n − n − q − − (( n − n − q − − − n − q − − − q − − , where n n n = n .In general, using a D -dimensional box we can store D bits,and we can show that the number of guaranteed writes is D (cid:89) i =1 ( n i − q − − D − (cid:88) i =1 i − D − i (cid:89) j =1 ( n j − q − − − D − (( q − − , where n n · · · n D = n . It is also possible to show thatthis code is asymptotically optimal. However, its deficiencydepends on n and therefore is not close enough to the lowerbound on the deficiency. Next, we will show how to modifythis construction in order to obtain a deficiency that is onlydependent on the number of bits k and the number of celllevels q .IV. E NHANCED M ULTIDIMENSIONAL C ONSTRUCTION The last construction of flash codes demonstrates the ideaof how to use a multidimensional box in order to representmultiple bits. Even though its asymptotic behavior is optimal,there is still a large gap between its write deficiency and thelower bound on the deficiency. The high deficiency mainlyresults from the separation cell in each column, the separationcolumn in each plane, and in general from the separationhyperplane in each dimension.The following construction of flash codes shows how toimprove the deficiency. In order to reduce the deficiency fromthe extra separation hyperplane in the last dimension, thelength of each dimension, besides the last one, should be assmall as possible, for example we want to choose n i = 2 , for ≤ i ≤ D − . We also want to store the bits differentlyso that in each dimension it is possible to take advantage of allcell levels before using the next dimension. Another advantageof using small dimension lengths is that the rate of the code(defined as k/ ( n log q ) ) is enhanced as well. We show aconstruction where each dimension length, other than the lastone, is two. If we want to store k = 2 D binary bits then weshow how to store D − of them inside ( D − -dimensionalboxes of size n × n × · · · × n D − = 2 × × · · · × . Then,we use a D -dimensional box of size n × n × · · · × n D =2 × × · · · × × n D , where n D ≥ , which consists of n D ( D − -dimensional boxes. For convenience, we call everymultidimensional box, of any dimension, whose edges are oflength , a block .The construction is recursive. We first present how to storetwo bits using two-cell blocks. Then, we use this constructionin order to store four bits using two-dimensional four-cellblocks of size × . Using the four-bits construction, it ispossible to store eight bits in a three-dimensional eight-cellblocks of size × × . In general, the construction forstoring i − bits in ( i − -dimensional blocks, where i ≥ ,is utilized in order to store i bits in i -dimensional blocksf i cells each. We show in detail the basic constructions forstoring two and four bits as these constructions are the buildingblocks for the arbitrary recursive construction. An analysis ofthe construction deficiency is given as well and it is shownthat the write deficiency order is O ( k q ) .Like the two-bits construction, this construction is presentedfor odd values of q , and it is possible to modify it in order tosupport even values. However, the deficiency is larger when q is even. A. Two-Bits Construction Our point of departure for these codes is a basic constructionfor storing two bits using blocks of two cells. Encoding: 1) As long as the number of writes in the block is no greaterthan q − :a) If the first bit is changed then the left cell is raisedby one.b) If the second bit is changed then the right cell israised by one.2) Starting at the q -th write, it may happen that for somecell state vectors of the block, it is possible to write onlyone of the bits. In this case, if the other bit is changedthen a new block is used.a) If the cell state vector of the block is of the form ( q − , x ) , where x < q − , then only the first bitcan be written to this block, and the level of thesecond cell is raised by one.b) If the cell state vector of the block is of the form ( x, q − , where x < q − , then only the secondbit can be written at the next write, and the levelof the first cell is raised by one.c) If the cell state vector of the block is of the form ( x , x ) , where x < q − , x < q − , thenboth bits can be written at the next step. If thefirst (second) bit is changed then the second (first)cell is raised by one. Decoding: 1) If the cell state vector is of the form ( x , x ) , where ≤ x , x ≤ q − , and x + x ≤ q − then thevariable vector is ( v , v ) = ( x (mod 2) , x (mod 2)) . 2) If the cell state vector is of the form ( x , x ) , where ≤ x , x ≤ q − , and x + x > q − then thevariable vector is ( v , v ) = ( x (mod 2) , x (mod 2)) . An example of this construction for q = 5 is given in Figure 3.We note that as long as the number of writes is no greater than q − then it is possible to write both bits. Only at the q -thwrite might it happen that writing will continue in the nextblock.By abuse of terminology we use the following definitionsfor a block of any size: Fig. 3. State diagram for flash codes storing two bits in a block of two 5-level cells. The numbers in each block, above the block, and next to each edgerepresent the cell state vector, variable vector, and the written bit, respectively. 1) A block is called empty if all its cells are at level zero.2) A block is called full if all its cells are at level q − .3) A block is called active if it is neither empty nor full. Lemma 1: For the two-bits construction, at any write op-eration, there are at most two active blocks and at most A = ( q − 1) + 2( q − − q − − levels thatare not used in these two blocks. Proof: If a new block is used then the previous blockuses at least q − levels, and there are no more active blocks.Therefore, at most q − levels are not used in the previousblock and q − − in the new block. B. Four-Bits Construction Next, the four-bits case is considered. We use blocks of fourcells. Each block is divided into two sub-blocks of two cellseach, and each such sub-block is a column that stores two bitsaccording to the previous construction. The block can eitherstore the first and second bits together or the third and fourthbits together, i.e., it is impossible to store all four bits togetherin the same block. If the block stores the first and second bitsthen the sub-blocks are written left-to-right, and if the blockstores the third and fourth bits then the sub-blocks are writtenright-to-left. , → * ** * ← , . In this construction we have another distinction betweenstoring the first and second bits and the third and fourth bits.Each sub-block represents two bits according to the previousconstruction, but the order the bits are written in the sub-blocks is changed. If the block represents the first and secondbits then both sub-blocks represent the bits in the same way:1 12 2owever, if the block represents the third and fourth bits thenthe representation order of the bits in the two sub-blocks ischanged as follows: 4 33 4 Encoding: 1) The block can either represent the bits , or the bits , . In each sub-block (column) we use the previousconstruction in order to represent two bits.2) If the block represents the bits , , then we write the twosub-blocks left-to-right, and the bits are stored similarlyin the two sub-blocks.3) If the block represents the bits , , then we write thetwo sub-blocks right-to-left. For the right sub-block werepresent the two bits where the third (fourth) bit isconsidered to be the first (second) bit in the two bitsconstruction, ↔ , ↔ . However, for the left sub-block we change the order ofthe bits, i.e., the third (fourth) bit is considered to be thesecond (first) bit in the two-bits construction, ↔ , ↔ . 4) If the block represents the bits , ( , ) then the right(left) sub-block cannot be full before the left (right) sub-block is full. Decoding: 1) For every active block we first determine, according tothe encoding rules, whether it represents the bits , or , :a) If the right (left) sub-block is empty then the blockrepresents the bits , ( , ).b) If the left (right) sub-block is full then the blockrepresents the bits , ( , ).c) If both sub-blocks are active then according to thedecoding procedure of the two-bits construction wecan decide for each sub-block whether it is in astate that enables to write both bits, only the firstbit or only the second bit.i) If the right (left) sub-block is in a state thatenables to write both bits then the block repre-sents the bits , ( , ).ii) Assume the states of both sub-blocks enableto write only one bit. If both bits from thetwo sub-blocks are first bits or both bits aresecond bits then the block represents the bits , . Otherwise, it represents the bits , .2) If the block represents the bits , or , , we can decodetheir values from the two sub-blocks using the decodingprocedure of the two-bits construction.3) The value of each bit is the XOR of its values from allblocks.An example of this construction for q = 3 is given in Figure 4. Fig. 4. State diagram for flash codes storing four bits in a four-cell block.The numbers in each block, above the block, and next to each edge representthe cell state vector, variable vector, and the written bit, respectively Lemma 2: For the four-bits construction, after any writeoperation, there are at most six active blocks and at most A = 2 (( q − 1) + 1 + 4( q − − 1) = 10( q − levels thatare not used in these four blocks. Proof: For each pair of bits there are at most three activeblocks, a new block and two previous active blocks that couldnot be full before starting the new block. In the two previousblocks at most ( q − levels are not used, corresponding tothe case that the first sub-block does not use one level and thesecond block does not use ( q − levels. For example, if theblocks represent the first and second bits, the two previousactive blocks can be of the following form, that enables towrite only the second bit: q − q − q − q − q − q − q − In the new block at most q − − levels are not used.Therefore, there are at most six active blocks and at most A = 2 · (( q − 1) + 1 + 4( q − − 1) = 10( q − levels thatare not used in these blocks. C. Construction for Arbitrary Number of Bits We are now ready to present the general construction offlash codes storing an arbitrary number of bits. First, we brieflydescribe how to represent eight bits and then give the generalconstruction.In order to store eight bits we use a block of eight cellswhich is a three-dimensional box of size × × . In fact, theblock consists of two sub-blocks of four cells each that canbe considered as two concatenated sub-blocks of size × .* * * ** * * *Each block can either represent the bits , . . . , or , . . . , according to the following order: , . . . , → , −→ , ←− , −→ , ←− * * * * ← , . . . , . he bits , . . . , ( , . . . , ) write the two × sub-blocksleft-to-right (right-to-left). Each sub-block represents four bitsaccording to the four-bits construction. More rules are usedto decide whether the code represents the bits , . . . , or , . . . , , and are described in detail below for the arbitrarycase.For representing i bits, we assume that there is a con-struction for storing i − bits in blocks of i − cells. We useblocks of i cells that consist of two sub-blocks of i − cells.We assume that for the i − -bits construction there are at most · i − active blocks and at most A i − levels that are not usedin these blocks. Encoding: 1) The block can either represent the bits , . . . , i − or thebits (2 i − +1) , . . . , i according to the following order: . . . i − → . . . (2 i − i − . . . (2 i − i − i − −−−→ . . . i − ←−−−−−− (2 i − i − −−−−−−−−−−−→ +1) . . . i ←−−−−−−− ← (2 i − · · · i In each sub-block, i − bits are represented accordingto the recursive construction.2) Assume the block represents the bits , . . . , i − ,a) The sub-blocks are written left-to-right.b) It is possible to use the right sub-block only if theleft sub-block is full.3) Assume the block represents the bits (2 i − + 1) , . . . , i ,a) The sub-blocks are written right-to-left.b) It is possible to use the left sub-block only if theright sub-block is full.c) The i − bits (2 i − +1) , . . . , i are stored as if theywere the bits , . . . , i − , where the (2 i − + j ) -thbit, ≤ j ≤ i − is considered to be the j -th bit. Decoding: 1) For every active block we first determine, accordingto the encoding rules, which group of i − bits itrepresents. If the left (right) sub-block is full or active,then the block represents the bits , . . . , i − ( (2 i − +1) , . . . , i ).2) If the block represents the bits , . . . , i − or (2 i − +1) , . . . , i , we can decode their value from the two sub-blocks using the decoding procedure of the i − -bitsconstruction.3) The value of each bit is the XOR of its values from allblocks. Lemma 3: For flash codes storing i bits, after any writeoperation, there are at most · i − active blocks and at most A i = 2 A i − + 3 / · ( q − i levels that are not used in these blocks. Proof: Each of the blocks that represents the bits , . . . , i − can be considered as a pair of sub-blocks con-taining i − cells, such that each sub-block represents the bits , . . . , i − . According to the recursive construction at most · i − sub-blocks are active and at most A i − levels are notused in these sub-blocks. If all these sub-blocks happen to bethe left ones in their containing blocks then there are · i − more sub-blocks that are empty, which are the correspondingright sub-blocks in each block. In each such a sub-block, atmost i − ( q − levels are not used. Hence, in these sub-blocks at most B i = 3 · i − · ( q − i − = 3 / · ( q − i levels are not used. The same analysis is applied to the blocksthat represent the bits (2 i − + 1) , . . . , i . Therefore, for all thebits, there are at most · i − active blocks and at most A i = 2 A i − + 2 B i = 2 A i − + 3 / · ( q − i levels that are not used in these blocks. D. Deficiency AnalysisLemma 4: For i ≥ we have A i = 3 / · ( q − i − / · ( q − i . Proof: We prove the correctness of the expression for A i by induction. According to Lemma 2, we have A = 10( q − which is also given by this expression. Assume A i − = 3 / · ( q − i − − / · ( q − i − , for i ≥ , then according toLemma 3 A i = 2 A i − + 3 / · i ( q − (cid:0) / · ( q − i − − / · ( q − i − (cid:1) + 3 / · i ( q − / · ( q − i − / · ( q − i . Theorem 3: If the flash codes represent k = 2 D bits thenthe deficiency δ D satisfies δ D = 2 A D − + 1 = 3 / · ( q − k − / · ( q − k + 1 . Proof: In order to represent k = 2 D bits a D -dimensionalbox of size × × · · · × × n D is used. The multidimensionalbox is considered as an array of n D ( D − -dimensionalboxes, called blocks. The first (last) D − bits are representedusing the blocks left-to-right (right-to-left), and there is oneblock for separation. In each ( D − -dimensional box we usethe construction to represent D − bits. Writing stops if weneed to start using a new block but it is the last separationblock. According to Lemma 3 at most A D − levels are notused in the active blocks for each group of bits. Also, it isimpossible to use the last separation block, and hence at most A D − + 1 levels are not used in the worst case, where A D − + 1= 2 (cid:0) / · ( q − D − − / · ( q − D − (cid:1) + 1= 3 / · ( q − D − / · ( q − D + 1= 3 / · ( q − k − / · ( q − k + 1 . For even values of q , we consider every two cells of level q as one cell of level q (cid:48) = 2 q − , and we can apply theconstruction for odd values of q . The code deficiency becomes / · ( q − k − · ( q − k + 1 .. C ONCLUSION In [12], the problem of coding to minimize block erasuresin flash memories was first presented. In this work we showan optimal construction of flash codes for storing two bits.We believe that our construction is simpler than an earlieroptimal construction presented in [12]. Our main contributionis an efficient construction of codes that support the storageof any number of bits. We show that the order of the codedeficiency is O ( k q ) , which is an improvement upon theequivalent construction in [13]. The upper bound in [12] onthe guaranteed number of writes implies that the order of thelower bound on the deficiency is O ( kq ) . Therefore, there isa gap, which we believe can be reduced, between the writedeficiency orders of our construction and the lower bound.A CKNOWLEDGMENT The authors wish to thank Hilary Finucane and MichaelMitzenmacher for pointing out errors in an earlier version ofthe paper . R EFERENCES[1] V. Bohossian, A. Jiang, and J. Bruck, “Buffer coding for asymmetricmulti-level memory,” in Proceedings IEEE International Symposium onInformation Theory , Nice, France, June 2007.[2] P. Cappelletti, C. Golla, P. Olivo, and E. Zanoni (Editors), Flash memo-ries , Boston: Kluwer Academic, 1999.[3] Y. Cassuto, M. Schwartz, V. Bohossian, and J. Bruck, “Codes for multi-level flash memories: correcting asymmetric limited-magnitude errors,”in Proceedings IEEE International Symposium on Information Theory ,Nice, France, June 2007.[4] G.D. Cohen, P. Godlewski, and F. Merkx, “Linear binary code for write-once memories,” IEEE Trans. Inform. Theory, vol. 32, pp. 697-700,October 1986.[5] B. Eitan and A. Roy, “Binary and multilevel flash cells,” in FlashMemories, P. Cappelletti, C. Golla, P. Olivo, E. Zanoni Eds. Kluwer,pp. 91-152, 1999.[6] A. Fiat and A. Shamir, “Generalized write-once memories,” IEEE Trans.Inform. Theory, vol. 30, pp. 470–480, September 1984.[7] E. Gal and S. Toledo, “Algorithms and data structures for flash memo-ries,” ACM Computing Surveys , vol. 37, no. 2, pp. 138–163, June 2005.[8] S. Gregori, A. Cabrini, O. Khouri, and G. Torelli, “On-chip error correct-ing techniques for new-generation flash memories,” in Proceedings ofThe IEEE , vol. 91, no. 4, pp. 602-616, April 2003.[9] M. Grossi, M. Lanzoni, and B. Ricco, “Program schemes for multilevelflash memories,” in Proceedings of the IEEE , vol. 91, no. 4, pp. 594-601,April 2003.[10] A. Jiang, “Information storage in flash memories with floating codes,”in Proceedings 45-th Annual Allerton Conference on Communication,Control and Computing , Monticello, IL, September 2007.[11] A. Jiang, “On the generalization of error-correcting WOM codes,” in Proceedings IEEE International Symposium on Information Theory ,Nice, France, June 2007.[12] A. Jiang, V. Bohossian, and J. Bruck, “Floating codes for joint infor-mation storage in write asymmetric memories,” in Proceedings IEEEInternational Symposium on Information Theory , Nice, France, June2007.[13] A. Jiang and J. Bruck, “Joint coding for flash memory storage,” in Proceedings IEEE International Symposium on Information Theory ,Toronto, Canada, July 2008.[14] A. Jiang, R. Mateescu, M. Schwartz, and J. Bruck, “Rank modulationfor flash memories,” in Proceedings IEEE International Symposium onInformation Theory , Toronto, Canada, July 2008.[15] A. Jiang, M. Schwartz, and J. Bruck, “Error-correcting codes for rankmodulation,” in Proceedings IEEE International Symposium on Infor-mation Theory , Toronto, Canada, July 2008.[16] D. Kahng and S.M. Sze, “A floating-gate and its application to memorydevices,” Bell Systems Tech. J. , vol. 46, no. 4, pp. 1288-1295, 1967. [17] M. Mitzenmacher, Z. Liu, and H. Finucane, “Designing floating codesfor expected performance,” in Proceedings 46-th Annual Allerton Con-ference on Communication, Control and Computing , Monticello, IL,September 2008.[18] R.L. Rivest and A. Shamir, “How to reuse a write-once memory,” Infor-mation and Control , vol. 55, nos. 1–3, pp. 1–19, December 1982.[19] B. Van Zeghbroeck, Principles of semiconductor devices , e-book pub-lished online at