Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/4bitPublic

a 4 bit TTL computer

License

NotificationsYou must be signed in to change notification settings

werdl/4bit

Repository files navigation

Features

  • Custom 4-bit ALU, supporting AND, OR, XOR, NOT, full add and full subtract
  • 256 nibbles of general use memory
  • Four registers, used for I/O to/from the ALU
  • Program counter with jump and jump if zero instructions

Instruction Set

Binary ValueAssembly MnemonicA_ARG valueB_ARG valueOperation DescriptionImplemented
0000ADDNoneNoneAdds reg 00 to reg 01 and stores in reg 10Yes
0001SUBNoneNoneSubtracts reg 01 from reg 00 and stores in reg 10Yes
0010REG4 bit literal2 bit register addressStoresA_ARG in regB_ARGYes
0011NOPNoneNoneNoneYes
0100NOTNoneNoneLogically inverts the contents of reg 00 and stores in reg 10Yes
0101XORNoneNonePerforms logical XOR on registers 00 and 01 and stores in reg 10Yes
0110ORNoneNonePerforms logical OR on registers 00 and 01 and stores in reg 10Yes
0111ANDNoneNonePerforms logical AND on registers 00 and 01 and stores in reg 10Yes
1000SAV8 bit address4 bit literalSavesB_ARG to memory addressB_ARGYes
1001LDA8 bit address2 bit register addressLoads memory addressA_ARG to regB_ARGYes
1010WRIT8 bit address2 bit register addressSaves regB_ARG to memory addressA_ARGYes
1011Reserved---No
1100JMP6 bit addressNoneJumps to PC addressA_ARGYes
1101Reserved---No
1110JCU6 bit address2 bit register addressIf registerB_ARG is equal to register 11, jumps to memory addressA_ARGYes
1111Reserved---No

Notes on the instruction set

  • There are 4 "namespaces" (bitfields)
Binary rangeUse# uses
0000 -0011Arithmetic uses2 +NOP
0100 -0111Logical operations4
1000 -1011Memory manipulation operations3
1100 -1111Control flow operations3 (only 1 implemented)
  • I think it is Turing-complete or near to it? I am pretty sure it is with manual instruction entry on the ALU/Memory Unit, but the PC I am less sure of

Example Programs

A simple program that adds 1 to a number in memory address 0x00 and stores it in memory address 0x01

LDA0x0000 ; Load the number from memory address 0x00 into reg 00REG101 ; Store the literal 1 in reg 01ADD ; Add reg 00 to reg 01 and store in reg 10WRIT0x0110 ; Write the result to memory address 0x01

Circuitry

Fully designed in Logisim, using the built in TTL library and alsothis library. A few logic gates are included for more obscure ICs, but they will be replaced either with said ICs or with equivalent chips in series.

ALU/MU

The ALU/MU is the heart of the computer, and is where all the computation is done. It is a 4-bit ALU, with 256 nibbles of general use memory. The ALU/MU is connected to the program counter, and is where the instructions are executed. The MU contains the registers and the memory.

Program Counter

The program counter is a simple counter that increments by one each clock cycle. It is connected to the ALU/MU, and is where the instructions are fetched from memory. The CLK input loads the current instruction into the ALU/MU, and the GO input executes the instruction. It is programmable, and can jump to any address in memory, using theJMP andJCU instructions.

ALU/MU

Program Counter

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp