Close

ALU Design finally completed and tested

A project log for SPAM-1 - 8 Bit CPU

8 Bit CPU in 7400 with full Verilog simulator and toolchain

john-lonerganJohn Lonergan 07/25/2020 at 23:010 Comments

I finally got to the end of desiging the ALU - the result is documented here https://github.com/Johnlon/spam-1/blob/master/docs/alu_with_carry_in.md

0-7 ALU Ops8-15 ALU Ops16-23 ALU Ops24-31 ALU Ops
0B-1A*B (high bits)A RRC B
AA+B*1A*B (low bits)A AND B
BA-B*1A/BA OR B
-AB-A*1A%BA XOR B
-BA-B (special)A << BA NAND B
BA / 10A+B+1*2A >> B arithmeticNOT B
BA % 10A-B-1*2A >> B logicalA+B (BCD)
B+1B-A-1*2A RLC BA-B (BCD)

This ALU is based on Warren Toomey's ALU for CscVon8 but with a few significant differences that are detailed in the ALU design page for SPAM-1.

There is a verilog implementation of the ALU https://github.com/Johnlon/spam-1/blob/master/verilog/alu/alu_code.v and a bunch of unit tests for each operation https://github.com/Johnlon/spam-1/blob/master/verilog/alu/test.v.

Once I had that passing I needed to generated an image file for burning a ROM and also because I wanted to use the same data file to drive an alternative impl using a verilog ROM loaded from that datafile so that I could run the CPU and unit test against it.

The approach I took was to create the data file by writing a small verilog program that applied all possible input values to the verilog ALU implentation and then writing the inputs and outputs to disk as a ROM image.

The program was pretty simple https://github.com/Johnlon/spam-1/blob/master/verilog/alu/gen_alu.v and generated all the files I need to create some physical ROMS when I get to the H/W build - which will be as soon as I can clear a space at home to start work.

Discussions