Recent progress in silicon photonics has dramatically advanced the possible realization of heterogeneous logic circuits. A variety of Boolean optoelectronic circuits have been proposed5. In this context, experimental investigation of logic operations with both optical and electrical inputs in chip-integrable devices is highly desirable. Here, we present a new kind of photodiode-based logic device using scalable heterojunctions of carbon nanotubes and silicon, the output currents of which can be manipulated completely by both optical and electrical inputs. This provides a novel platform for heterogeneous optoelectronic logic elements with voltage-switchable photocurrent responsivity of > 1 AW-1, photovoltage responsivity of >1×105 VW-1, electrical on/off ratios of >1×105 and optical on/off ratios of >1×104. To demonstrate their scalability, we fabricated a large array of photoactive elements on a centimetre-scalewafer. We also present bidirectional phototransistors and novel clock-triggerable logic elements such as a mixed optoelectronic AND gate, a 2-bit optoelectronic ADDER/OR gate and a 4-bit optoelectronic digital-to-analog converter.