The voltage retention circuit 320 (voltage retention circuit 320a) has a function of suppressing a change in the potential of the wiring 259 in the retention operation of the memory device 300 (memory device 300a). The voltage retention circuit 320 (voltage retention circuit 320a) has a function of suppressing a change in the potential of the wiring 259 even when power supply to the memory device 300 (memory device 300a) is stopped. In other words, the voltage retention circuit 320 (voltage retention circuit 320a) has a function of retaining the voltage of the wiring 259. The transistor 323 (transistor 323a) is preferably a transistor having a low off-state current because it retains the voltage of the wiring 259. For example, when the capacitance of the capacitor 324 is 10 pF and an acceptable increase in potential of the wiring 259 is 0.5 V, it takes an hour until the potential of the wiring 259 is increased by 0.5 V in the case where the off-state current of the transistor 323 (transistor 323a) is 1.39×10?15 A, a day in the case where the off-state current of the transistor 323 (transistor 323a) is 5.79×10?17 A, a year in the case where the off-state current of the transistor 323 (transistor 323a) is 1.59×10?19 A, and ten years in the case where the off-state current of the transistor 323 (transistor 323a) is 1.59×10?20 A. When the off-state current of the transistor 323 (transistor 323a) is lower than or equal to 1.59×10?20 A, data written to the memory circuit 310 (memory circuit 310a) can be retained for ten years or more.