Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Digital Logic Sim

​A minimalistic digital logic simulator · By Sebastian Lague

16-Bit ALU

A topic by Murat_two created May 04, 2025 Views: 205 Replies: 2
Viewing posts 1 to 2
(+1)

I maded a massive 16-bit ALU that has 14 operations includes multiplication. But i will make a v2 of it. v2 will have 16 operations (division and mod). Maybe I will make a CPU for it and CPU will be maybe includes loop's, while's and for's. This is a photo of it and operation set:

- HEX: 0x0, BIN: 0000, ADD: A+B
- HEX: 0x1, BIN: 0001, SUB: A-B
- HEX: 0x2, BIN: 0010, AND: A AND B
- HEX: 0x3, BIN: 0011, OR: A OR B
- HEX: 0x4, BIN: 0100, XOR: A XOR B
- HEX: 0x5, BIN: 0101, NOT: !A
- HEX: 0x6, BIN: 0110, SHL: A<<1
- HEX: 0x7, BIN: 0111, SHR: A>>1
- HEX: 0x8, BIN: 1000, MUL: A*B
- HEX: 0x9, BIN: 1001, DIV: A/B (will be added in v2)
- HEX: 0xA, BIN: 1010, NEG: -B (Because of SUB it's not for A, it's for B)
- HEX: 0xB, BIN: 1011,  MOD: A%B (will be added in v2)
- HEX: 0xC, BIN: 1100, EQ: A==B
- HEX: 0xD, BIN: 1101, NEQ: A!=B
- HEX: 0xE, BIN: 1110, GT: A>B
- HEX: 0xF, BIN: 1111, LT: A<B

I have a tip for You , because Your project will be big the optimisation will be helpful
Add 3 state buffer before operation logic , why it will  help because when You add data on data bus simulation in first step calculate all gate
(for example one gate one tick now you have 5 * 16 = 80 ticks but if you will only one You will need only 16 ticks )
And one more AND gate need 2 NAND but You can use one 3 state

on screenshot You can see how I realize it
first line 3 state allow data input  second 3 state make AND gate logic
I hope it will be helpful


Thank you.