2017q3 Homework1 (ternary) === contributed by <`ZixinYang`> --- ### Review by `williamchangTW` - 根據作者的內容,對數位邏輯的部份做了詳細的解釋,讓我有了初步的了解,或許可以搭配電路圖的呈現可以更加了解其中的運作 - 作者有提到 IOTA 其中的一些重點,詳細分析下去應該可以得到不錯的結論 >小弟坐井觀天,如有冒犯請見諒[name="williamchangTW"] --- ## Balanced Ternary 簡介 ### 原理 * 3為基數,每一位元用-1(T),0,1表示 * 因不需額外符號表示負號,故在加減法及乘法上效率較二進位高 * [Ternary Adder](http://homepage.divms.uiowa.edu/~jones/ternary/arith.shtml) * Ternary Multiplier * Truth Table ![Truth Table](https://i.imgur.com/mHTDgE7.png) * K-map ![K-map](https://i.imgur.com/8lbbFKr.png) * Implementation ![Implementation](https://i.imgur.com/dWuKVla.png) * Output equations * F~prod~ = X~1~^1^*X~2~^2^ + X~1~^2^*X~2~^1^ + [X~1~^1^*X~2~^1^ + X~1~^2^*X~1~^2^*X~2~^2^] * F~carry~ = X~1~^2^*X~2~^2^ * 出處:[Ternary Digital System: Concepts and Applications](https://www.researchgate.net/publication/266477093_Ternary_Digital_System_Concepts_and_Applications) P.87 ### 應用案例 * [IOTA](https://iota.readme.io/docs) * [Introduction to IOTA](https://www.youtube.com/watch?v=yj9j_a_ACB4) * Utilize tangle structure instead of blockchain * Directed acyclic graph * No blocks, the structure is very light * Infinitely scalable * No transaction fee and avoid waiting for verification for several days * Why ternary applied on IOT > These 3 states perform transaction very balanced, which is quite helpful to build a self-organizing and self-sustaining network ## 測試 Balanced Ternary * 此表示法為 8 digits 的表示法,範圍為 -3280 ~ +3280 ``` ┌───┐ ┌───┐ ┌───┐ ├───┐ ┌─┴─┐ ┌───┤ ┌───┐ ┌───┐ │ │ │ │ ┤ │ │ │ │ │ │ │ │ ├ │ │ └─┬─┘ ├───┘ └───┘ └───┘ └───┘ └───┘ └───┘ └───┤ (1) (3) (9) (27) (81) (243) (729) (2187) ┌───┐ ┌───┐ ┌───┐ ┌┬──┐ ┌─┬─┐ ┌──┬┐ ┌───┐ ┌───┐ │ │ │ │ ├ │ │ │ │ │ │ │ │ ┤ │ │ └─┴─┘ └┴──┘ └───┘ └───┘ └───┘ └───┘ └───┘ └──┴┘ (-1) (-3) (-9) (-27) (-81) (-243) (-729) (-2187) ``` * [Box-Drawing Character](https://en.wikipedia.org/wiki/Box-drawing_character) ## Balanced Ternary 教學影片重點整理 * Number Systems: Ternary * 十進位轉三進位 * Non-Binary Computing * History * Thomas Fowler Machine (1838) * Calculate up to 87,000 * Do a multiplication/division for doing logarithms * Setun * Composed of 18 ternary digits, giving the machine numerical range of 387 million. A binary computer would need 29 digits to reach the capacity. * As soon as the transistor came out, it was abandoned in favor of binary machine * Conversion * Three trips number system * Positive number: 5 = + - - (+3^2^-3^1^-3^0^) * Negative number: -5 = - + + (-3^2^+3^1^+3^0^) * Range from -13 to +13 ``` -13 --- +13 +++ -12 --0 +12 ++0 -11 --+ +11 ++- -10 -0- +10 +0+ -9 -00 +9 +00 -8 -0+ +8 +0- -7 -+- +7 +-+ -6 -+0 +6 +-0 -5 -++ +5 +-- -4 0-- +4 0++ -3 0-0 +3 0+0 -2 0-+ +2 0+- -1 00- +1 00+ 0 000 ``` * Logic Table Sum | - | 0 | + | | :---: | :---: | :---: | :---: | | - | + | - | 0 | | 0 | - | 0 | + | | + | 0 | + | - | | Carry | - | 0 | + | | :---: | :---: | :---: | :---: | | - | - | 0 | 0 | | 0 | 0 | 0 | 0 | | + | 0 | 0 | + | | Multiply | - | 0 | + | | :---: | :---: | :---: | :---: | | - | + | 0 | - | | 0 | 0 | 0 | 0 | | + | - | 0 | 0 | | Divide| - | 0 | + | | :---: | :---: | :---: | :---: | | - | + |-∞ | - | | 0 | 0 | NAN | 0 | | + | - | ∞ | + | > 嘗試用 Markdown 和 HackMD 擴充語法來處理文字為主的表示法 [name="jserv"][color=red] * Full Adder * Implementation of a full ternary adder (A+B+C=S with C^'^) * Modulo 3 Sum and Product Functions * Ripple Adder in Binary and Ternary Logic * Concepts Review * Half Adder: two inputs (addition for two 1-digit varaibles), two outputs (sum & c_out) * Full Adder: three inputs (two 1-digit variables & carryout from previous adder), two outputs (sum & c_out) * Ripple Adder: composed of full adders to construct an N-digit adder * Binary Ripple Adder * Composed of full adders which are composed of XOR and AND gates * Ternary Ripple Adder * Requires fewer rounds of addition and fewer circuits ## 参考資料 * [Tangle V.S. Blockchain](https://www.youtube.com/watch?v=Mlbz6vDMnZo) * [The Balanced Ternary Machines of Soviet Russia](https://dev.to/buntine/the-balanced-ternary-machines-of-soviet-russia) * [Why Not Ternary Computers?](https://www.techopedia.com/why-not-ternary-computers/2/32427) * [The tangle (White paper)](http://iotatoken.com/IOTA_Whitepaper.pdf)