# Multilevel Storage and Redundant Arithmetic

MathJax.Hub.Config({tex2jax: {inlineMath: [[‚$‘,’$‘], [‚\$$‘,’\$$‘]]}});

Besides the non-volatility memristors show another useful property, when it comes to its storage capability. Since the transitions between LRS and HRS are a gradual process, we can abort it inbetween. This way we can generate multiple stable states between LRS and HRS. Because of this memristors have multi-level cell (MLC) capability, i.e. they can store more than 2 values.

This allows not only to store data more densely, but to explore multi-valued logic and non-unique number representations, without an increase in number of bits needed to store results and intermediary results.

Our working group is researching ternary number representations and optimized arithmetic units based on this principle. Ternary numbers are represented using the digits $$\{-1,0,1\}$$ instead of $$\{0,1\}$$ as used in the usual binary encoding. Ternary numbers are not unique, for example can the 2-bit number 1, normally represented as 01, also represented using the ternary representations 01 and 1-1. It can easily be seen, that the equality of these numbers hold:

$$1 = \mathtt{01} = 0 \times 2^1 + 1 \times 2^0 = 1 \times 2^1 + -1 \times 2^0 = \mathtt{1{-1}} = 1$$

Using this representation it is possible to construct an adder that works in constant time and uses linear space with respect to the number of trits. This beats the conventional adders, the carry-ripple adder and the carry-lookahead adder.

### Construction To understand how our adder works, one needs to understand what aspect actually makes addition problematic: First consider the addition of 01 + 01 (See Figure ? a)). In this example we first add the first place which yields a carry and add it to the sum of the second digits which is 0. In this case we could also have calculated the digits in parallel, since no additional carry was generated by an incoming carry of a digit to the right. But this is always a possibility: For example, consider 11 + 01 (See Figure ? b)). The addition of the first digit gives 0 and a carry. The sum of the second digits gives 1. In this case the carry of 1 + 1 of the right digit generates another carry to the right. It can be seen, that having 0 + 1 or 1 + 0 in a digit will give 1 and will trigger an outgoing carry, if there is an incoming carry. We therefore try to avoid having digits add up 1.

Our method is a two-step process. At first we generate a carry-vector c and a sub-total z of the digits and then add these up. The way we generate the carry-vector and the sub-total avoids digit-sum being 1. For the addition of 1 and 1 we get 0 for the sub-total and 1 for the carry. For 0 and 0 we get 0 for both the carry and the sub-total. So far, this is nothing noteworthy, since this is how a conventional full adder works. For the 0 + 1 and 1 + 0 cases we do not generate 0 as carry and 1 as sub-total, but instead 1 for the carry and -1 for the sub-total. Recall that $$1 = \mathtt{01} = 0 * 2^1 + 1 * 2^0 = 1 * 2^1 + -1 * 2^0 = \mathtt{1{-1}} = 1$$. This first step can be performed independently for every digit and therefore has a time complexity of $$\mathcal{O}(1)$$ and a space complexity of $$\mathcal{O}(n)$$. You can see examples in Figure ? c) and d).

In the next step we add the carry and the sub-total. The sub-total can only contain -1 and 0 as digits and the carry-vector only 0 and 1, because of the rules stated in the previous paragraph. The addition of carry and sub-total can not generate carries at all and can be done with half adders alone and therefore has a time complexity of $$\mathcal{O}(1)$$ and a space complexity of $$\mathcal{O}(n)$$. Since the signals of the sub-total and the carry-vector each only use two values this process can be implemented in regular CMOS, without needing multi-valued logic. Only the storage of the operands needs three-level cells for the trits (ternary digits).

Since the time and space complexities of the two steps are equal, we get for the whole process a time complexity of $$\mathcal{O}(1)$$ and a space complexity of $$\mathcal{O}(n)$$ for n-digit adders.

But the carry-ripple adder has a runtime complexity of $$O(n)$$, since each full adder has to wait for the carry of the previous full adder, except the first one. Our adder can provide the result in $$O(1)$$, since its digits can work independently.
The carry-lookahead adder tries to alleviate the “rippling” of the carry bits, by adding a “lookahead unit” that predicts weather a carry is possible for a block of bits or not. This unit has a space complexity of $$O(n \log n)$$ and reduces the delay complexity down to $$O(\log n)$$.
{"ft_lang_label":"__label__en","ft_lang_prob":0.867335,"math_prob":0.9967627,"size":5571,"snap":"2021-04-2021-17","text_gpt3_token_len":1514,"char_repetition_ratio":0.12897432,"word_repetition_ratio":0.03567681,"special_character_ratio":0.2706875,"punctuation_ratio":0.11347517,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99926907,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-20T11:17:59Z\",\"WARC-Record-ID\":\"<urn:uuid:039055e9-741b-41c4-8a56-e0296a62c2e0>\",\"Content-Length\":\"22719\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c375ba3f-0f33-4c55-8155-946885bb4ac0>\",\"WARC-Concurrent-To\":\"<urn:uuid:ddcfb014-f4c1-443d-91da-a3adf9a93809>\",\"WARC-IP-Address\":\"131.188.16.206\",\"WARC-Target-URI\":\"https://www.cs3.tf.fau.de/research/memristive-computing/multilevel-storage-and-redundant-arithmetic/\",\"WARC-Payload-Digest\":\"sha1:YHM2KHKMRDNAO2CGD2RIBFG54ZM6FFRW\",\"WARC-Block-Digest\":\"sha1:AMAWZPH5FJJY6TSD4YQCGT5Q7CLT64HZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703519984.9_warc_CC-MAIN-20210120085204-20210120115204-00372.warc.gz\"}"}