Devices with PN heterojunction gate