AnyCPU
http://anycpu.org/forum/

Ben Eater's SAP inspired computer implemented in VHDL
http://anycpu.org/forum/viewtopic.php?f=13&t=441
Page 1 of 1

Author:  Xark [ Thu Aug 24, 2017 9:23 pm ]
Post subject:  Ben Eater's SAP inspired computer implemented in VHDL

Hello! I have just recently discovered this forum and I thought some people here might find my latest simple FPGA project mildly interesting.

https://github.com/XarkLabs/BenEaterVHDL

I have implemented a version of Ben Eater's SAP computer (https://eater.net) in VHDL for an FPGA (currently Lattice MachXO2-1200, but it should be easily portable). It is a very simple project, but might be useful for someone who wants to play around with a working implementation. It currently has only 8-bit binary GPIO "output", but it does include a TX only UART (9600 8N1) which produces a real-time "cycle trace" of the CPU (so you get a "log" showing internal CPU state for each cycle that is similar to looking at all the LEDs on Ben's breadboard implementation).

Mostly this project is educational, and eventually I hope to write an article describing the design to help people wrap their head around FPGA (and simple CPU) development.

Enjoy,
Xark - https://hackaday.io/Xark

Author:  BigEd [ Fri Aug 25, 2017 7:55 am ]
Post subject:  Re: Ben Eater's SAP inspired computer implemented in VHDL

Welcome! An interesting project, for sure. Is there a block diagram anywhere, or a table showing the instruction format? Looks like a byte-wide two-register machine with perhaps single-byte instructions - but the details are where it gets interesting!

Author:  Xark [ Fri Aug 25, 2017 9:18 am ]
Post subject:  Re: Ben Eater's SAP inspired computer implemented in VHDL

Hi Ed (love your OPC stuff),

No, this is strictly a toy 4-bit educational CPU (including 4-bit address bus) for TTL on a (large-ish) breadboard. The cool part are the many hours of amazing videos Ben has made showing exactly how he designed and built every single part of the computer and how it all works (all the way from "what is a semiconductor", what is a flip-flop etc.). The actual CPU design is very similar to the SAP-1 from an out of print computer book called Digital Computer Electronics.

I have attached a diagram of the CPU "screen grabbed" from Youtube to this post.

As far as the instruction set, high 4 bits is instruction and low 4 bits are operand (or ignored). Ben hasn't gotten to JCS yet (jump carry set), but here are the instructions plus that one:
Code:
   -- Ben Eater SAP inspired CPU instruction set:
   --
   -- 0000 xxxx   NOP           no-operation
   -- 0001 mmmm   LDA M         A = RAM[M]
   -- 0010 mmmm   ADD M         A = A+RAM[M]
   -- 0011 mmmm   SUB M         A = A-RAM[M]
   -- 0100 mmmm   STA M         RAM[M] = A
   -- 0101 iiii   LDI N         A = N (4-LSB)
   -- 0110 mmmm   JMP M         PC = M
   -- 0111 mmmm   JCS M         if (carry) then PC = M
   -- 1000 xxxx   ??? (unused, acts like NOP)
   -- 1001 xxxx   ??? (unused, acts like NOP)
   -- 1010 xxxx   ??? (unused, acts like NOP)
   -- 1011 xxxx   ??? (unused, acts like NOP)
   -- 1100 xxxx   ??? (unused, acts like NOP)
   -- 1101 xxxx   ??? (unused, acts like NOP)
   -- 1110 xxxx   OUT            output A register
   -- 1111 xxxx   HLT            halt CPU clock (forces clock enable low)


SAP stands for "Simple As Possible" to teach about CPUs and digital electronics (and maybe a bit of FPGAs and VHDL with my project). Of course the first thing one wants to do when you get this operational is to extend it. Thankfully, this is a lot easier than re-wiring things on a breadboard.

-Xark

Attachments:
BenEater_Diagram.png
BenEater_Diagram.png [ 258.66 KiB | Viewed 8862 times ]

Author:  BigEd [ Fri Aug 25, 2017 3:03 pm ]
Post subject:  Re: Ben Eater's SAP inspired computer implemented in VHDL

Thanks - 4 bits eh? Even simpler than I thought! But that's still a computer. I'm all for it.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/