## 2 Demonstration of Ternary Logic Gates  
In conventional binary Boolean Logic, there are a total of 2\({}^{2}\) = 4 monadic functions. While in ternary logic [6], the number of monadic functions is 3\({}^{3}\) = 27. These 27 ternary functions are enumerated from 0 to 9 and then A to Z, as shown in Figure 1a. Strictly speaking, we do not need all of these functions because there are strong relationships between such operations in Boolean Algebra. Several of them are nontrivial and meaningful [6]. For example, functions 0, D, and Z are the trivial, constant-valued functions; Function P is identity; Function 5 is the standard ternary inverter (STI); Functions 2 and 8 are the negative threshold inverter (NTI) and positive threshold inverter (PTI), respectively; Functions 7 and B are increment cycling inverter (ICI) and decrement cycling inverter (DCI), respectively. It is widely accepted that the most important and fundamental components in ternary logic are STI, NTI and PTI [9; 10; 11; 12]. The output-input characteristic curves of such ternary functions have been shown in Figure 1b. STI is actually a ternary NOT function that inverts its input, returning \"0\" when given \"2\" and vice versa, while leaving \"1\" inputs unchanged; NTI inverts the input of \"2\" and \"0\" as same as the NOT function, but returns \"0\" when given \"0\"; PTI inverts the input of \"2\" and \"0\", but returns \"2\" when given \"1\". Cycling ternary (CT) gates can operate the increment function (output = input + 1) or decrement function (output = input - 1), which are especially suitable for the ternary ripple-carry adder. While we still do not need both of them, since \((\mathrm{a}-1)=((\mathrm{a}+1)+1)=-(-\mathrm{a}+1)\), which means a decrement gate can be achieved by two increment gates, or by two NOT gates together with one increment gate. Similarly for the increment gate, it can be achieved by using two decrement gates, or by two NOT gates plus one decrement gate because \((\mathrm{a}+1)=((\mathrm{a}-1)-1)=-(-\mathrm{a}-1)\). By utilizing the unique electronic properties of ambipolar BP transistors and N-type MoS\({}_{2}\) transistors, the above-mentioned ternary logic gates have been successfully designed and fabricated in this work. The specific fabrication process is described as following. Firstly, commercial-available few-layer black phosphorus and MoS\({}_{2}\) flakes were mechanically exfoliated onto a silicon substrate with a 20 nm HfO\({}_{2}\) high-k dielectric layer. Then the flakes were identified under a microscope in a glove box, where the oxygen and humidity were always kept below 0.1 ppm. Next, standard electron-beam lithography and electron-beam evaporation of 20 nm/60 nm Ni/Au were used to form the device structures and metal contacts. After that, the current-voltage performance of the devices was measured  
Figure 1: (**a**) List of the 27 ternary operators. (**b**) Characteristic curves of ideal negative ternary inverter (NTI), standard ternary inverter (STI), positive ternary inverter (PTI) and decrement cycling inverter (DCI) from top to down. in a probe station under high vacuum. BP FETs and MoS\({}_{2}\) FETs with a suitable threshold voltage and on-off ratio, as well as a high mobility, were chosen for the second electron-beam lithography and electron-beam evaporation to fabricate the interconnections. Because the BP flakes were easily deteriorated in air conditions, great attention should be taken to protect the samples during the whole fabrication. The samples should always be kept in the glove box, and the time of exposure to air in-between process steps should be minimized. For the BP-MoS\({}_{2}\)-based standard ternary inverter (Figure 2a,b), unlike previous studies of a CMOS inverter based on a MoS\({}_{2}\) n-type MOSFET and a BP p-type MOSFET [24; 25], the BP channel here is divided into two regions with a short channel of 0.1 \(\upmu\)m and a long channel of 1.8 \(\upmu\)m. We may simply name the in-series MoS\({}_{2}\) FET plus BP1 FET as Part 1, and the BP2 FET as the Part 2, respectively.