There's a project out in the Google-verse called LC3B (or the earlier version LC3) which is a hardware design project. The given state diagram can be coded up in VHDL (or whatever) to form a functional CPU with nothing more than an interrupt driven serial port. It has separate system and user privileges and while the instruction set is clearly RISC, there is a C compiler for the LC3 version. I don't know if it has been upgraded for the byte oriented LC3B. There is also an assembler for the LC3 version.
This is a pretty nice project because first you build the CPU, then you add peripherals (PWM, more serial, <whatever>) then you write bare metal code in assembly language. In the end, you will have a pretty good handle on both hardware and embedded programming.
Yeah this is something I would be really interested in doing. Where do I start though? Just reading trough the book you posted or that H&P book? What about that MIPS R2K?
There are going to be a lot of opinions on this. Here's mine: KISS - Keep It Simple Stupid. I like Patt and Patel because they start from the very simple basics of logic gates and work up through an entire CPU with a lot of Computer Science kinds of things mixed in. Fact is, they don't even begin to talk about the CPU until Appendix A and it's in Appendix C (which you can find separately on the Internet) that they even start getting into design.
They give you the hardware diagram, some hardware descriptions of the control and data paths and, ultimately, a table to fill out to create microcode (which I didn't use). They give you a diagram of the COMPLETE state diagram - just convert it to microcode or VHDL. The information is more than sufficient.
Here is Appendix C:
http://people.cs.georgetown.edu/~squier/Teaching/HardwareFundamentals/LC3-trunk/docs/LC3-uArch-PPappendC.pdfThere dozens of videos about LC3 - just Google for 'LC3 video'. These may be an enormous help getting started.
Read through it and see if it makes any sense at all. Then read through it a couple of times to let it sink in. What data is moving where? Which MUX input is being selected when? When you catch on, it's really kind of simple. I suppose it is simpler if it isn't your first rodeo...
There are things you need to know how to write in VHDL. Most important is the Finite State Machine. The entire CPU is one gigantic FSM with some supporting processes around the outside. There is also a serial port which connects to a PC terminal emulator like PuTTY. You are going to subscribe to OpenCores.org and grab a serial core. Just connect up some signals and you're good to go.
Here is just a wee bit of the FSM:
case State is
when 0 => -- Branch Instruction
if BEN = '1' then
NextState <= 22; -- branch is taken
else
NextState <= 18; -- branch not taken
end if;
when 1 => -- ADD Instruction
if Immediate = '1' then
SR2select <= Sext5sel;
else
SR2select <= SR2outSel;
end if;
ALUop <= ALUadd;
GateBusSelect <= GateALU;
LD_Reg <= '1';
LD_CC <= '1';
NextState <= 18;
when 2 => -- LD Instruction
Addr1Select <= Addr1PC;
Addr2Select <= Addr2Sext9;
MARselect <= MARadder;
GateBusSelect <= GateMARmux;
LD_MAR <= '1';
NextState <= 25;
Look how closely this matches the transition diagram. I didn't invent the thing, I just copied from the diagram, substituting names here and there.
The microcode approach won't require nearly as much code but it will be much more obscure. Particularly when making tests that result in different state transitions. I would like to use this approach some time, I like the concept of a reconfigurable processor.
The main code is right at 1000 lines plus several support files which vary from 40 to 100 lines. Nothing significant.
I'm not going to say the project is trivial or even easy. Starting from ground zero, it's a lot of learning. Start by reading through the Appendix and then asking questions. FWIW, I built mine in a large Artix 7. The main selection criteria is that it have enough BlockRAM to support 64k by 16b words. This isn't a hard requirement but it does provide the maximum memory.
Why not start with the RISC-V? It's darn difficult to build pipelined machines. There are some great projects out there, I was reading through the TinyRV1 yesterday. Breaking a CPU down into stages is pretty easy, accounting for the hazards like an instruction using a result that is still in the pipeline makes it really complex.
https://www.csl.cornell.edu/courses/ece4750/handouts/ece4750-T02-proc-uarch.pdfFor a first project, LC3 is more than enough. The nice thing about it is that it has no predefined IO. You can add whatever you like. So, when you want to build a gadget, just plunk in an LC3 core and you have the processor. Add widgets as required...
Here is the book with CD. Make sure you get the CD if you buy a used book!
https://www.amazon.com/Introduction-Computing-Systems-Gates-Beyond/dp/0072467509Alibris has many copies of the previous version - I wouldn't go there just to save $30
There may be enough information on the Interwebs to make buying the book redundant.