Check out The Elements of Computing Systems. It walks you through the construction of a computer starting with just NAND gates. You start by building other logic gates, and then an ALU, CPU, assembler, virtual machine, a compiler for a simple high level language, and finally an operating system. Each chapter gives the necessary background information, and a specification for you to implement.