Content uploaded by Kees Schouhamer Immink

Author content

All content in this area was uploaded by Kees Schouhamer Immink on Sep 02, 2021

Content may be subject to copyright.

Efﬁcient Design of Capacity-Approaching

Two-Dimensional Weight-Constrained Codes

Tuan Thanh Nguyen∗, Kui Cai∗, Kees A. Schouhamer Immink†, and Yeow Meng Chee‡

∗Singapore University of Technology and Design, Singapore 487372

†Turing Machines Inc, Willemskade 15d, 3016 DK Rotterdam, The Netherlands

‡Department of Industrial Systems Engineering and Management, National University of Singapore, Singapore

Emails: {tuanthanh nguyen,cai kui}@sutd.edu.sg, immink@turing-machines.com, pvocym@nus.edu.sg

Abstract—In this work, given n, p > 0, efﬁcient encoding/decoding

algorithms are presented for mapping arbitrary data to and from

n×nbinary arrays in which the weight of every row and every

column is at most pn. Such constraint, referred as p-bounded-

weight-constraint, is crucial for reducing the parasitic currents in

the crossbar resistive memory arrays, and has also been proposed

for certain applications of the holographic data storage. While low-

complexity designs have been proposed in the literature for only

the case p= 1/2, this work provides efﬁcient coding methods that

work for arbitrary values of p. The coding rate of our proposed

encoder approaches the channel capacity for all p.

I. INTRODUCTION

A solution for the ever-increasing demand for data storage

capacity is to scale the storage density while maintaining its reli-

ability. Particularly, in the resistive memory crossbar arrays or the

holographic recording systems, the information data is regarded

as two-dimensional (2D) instead of one-dimensional (1D). Cor-

respondingly, new types of 2D constraints are introduced into

the input information data to improve the system reliability. In

this work, we focus on constraint, namely 2D bounded-weight-

constraint. We next brieﬂy describe the applications of such a

constraint in practical data storage systems.

In resistive memory, the memory cell is a passive two-terminal

device that can be both read and written over a simple crossbar

structure [1]–[6], which facilitates a huge density advantage.

However, a fundamental and challenging problem of the crossbar

memory arrays is the sneak path problem. When a cell in a

crossbar array is read, a voltage is applied upon it, and current

measurement determines whether it is in a low-resistance state

(LRS, corresponding to a ‘1’) or a high-resistance state (HRS,

corresponding to a ‘0’). Sneak paths are an effect by which

in parallel to the desired measurement path, alternative current

paths through other array cells distort the measurement, which

may result in reading an erroneous state. The sneak path problem

was addressed by numerous works with different approaches and

at various system layers [7]–[11]. An effective method to reduce

the sneak path effect is by enforcing fewer memory cells with

the LRSs. This can be achieved by applying constrained coding

techniques to convert the user data into 2D-constrained array

that limits number of 1’s in every row and every column. For

example, Ordentlich and Roth [7] required the weight in every

row and every column to be at most half, and presented efﬁcient

encoders with redundancy at most 2nfor n×narray. In [12],

the authors studied the bounds of codes that required the weight

in every row and every column is precisely pn and provided

a coding scheme based on the enumeration coding technique.

In this work, we provide efﬁcient designs for n×nbinary

arrays that satisfy the p-bouned-weight-constraint, in which the

weight in every row and every column is at most pn for

arbitrary p∈(0,1). Besides resistive memory, this constraint

has been proposed for applications in holographic memory as

well [12], [13]. Particularly, Talyansky et al. [13] studied the t-

conservative arrays constraint, where every row (not necessary

column) has at least ttransitions 0→1or 1→0for some

t6n/(2 log n)−O(log n). It is easy to verify that such

constraint is equivalent to the p-bounded-weight constraint for

p= 1 −1/(2 log n)>1/2in a weaker condition, where the

weight-constraint is enforced in the rows only. We show that

our encoders can be used for such a constraint with a strictly

larger range of t(refer to Section III, Remark 1).

While 1D-constraints have been extensively investigated, the

study for 2D-constraints is much less profound. The main reason

is due to the provable difﬁculty of 2D-constraints compared to

1D-constraints. For example, consider certain weight-constrained

codes such as the balanced codes or constant-weight codes, there

are several efﬁcient prior-art coding methods for designing 1D-

codes with optimal or almost optimal redundancy [14]–[17].

Here, almost optimal refers to the cases that the encoder’s

redundancy is at most a constant bit away from the optimal re-

dundancy. Consider such constraints in 2D-codes, although low-

complexity encoding algorithms have been introduced, there is

still a big gap between the corresponding encoder’s redundancy

and the optimal value.

For 2D p-bounded-weight-constraint, one may use the method

proposed by Ordentlich and Roth [12] for arbitrary p∈(0,1) or

the recent method proposed by Nguyen et al. [21] for p61/2.

Both methods are based on the enumeration coding technique,

that resulted in high complexity encoding/decoding. The main

contribution of this work is to further reduce the redundancy of

previous known encoders for p-bounded-weight-constraint while

having a lower complexity of encoding/decoding algorithm. Our

coding scheme works for arbitrary values of p∈(0,1) and the

rates of our proposed encoders approach the channel capacity.

The coding method can be easily modiﬁed to construct m×n

arrays.

We ﬁrst go through certain notations and review prior-art

coding techniques.

II. PRELIMINARIES

A. Notations

Given two binary sequences x=x1. . . xmand y=y1. . . yn,

the concatenation of the two sequences is deﬁned by xy ,

x1. . . xmy1. . . yn.For a binary sequence x, we use wt(x)to

denote the weight of x, i.e the number of ones in x. We use x

to denote the complement of x. For example, if x= 00111 then

wt(x) = 3 and x= 11000.

Let Andenote the set of all n×nbinary arrays. The ith row of

an array A∈Anis denoted by Aiand the ith column is denoted

by Ai. We use Ai;hjito denote the sequence obtained by taking

the ﬁrst jentries of the row Aiand use Ai;hjito denote the

sequence obtained by taking the ﬁrst jentries of the column Ai.

Given n, p > 0, we set

B(n, p) = nA∈An: wt(Ai)6pn and wt(Ai)6pn for 16i6no.

The channel capacity is deﬁned by

cp,lim

n→∞

log |B(n, p)|

n2.

In this work, we are interested in the problem of designing

efﬁcient coding methods that encode (decode) binary data to

(from) B(n, p).

Deﬁnition 1. The map EN C :{0,1}k→ {0,1}n×nis a p-

bounded-weight-constrained encoder if ENC(x)∈B(n, p)for all

x∈ {0,1}kand there exists a decoder map DEC :{0,1}n×n→

{0,1}ksuch that DEC ◦ENC (x) = x. The redundancy of the

encoder is measured by the value n2−k(bits).

Our design objectives include low redundancy (equivalently,

high code rate) and low complexity of the encoding/decoding

algorithms. In this work, the rates of our constructive codes

approach the channel capacity for all values of p. Particularly,

for p>1/2, we have cp= 1.

B. Previous Works

We brieﬂy describe the works on the p-bounded-weight

constraint by Ordentlich and Roth in [7], [12] that provided

encoding/decoding algorithms for B(n, p).

•For p= 1/2, i.e. the weight of every row and every

column is at most n/2. In [7], the authors presented two low

complexity coding methods. The ﬁrst method is based on

ﬂipping rows and columns of an arbitrary binary array until

the weight-constraint is satisﬁed in all rows and columns

while the second method is based on efﬁcient construction

of antipodal matching. Both codes have roughly 2nredun-

dant bits. A lower bound on the optimal redundancy was

shown to be λn +o(n)for a constant λ≈1.42515 in

[20]. Note that these two methods can be used to construct

B(n, p)for arbitrary p > 1/2since B(n, 1/2) ⊂B(n, p)

for all p > 1/2.

•For p < 1/2, one may follow the coding method in

[12], based on enumeration coding, that ensure the weight

in every row and every column to be precisely pn. The

redundancy of the proposed encoder was at most 2nµ(n, p),

where µ(n, p)is the least redundancy required to encode

one-dimensional binary codewords of length nsuch that

the weight is pn. If we set

Q(n, p) = nx∈ {0,1}n: wt(x) = pno,

then we have µ(n, p) = nH(p)−log |Q(n, p)|where

H(p) = −plog p−(1 −p) log(1 −p). It is easy to verify

that µ(n, p) = Θ(n)for all p < 1/2. In addition, Ordentlich

and Roth [12] also provided a lower bound on the optimal

redundancy, which is at least 2nµ(n, p)+O(n+ log n)bits.

In this work, we propose two efﬁcient coding methods for

B(n, p). The ﬁrst method combines the sequence replacement

technique and antipodal matching to encode B(n, p)for arbitrary

p > 1/2with n+ 3 redundant bits. On the other hand, the

second method, based on Knuth’s balancing technique, uses at

most nµ(n, p) + O(nlog n)redundant bits to construct B(n, p)

for arbitrary p < 1/2. We review below the antipodal matching

(deﬁned in [7]) and the linear-time encoder for weakly-balanced

binary codes [18], as they will be used in our proposed 2D

constrained coding methods.

Deﬁnition 2 (Ordentlich and Roth [7]).An antipodal matching φ

is a mapping from {0,1}nto itself with the following properties

holding for every x∈ {0,1}n:

1) wt(φ(x)) = n−w(x).

2) If wt(x)> n/2then φ(x)has all its 1’s in positions where

xhas 1’s. In other words, suppose x=x1x2. . . xnand

y=φ(x) = y1y2. . . yn, then yi= 1 implies xi= 1 for

16i6n.

3) φ(φ(x)) = x.

Ordentlich and Roth [7] presented an efﬁcient construction

of antipodal matchings φfor all n. In fact, such an antipodal

matching can be decomposed into a collection of bijective

mappings φ=∪n

i=0φiwhere

φi:nx∈ {0,1}n: wt(x) = io→nx∈ {0,1}n: wt(x) = n−io.

The authors showed that φican be constructed in linear-time

for all n, i.

In [18], we studied the weakly-balanced constraint that en-

forces the weight-constraint over every window of size `=

Ω(log n), and showed that for arbitrary p1, p2, where 06

p1<1/2< p261, for sufﬁcient n, there exists a linear-

time algorithm to encode binary data to codewords of length

nwith only 1 redundant bit. Our coding method is based on

the sequence replacement technique and the complexity of the

algorithm was shown to be linear in codeword’s length [18].

Theorem 1 (Nguyen et al. [18]).Given p1, p2where 06

p1<1/2< p261, let c= min{1/2−p1, p2−1/2}.

For (1/c2) logen6`6n, there exists linear-time algorithm

ENC :{0,1}n−1→ {0,1}nsuch that for all x∈ {0,1}n−1if

y=ENC(x)then wt(y)∈[p1n, p2n]) and for every window w

of size `of y,wt(w)∈[p1`, p2`].

III. CONSTRUCTION OF B(n, p)FOR p > 1/2

Recall that the encoders proposed in [7] can be used for

constructing B(n, p)when p > 1/2, and the redundancy is

roughly 2n(bits). In this section, we provide a linear-time

encoder for B(n, p)where p > 1/2with at most (n+ 3)

redundant bits.

Set m=n2−(n+3),`=n,p1= 0,p2=pand c=p−1/2.

According to Theorem 1, for sufﬁcient nthat (1/c2) loge(n2−

n−3) 6n6n2−n−3, there exists linear-time encoder,

ENCseq :{0,1}m→ {0,1}m+1 such that for all x∈ {0,1}m

and y=ENCseq (x)we have wt(w)∈[0, pn]for every window

wof size nof y. In addition, we follow [12] to construct the

antipodal matchings φfor sequences of length n−1.

We now describe the detailed construction of the p-bounded-

weight-constrained encoder, ENCB(n,p). We have p > 1/2in all

our descriptions in this part.

p-bounded-weight-constrained encoder, ENCB(n,p).

INP UT:x∈ {0,1}m

OUTPUT:A,ENCB(n,p)(x)∈B(n, p)with p > 1/2

(I) Set y=EN Cseq(x)∈ {0,1}m+1 . Suppose that y=

y1y2. . . yn2−n−2.

(II) Fill n2−n−1bits of yto Arow by row as follows.

•Set Ai,yn(i−1)+1 . . . yni for 16i6n−2.

•Set An−1,yn(n−2)+1 . . . yn2−n−2∗1∗2, where ∗1,∗2

are determined later.

•Suppose that An=z1z2. . . znwhere ziis determined

later.

•If wtAn−1;hn−2i> p(n−2), ﬂip all bits in

An−1;hn−2iand set ∗1= 1, otherwise set ∗1= 0.

(III) For 16i6(n−1), we check the ith column:

•if wtAi;hn−1i> pn, set zi= 1 and replace

Ai;hn−1iwith φAi;hn−1i

•Otherwise, set zi= 0.

(IV) Check the nth row:

•If wtAn;hn−1i> pn, set ∗2= 1 and replace

An;hn−1iwith φAn;hn−1i

•Otherwise, set ∗2= 0.

(V) Check the nth column:

•If wtAn;hn−1i> pn, set zn= 1 and replace

An;hn−1iwith φAn,hn−1i.

•Otherwise, set zn= 0.

(VI) Output A.

Theorem 2. The Encoder ENCB(n,p)is correct. In other words,

ENCB(n,p)(x)∈B(n, p)with p > 1/2for all x∈ {0,1}m. The

redundancy is n+ 3 (bits).

Proof. Let A=ENCB(n,p)(x). We ﬁrst show that the weight of

every column of Ais at most pn. From Step (III) and Step (V),

the encoder guarantees that the weights of ncolumns are at most

pn. Although there is a replacement in the nth row, it does not

affect the weight of any column. Indeed, if wt(x)> n/2, then

φ(x)has all its 1’s in positions where xhas 1’s and wt(φ(x)) 6

n/2. Therefore, whenever the encoder performs replacement step

in any row (or respectively any column), it does not increase the

weight of any column (or respectively any row). Therefore, we

conclude that wtAi6pn for all 16i6n.

We now show that the wtAi6pn for all 16i6n.

From Step (IV), we observe that the nth row satisﬁes the

weight-constraint. As mentioned above, during Step (III) and

Step (V), whenever the encoder performs replacement step in

any column, it does not increase the weight of any row, i.e. the

weight-constraint is preserved over the ﬁrst (n−2) rows that

is guaranteed by the Encoder ENCseq from Step (I). It remains

to show that the (n−1)th row satisﬁes the weight constraint

with the determined values of ∗1,∗2. Indeed, from Step (II), if

∗1= 0, we have:

wtAn−16p(n−2) + 1 = pn + (1 −2p)6pn.

Otherwise,

wtAn−1<(1 −p)(n−2) + 2 < pn for all n > 2/(2p−1).

In conclusion, we have ENCB(n,p)(x)∈B(n, p)for all x∈

{0,1}m. Since m=n2−(n+3), the redundancy of our encoder

is n+ 3 (bits).

For completeness, we describe the corresponding decoder

DECB(n,p)as follows.

p-bounded-weight-constrained decoder, DECB(n,p).

INP UT:A∈B(n, p)

OUT PU T:x,DEC B(n,p)(A)∈ {0,1}m, where m=n2−n−3

(I) Decode the nth column, An. If the last bit is 1, ﬂip it

to 0 and replace An;hn−1iwith φAn;hn−1i. Otherwise,

proceed to the next step.

(II) Decode the nth row, An. Check the last bit in An−1, if it

is 1, ﬂip it to 0 and replace An;hn−1iwith φAn;hn−1i.

Otherwise, proceed to the next step.

(III) Decode the (n−1)th row, An−1. Check the second last

bit in An−1, if it is 1, ﬂip all the bits in An−1. Otherwise,

proceed to the next step.

Suppose the nth row is now An=z1z2. . . zn.

(IV) For 16i6(n−1), we decode the ith column, i.e. Ai,

as follows. If zi= 1, replace Ai;hn−1iwith φAi,hn−1i.

(V) Set y,A1A2. . . An−2An−1;hn−2i∈ {0,1}n2−n−2.

(VI) Output x,DE Cseq(y)∈ {0,1}n2−n−3.

Complexity analysis. For n×narrays, it is easy to verify

that Encoder ENCB(n,p)and Decoder DE CB(n,p)have linear-time

complexity. Particularly, there are at most n+ 2 replacements,

each replacement is done over sequence of length n, and the

complexity of encoder/decoder EN Cseq,DECseq is linear over

codeword length m=n2−n−3 = Θ(n2). We conclude that

the running time of Encoder ENCB(n,p)and Decoder D EC B(n,p)

is Θ(n2)which is linear in the message length m=n2−n−3.

Remark 1. In [13], Talyansky et al. studied the t-conservative

arrays constraint, where every row has at least ttransitions 0→

1or 1→0for some t6n/(2 log n)−O(log n)< n/2. Such a

constraint is equivalent to the p-bounded-weight constraint in a

weaker condition, where the weight-constraint is enforced in the

rows only. Indeed, for a sequence x=x1x2. . . xn∈ {0,1}n,

consider the differential of x, denoted by Diﬀ(x), which is a

sequence y=y1y2. . . yn∈ {0,1}n, where y1=x1and yi=

xi−xi−1(mod 2) for 26i6n. We then observe that x

has at least ttransitions if and only if the weight of Diﬀ(x)is

at least t. In addition, the constraint problem where the weight

in every row is at least twhere t < n/2is equivalent to the

constraint problem where the weight in every row is at most t

where t > n/2. Therefore, one may modify the construction of

our proposed encoder ENCB(n,p)(i.e for p= 1 −1/(2 log n)) >

1/2) to construct binary arrays such that there are at least t

transitions in every row and every column with at most n+ 3

redundant bits. When the weight-constraint is only required on

rows, only Step (I) in EN CB(n,p)is sufﬁcient and m=n2−

1. Although there is no improvement in the redundancy (the

encoder in [13] also use only one redundant bit), our encoder

can be applied for a larger range of t, where t6n/c for any

c > 2.

IV. CONSTRUCTION OF B(n, p)FO R p61/2

The sequence replacement method to construct EN Cseq ,

DECseq is efﬁcient in terms of redundancy (only one bit)

and running time complexity (linear-time). However, it is not

applicable to the cases when p61/2. For such cases, we

adapt the enumeration coding technique and a modiﬁcation of

the Knuth’s balancing technique [15]. Compare to literature

works in [12], [21] that also used modiﬁcations of enumeration

coding technique, the major difference of our coding method is

that the rows and columns are encoded independently, and the

two-dimensional code construction can be divided to two one-

dimensional code constructions. In other words, the complexity

of our encoder mainly depends on the efﬁciency of enumeration

coding for one dimensional codes.

In general, a ranking function for a ﬁnite set Sof cardinality N

is a bijection rank : S→[N]where [N],{0,1,2, . . . , N −1}.

Associated with the function rank is a unique unranking function

unrank : [N]→S, such that rank(s) = jif and only if

unrank(j) = sfor all s∈Sand j∈[N]. Given n, p > 0,

let S(n, p),nx∈ {0,1}n: wt(x)6pno, i.e. S(n, p)is

the set of all one dimensional sequences that satisfy the p-

bounded-weight constraint. One may use enumeration coding

[22], [23] to construct rankp:S(n, p)→[|S(n, p)|]and

unrankp: [|S(n, p)|]→S(n, p). The redundancy of this

encoding algorithm is then λ(n, p) = n−log |S(n, p)|(bits).

A. Construction of B(n, p)for p < 1/2

We now present efﬁcient encoding method for B(n, p)for

given p < 1/2. Recall that one may follow the coding method

in [12], based on enumeration coding, that ensure the weight in

every row and every column to be precisely pn. The redundancy

of the proposed encoder was at most 2nµ(n, p), where µ(n, p)is

the least redundancy required to encode one-dimensional binary

codewords of length nsuch that the weight is pn (refer to

Section II-B). It is easy to verify that λ(n, p)6µ(n, p). The

redundancy of our encoder is at most nλ(n, p) + O(nlog n)6

nµ(n, p)+ O(nlog n)bits. Our method is based on the enumera-

tion coding [22], [23] used to enforce the weight-constraint in all

rows (here rows are encoded/decoded independently) and swap,

used to enforce the weight-constraint in all columns (without

changing the weight in any row). The swap method is a simple

modiﬁcation of Knuth’s balancing technique [15], which was

also introduced in [13] for balanced codes.

We ﬁrst deﬁne p-bouned-weight-constraint in a general way.

Let xbe a q-dimensional binary vector (q>1) contains a

total of nbits. We say xis p-bounded if the weight of x

(also deﬁned by the number of 1’s in x) is at most pn. For

simplicity, we assume that pn, log n, (1/p)are integers. Set

m=n−(1/p)(1 + log n), N =m(n−λ(n, p)). We now

describe brieﬂy the main idea of the algorithm. The encoding

method includes three phases.

•In Phase I, the encoder encodes the information of length N

into array Aof size m×nwhere every row is p-bounded,

using the enumeration coding technique. Particularly, the

information is encoded into S(n, p)with the redundancy at

most λ(n, p)bits for each row. Therefore, the redundancy

used in Phase I is at most mλ(n, p)bits.

•In Phase II, the encoder follows the swapping procedure

to ensure that every column of Ais p-bounded. Note that,

from Phase I, array Ais p-bounded. Suppose that at some

encoding step i, we have an array Sof size m×n0, which

is already p-bounded for some n06n(initially, n0≡n).

We then divide Sinto two subarrays of size m×(n0/2),

denoted by LSand RS, and proceed to make sure LSand

RSare both p-bounded. This can be done via a simple

method of swapping the bits in LSand RSas follows.

Swapping Procedure. If both LSand RSare p-bounded

then no action is needed, i.e. the number of swap is 0.

On the other hand, if one of them is not p-bounded, and

w.l.o.g, assume that wt(LS)> pn0while wt(RS)< pn0

where n0=mn0/2. We then swap the bits in LSand RS

respectively in the order from column to column. Observe

that each swap increases or decreases the weight of LS, RS

by one, and when all the bits in LSand RSare swapped,

we have wt(LS)< pn0while wt(RS)> pn0. Therefore,

there must be an index t,16t6n0such that after

swapping tbits, we have wt(LS)< pn0and wt(RS)< pn0.

We refer such an index as a swapping index of LSand

RS. To represent the swapping index t, we need at most

log n0redundant bits. After both subarrays LSand RS

are p-bounded, we continue to divide each of them into

two subarrays and repeat the swapping procedure to ensure

the newly created subarrays are p-bounded. This process

ends when all subarrays of size m×1are p-bounded. We

illustrate the idea of the swapping procedure in Figure 1.

Let re(n)be the sequence obtained by concatenating all

binary representations of the swapping indices. The size of

re(n), is at most

X

k=2j

26k6n

(n/k) log(mk/2) = (n−1)(1 + log m)−log n

< n(1 + log n)(bits).

•In Phase III, the encoder encodes re(n)into an array Bof

size (n−m)×nsuch that its every row and every column is

p-bounded. At the end of Phase III, the encoder outputs the

concatenation of Aand B, which is an array of size n×n.

Recall that n−m= (1/p)(1 +log n). While the encoder in

[13] proceeds to repeat the swapping procedure to encode

re(n), which makes the problem difﬁcult to construct en-

coder for arrays of given size, we show that re(n)can be

encoded/decoded efﬁciently without repeating the swapping

procedure. Suppose that re(n) = x1x2. . . xn(1+log n),re(n)

is encoded to Bas follows. Here 0tdenotes the repetition

of 0for ttimes.

r1

B= (x10

1

p

−1)(xn−m+10

1

p

−1). . . (x(n−m)(n−1)+10

1

p

−1)

r2

B= (0x20

1

p

−2)(0xn−m+20

1

p

−2). . . (0x(n−m)(n−1)+20

1

p

−1)

. . .

ri

B= (0j−1xi0

1

p

−j). . . (0j−1x(n−m)(n−1)+i0

1

p

−j),

where j≡i(mod 1/p)and 16i6n−m. It is easy to

verify that every row and every column of Bis p-bounded

and re(n)can be decoded uniquely from B.

In conclusion, the total redundancy for encoding an n×n

array is at most

mλ(n, p) + (1/p)n(1 + log n)< nλ(n, p) + O(nlog n)bits

< nµ(n, p) + O(nlog n)bits.

Since µ(n, p) = Θ(n), we observe that the code rate of our

proposed encoder approaches the channel capacity. In general,

when pn,log nand 1/p are not integers, we can easily modify

the construction of our encoder and show that the redundancy

is at most nλ(n, p) + O(nlog n)6nµ(n, p) + O(nlog n)bits.

Due to space constraint, we defer the detailed construction for

the general case in the full paper.

Fig. 1: Swapping procedure example for n= 8, p = 1/4. The

current subarray Sis of size 8×4. The subarrays, highlighted

in red, are not p-bounded while those, highlighted in blue, are

p-bounded.

B. Improvement from Literature Works for p= 1/2

While the coding method in Section IV-A can also apply for

p= 1/2, the redundancy of the corresponding encoder will be

higher than literature works [7]. When p= 1/2, we can combine

the enumeration coding technique with the antipodal matching

to further reduce the redundancy of the proposed encoders in [7]

for even nas follows.

For an even n, set N=|S(n, 1/2)|=Pn/2

i=0 n

i. Suppose

that rank : S(n, 1/2) →[N]and unrank : [N]→S(n, 1/2) are

constructed. Given tbinary sequences x1,x2,...,xt, of length

n, we use x1||x2|| . . . ||xtto denote the t×narray where the ith

row is xi.

To encode B(n, 1/2), we ﬁrst ensure that the constraint is en-

forced over every row. Particularly, the information is encoded in

the ﬁrst (n−2) rows using enumeration coding, the information

in the (n−1)th is done via simple ﬂipping (we also reserve the

last two bits in this row as redundant bits), and the entire last

row is reserved for redundant bits.

For x∈ {0,1}(n−2) log N, suppose d∈[Nn−2]that takes xas

the binary representation of length (n−2) log N, we represent d

in N-ary representation as d=Pn−2

i=1 di×Ni−1. Suppose that

ri

A= unrank(di), we then set EN C∗(x) = r1

A||r2

A|| . . . ||rn−2

A.

For 16i6n−2, if rank(ri

A) = diwhere di∈[N], then

DEC∗(r1

A||r2

A|| . . . ||rn−2

A) = rank(d1)rank(d2). . . rank(dn−2).

Recall that the right hand side is the concatenation of (n−2)

sequences of length log N. We are now ready to present the

construction of ENCB(n,1/2) ,DECB(n,1/2) . The construction is

similar to the construction of B(n, p)for p > 1/2.

Encoder, EN CB(n,1/2).

Preparation phase. Given n > 0, n is even, set N=

|S(n, 1/2)|, and m= (n−2) log N+ (n−2).

INP UT:x∈ {0,1}m

OUT PU T:A,ENC B(n,1/2)(x)∈B(n, 1/2)

(I) Set x1be the preﬁx of length (n−2) log Nof xand x2

be the sufﬁx of length n−2of x.

(II) Set B=EN C∗(x1)which is a (n−2) ×narray.

(III) For 16i6n−2set Aibe the ith row of B.

(IV) Set An−1=x2∗1∗2where ∗1,∗2∈ {0,1}that are

determined later.

•If wt(x2)>1/2(n−2), we set ∗1= 1 and ﬂip every

bit in x2, i.e. replace x2with the complement x2.

•Otherwise, set ∗1= 0.

Suppose that An=z1z2. . . zn.

(V) For 16i6(n−1), we check the ith column:

•if wtAi;hn−1i>1/2(n−1), set zi= 1 and replace

Ai;hn−1iwith φAi;hn−1i

•Otherwise, set zi= 0.

(VI) Check the nth row:

•If wtAn;hn−1i>1/2(n−1), set ∗2= 1 and replace

An;hn−1iwith φAn;hn−1i

•Otherwise, set ∗2= 0.

(VII) Check the nth column:

•If wtAn;hn−1i>1/2n, set zn= 1 and replace

An;hn−1iwith φAn;hn−1i.

•Otherwise, set zn= 0.

(VIII) Output A.

V. CONCLUSION

We have presented efﬁcient encoding/decoding algorithms for

mapping arbitrary binary data to binary arrays of size n×nthat

satisfy the p-bounded-weight constraint, i.e. the weight in every

row and every column is at most pn. Our proposed encoders have

low complexity, and the rate approaches the channel capacity for

all values of p∈(0,1).

ACKNOWLEDGMENT

The work of Kui Cai and Tuan Thanh Nguyen is supported

by Singapore Ministry of Education Academic Research Fund

MOE2019-T2-2-123. The research of Yeow Meng Chee is

supported by the Singapore Ministry of Education under grant

MOE2017- T3-1-007.

REFERENCES

[1] D. B. Strukov, G. S. Snider, D. R. Stewart, and R. S. Williams, “The

missing memristor found,” Nature, vol. 453, pp. 80-83, May 2008.

[2] H. H. Li, Y. Chen, C. Liu, J. P. Strachan, N. Davila, “Looking ahead for

resistive memory technology: A broad perspective on ReRAM technology

for future storage and computing,” IEEE Consum. Electron. Mag., vol. 6,

no. 1, pp. 94-103, Jan. 2017.

[3] A. Chen, “Accessibility of nano-crossbar arrays of resistive switching

devices,” Proc. 11th IEEE Int. Conf. Nanotechnol., pp. 1767-1771, Aug.

2011.

[4] T. Raja and S. Mourad, “Digital logic implementation in memristor-based

crossbars,” Proc. Int. Conf. Commun. Circuits Syst. (ICCCAS), pp. 303-309,

Jan. 2009.

[5] S. Kvatinsky, G. Satat, N. Wald, E. G. Friedman, A. Kolodny, and U.

C. Weiser, “Memristor-based material implication (imply) logic: Design

principles and methodologies,” IEEE Trans. Very Large Scale Integr. (VLSI)

Syst., vol. 22, no. 10, pp. 2054-2066, Oct. 2014.

[6] R. Ben Hur and S. Kvatinsky, “Memory processing unit for in-memory

processing,” in Proc. IEEE ACM Int. Symp. Nanosc. Archit., pp. 171-172,

Jul. 2016.

[7] E. Ordentlich and R. M. Roth, “Low complexity two-dimensional

weight-constrained codes,” 2011 IEEE International Symposium on In-

formation Theory Proceedings, St. Petersburg, 2011, pp. 149-153, doi:

10.1109/ISIT.2011.6033792.

[8] P. O. Vontobel, W. Robinett, P. J. Kuekes, D. R. Stewart, J. Straznicky,

and R. S. Williams, “Writing to and reading from a nano-scale crossbar

memory based on memristors,” Nanotechnology, vol. 20, no. 42, Sep. 2009,

Art. no. 425204.

[9] Y. Cassuto, S. Kvatinsky and E. Yaakobi, “Information-Theoretic Sneak-

Path Mitigation in Memristor Crossbar Arrays,” in IEEE Transactions

on Information Theory, vol. 62, no. 9, pp. 4801-4813, Sep. 2016, doi:

10.1109/TIT.2016.2594798.

[10] X. Zhong, K. Cai, G. Song and N. Raghavan, “Deep Learning Based

Detection for Mitigating Sneak Path Interference in Resistive Mem-

ory Arrays,” 2020 IEEE International Conference on Consumer Elec-

tronics - Asia (ICCE-Asia), Seoul, 2020, pp. 1-4, doi: 10.1109/ICCE-

Asia49877.2020.9277380.

[11] G. Song, K. Cai, X. Zhong, J. Yu, and J. Cheng, “Performance Limit and

Coding Schemes for Resistive Random-Access Memory Channels”, arXiv,

arXiv:2005.02601.

[12] E. Ordentlich and R. M. Roth, “Two-dimensional weight-constrained

codes through enumeration bounds,” in IEEE Transactions on Information

Theory, vol. 46, no. 4, pp. 1292-1301, Jul. 2000, doi: 10.1109/18.850669.

[13] R. Talyansky, T. Etzion, and R. M. Roth, “Efﬁcient Code Constructions for

Certain Two-Dimensional Constraints”, IEEE Transactions on Information

Theory, vol. 45, no. 2, pp. 794-799, Mar. 1999.

[14] K. A. S. Immink and J. H. Weber, “Very Efﬁcient Balanced Codes”, IEEE

J. Selected Areas Comms., vol. 28, no. 2, pp. 188-192, 2010.

[15] D.E.Knuth, “Efﬁcient Balanced Codes”, IEEE Trans. Inform. Theory,

vol.IT-32, no. 1, pp. 51-53, Jan. 1986.

[16] N. Alon, E. E. Bergmann, D. Coppersmith, and A. M. Odlyzko, “Balancing

sets of vectors”, IEEE Trans. Inf. Theory, vol. IT-34, no. 1, pp. 128-130,

Jan. 1988.

[17] V. Skachek and K. A. S. Immink, “Constant Weight Codes: An Approach

Based on Knuth’s Balancing Method,” in IEEE Journal on Selected

Areas in Communications, vol. 32, no. 5, pp. 909-918, May 2014, doi:

10.1109/JSAC.2014.140511.

[18] T. Thanh Nguyen, K. Cai and K. A. Schouhamer Immink, “Binary

Subblock Energy-Constrained Codes: Knuth’s Balancing and Sequence

Replacement Techniques,” 2020 IEEE International Symposium on In-

formation Theory (ISIT), Los Angeles, CA, USA, 2020, pp. 37-41, doi:

10.1109/ISIT44484.2020.9174430.

[19] T. T. Nguyen, K. Cai, K. A. Schouhamer Immink and H. Mao Kiah, “Con-

strained Coding with Error Control for DNA-Based Data Storage,” 2020

IEEE International Symposium on Information Theory (ISIT), Los Angeles,

CA, USA, 2020, pp. 694-699, doi: 10.1109/ISIT44484.2020.9174438.

[20] E. Ordentlich, F. Parvaresh and R. M. Roth, “Asymptotic enumeration of

binary matrices with bounded row and column weights,” 2011 IEEE In-

ternational Symposium on Information Theory Proceedings, St. Petersburg,

2011, pp. 154-158, doi: 10.1109/ISIT.2011.6033804.

[21] C. D. Nguyen, V. K. Vu, and K. Cai, “Two-Dimensional Weight-

Constrained Codes for Crossbar Resistive Memory Arrays”, IEEE Com-

mun. Lett., Early Access.

[22] T. M. Cover, “Enumerative source encoding,” IEEE Transactions on

Information Theory, vol. 19, no. 1, pp. 73-77, Jan. 1973.

[23] K. A. S. Immink, Codes for Mass Data Storage Systems, Second Edition,

ISBN 90-74249-27-2, Shannon Foundation Publishers, Eindhoven, Nether-

lands, 2004.