Fundamental Theory of Devices and Architectures for Memristor-based Computing-in-Memory Chip