Skip to content

About

Minimal processor with a simple custom ISA designed to teach students computer architecture fundamentals in just one lecture meeting.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ADEL Processor

ADEL — Architecture Design that's Easy to Learn — is a minimal custom processor and instruction set architecture designed for teaching introductory computer architecture. Its goal is to expose the complete path from an encoded instruction to register-file access, arithmetic/logic execution, writeback, instruction sequencing, and conditional control flow without the additional complexity of a production ISA.

ADEL intentionally keeps the architectural state and instruction format small:

  • 16-bit fixed-width instructions
  • 8-bit datapath
  • 4 general-purpose 8-bit registers (R0–R3)
  • 8-bit program counter
  • Register-register and register-immediate ALU operations
  • PC-relative conditional branches
  • Single-cycle execution
  • No data memory, load/store instructions, status register, or pipeline

The processor is small enough for the complete instruction encoding and datapath to be discussed as a single coherent design, while still supporting non-trivial programs containing arithmetic, bitwise operations, loops, multiplication by repeated addition, division by repeated subtraction, and Fibonacci-style recurrences.

In the ADEL simulator, the processor can also interact with simulated input and output devices through its registers. Programs can read switches and sensors, control displays and motors, and exchange data with peripheral memory using the existing instruction set. Configurable I/O makes it possible to study complete systems that respond to user input and produce visible or audible output.


Architecture at a Glance

Property ADEL
Instruction width 16 bits
Data width 8 bits
General-purpose registers 4 × 8-bit (R0–R3)
Program counter 8 bits
Instruction address space 256 instruction words
ALU operations ADD, SUB, AND, OR
Immediate width 8 bits
Immediate representation Two's complement
Branch conditions EQ, NE, LT, GT relative to zero
Branch addressing PC-relative
Execution model Single-cycle
Register write Rising clock edge
Reset Active-low; clears PC and register file

All four registers are ordinary writable registers; there is no hardwired zero register. Arithmetic results are stored in 8 bits and therefore naturally wrap modulo 256.


Instruction Set Architecture

ADEL processor instruction encoding

16-bit Instruction Format

Every instruction uses the same 16-bit format.

 15    14 13    12    11 10     9 8       7                 0
+---+----------+---+----------+--------+------------------------+
| W |   OPC    | RS|   DEST   |  SRC1  |      CONST / SRC2      |
+---+----------+---+----------+--------+------------------------+
  1      2       1      2         2                8
Field Bits Description
W 15 Register-file write control. 1 selects an ALU instruction; 0 selects a branch instruction.
OPC 14:13 Operation code. Its interpretation depends on W.
RS 12 Selects the second ALU operand: immediate (0) or register (1). For branches, this field is unused and encoded as 0.
DEST 11:10 Destination register for ALU instructions. Unused by branches and encoded as 00.
SRC1 9:8 First source register. For branches, this is the register compared against zero.
CONST/SRC2 7:0 Either an 8-bit immediate/branch displacement or the second source-register encoding.

The format deliberately allows instruction bits to drive the datapath almost directly. A separate instruction decoder is not required for most fields: the register selectors, ALU selector, operand selector, and write-enable signal are already present in the instruction itself.


Register Encoding

ADEL contains four 8-bit general-purpose registers.

Register Encoding
R0 00
R1 01
R2 10
R3 11

The same mapping is used by DEST, SRC1, and SRC2.

For register-register instructions, the upper six bits of the CONST/SRC2 field are zero and the register number is placed in bits [1:0]:

00000000  -> R0
00000001  -> R1
00000010  -> R2
00000011  -> R3

ALU Instructions

When W = 1, the instruction is an arithmetic or logical operation and OPC selects the ALU function.

OPC Operation
00 ADD
01 SUB
10 AND
11 OR

RS selects the form of the second operand:

  • RS = 1: register-register instruction
  • RS = 0: register-immediate instruction

The first operand is always the register selected by SRC1.

Register-Register Form

OP DEST, SRC1, SRC2

Semantically,

R[DEST] <- R[SRC1] OP R[SRC2]

For this form, RS = 1 and bits [7:2] are zero.

Instruction Semantics
ADD Rd, Rs1, Rs2 Rd = Rs1 + Rs2
SUB Rd, Rs1, Rs2 Rd = Rs1 - Rs2
AND Rd, Rs1, Rs2 Rd = Rs1 & Rs2
OR Rd, Rs1, Rs2 Rd = Rs1 | Rs2

Example:

SUB R1, R3, R2

performs

R1 <- R3 - R2

and assembles to:

W   OPC  RS  DEST  SRC1  CONST/SRC2
1   01   1    01    11    00000010

1011 0111 0000 0010 = 0xB702

Register-Immediate Form

OPI DEST, SRC1, IMM8

Semantically,

R[DEST] <- R[SRC1] OP IMM8

The immediate occupies bits [7:0] and is encoded in 8-bit two's-complement form. The assembler uses the I suffix to distinguish immediate instructions.

Instruction Semantics
ADDI Rd, Rs1, imm8 Rd = Rs1 + imm8
SUBI Rd, Rs1, imm8 Rd = Rs1 - imm8
ANDI Rd, Rs1, imm8 Rd = Rs1 & imm8
ORI Rd, Rs1, imm8 Rd = Rs1 | imm8

Example:

SUBI R3, R1, -31

is encoded as:

W   OPC  RS  DEST  SRC1      IMM8
1   01   0    11    01      11100001

1010 1101 1110 0001 = 0xADE1

Since 0xE1 is the 8-bit two's-complement representation of -31, the instruction performs:

R3 <- R1 - (-31)

Branch Instructions

When W = 0, the instruction is interpreted as a conditional branch rather than an ALU/writeback instruction.

The branch tests the value of R[SRC1] relative to zero. OPC is therefore re-used as a branch-condition code.

OPC Mnemonic Branch condition
00 BEQ R[SRC1] == 0
01 BNE R[SRC1] != 0
10 BLT R[SRC1] < 0
11 BGT R[SRC1] > 0

The branch format is:

Bcc SRC1, offset

For all branch instructions:

W    = 0
RS   = 0
DEST = 00

and the 8-bit CONST field is interpreted as a signed PC-relative displacement.

A taken branch updates the program counter as:

PCnext = PC + offset

A non-taken branch proceeds sequentially:

PCnext = PC + 1

The displacement is relative to the address of the branch instruction itself, not to PC + 1.

Because the PC and branch displacement are both 8 bits in the implementation, PC arithmetic naturally wraps modulo 256.

Branch Example

BNE R2, -2

encodes as:

W   OPC  RS  DEST  SRC1      OFFSET
0   01   0    00    10      11111110

0010 0010 1111 1110 = 0x22FE

If R2 != 0, execution continues at PC - 2. Otherwise, execution continues at PC + 1.


Complete Instruction Set

Mnemonic Syntax W OPC RS Operation
ADD ADD Rd, Rs1, Rs2 1 00 1 Rd = Rs1 + Rs2
ADDI ADDI Rd, Rs1, imm8 1 00 0 Rd = Rs1 + imm8
SUB SUB Rd, Rs1, Rs2 1 01 1 Rd = Rs1 - Rs2
SUBI SUBI Rd, Rs1, imm8 1 01 0 Rd = Rs1 - imm8
AND AND Rd, Rs1, Rs2 1 10 1 Rd = Rs1 & Rs2
ANDI ANDI Rd, Rs1, imm8 1 10 0 Rd = Rs1 & imm8
OR OR Rd, Rs1, Rs2 1 11 1 Rd = Rs1 | Rs2
ORI ORI Rd, Rs1, imm8 1 11 0 Rd = Rs1 | imm8
BEQ BEQ Rs, offset 0 00 0 Branch if Rs == 0
BNE BNE Rs, offset 0 01 0 Branch if Rs != 0
BLT BLT Rs, offset 0 10 0 Branch if Rs < 0
BGT BGT Rs, offset 0 11 0 Branch if Rs > 0

There are no dedicated move, clear, compare, unconditional-jump, or halt instructions. These can be synthesized from the existing ISA where needed. For example:

ADDI R1, R2, 0     # R1 <- R2
SUB  R3, R3, R3    # R3 <- 0

A program can stop useful execution by entering a self-branch whose condition is known to be true.


Hardware Implementation

ADEL is a single-cycle datapath. The current instruction is decoded combinationally, its operands are read from the register file, the selected operation or branch condition is evaluated, and architectural state is updated on the next rising clock edge.

ADEL processor datapath

Instruction Fetch and Program Counter

The full teaching datapath uses a read-only instruction memory addressed by the program counter. During normal execution, the PC advances by one instruction every cycle.

The HDL core separates the processor from its instruction memory:

input  [15:0] inst;
output reg [7:0] pc;

This makes the interface suitable for connecting an external ROM or instruction-memory module:

pc -> instruction memory address
instruction memory data -> inst

With an 8-bit PC, up to 256 instruction addresses can be represented.

Register File

The register file contains four 8-bit registers. Two registers can be read combinationally for the source operands, while one destination register can be updated on the rising clock edge.

The instruction directly supplies:

DEST -> write destination
SRC1 -> first read address
SRC2 -> second read address
W    -> write enable

On reset, all four registers are cleared to zero.

Operand Selection

The first ALU operand is always:

A = R[SRC1]

The second operand is selected by RS:

if RS = 0:
    B = IMM8
else:
    B = R[SRC2]

This single multiplexer allows the same ALU datapath to implement both register-register and register-immediate instructions.

Arithmetic and Logic Unit

The ALU supports four operations:

00 -> A + B
01 -> A - B
10 -> A & B
11 -> A | B

A hardware implementation may compute these functions in parallel and use a 4-to-1 multiplexer selected by OPC, or express the same behavior as a case statement in HDL.

For W = 1, the selected ALU result is written to R[DEST] at the rising clock edge, and the PC advances to PC + 1.

Branch Unit

For W = 0, the ALU writeback path is disabled and the OPC field is interpreted as a branch condition.

The branch unit compares R[SRC1] against zero and evaluates one of four conditions:

EQ : R[SRC1] == 0
NE : R[SRC1] != 0
LT : R[SRC1] <  0
GT : R[SRC1] >  0

If the selected condition is true:

PC <- PC + IMM8

otherwise:

PC <- PC + 1

This keeps control flow intentionally simple: there are no condition flags and no separate compare instruction. The register value itself is examined directly by the branch instruction.


Simulated I/O

The simulator connects peripherals directly to selected register bits. An output device observes values written by the processor, while an input device supplies values to its assigned bits. Programs use ordinary ALU instructions to read, mask, and update these values, and conditional branches to poll inputs and control execution. This interface uses the existing instruction encoding and requires no additional I/O opcodes or memory addresses.

The I/O configuration supports a single peripheral connected to R3. Free Play provides two peripheral slots, each independently assigned to R0, R1, R2, or R3. This allows combinations such as buttons on one register and an LED bank on another. Two output devices can observe the same register; devices that drive inputs can overwrite shared register bits, so the simulator flags these assignments.

Available peripherals cover several types of interaction:

Category Simulated peripherals
Digital input Eight momentary pushbuttons, four switches with four LEDs, rotary encoder with pushbutton and LEDs, 4×4 matrix keypad
Displays Eight LEDs, RGB LED, two hexadecimal 7-segment digits, raw 7-segment digit, 8×8 LED matrix, 16×2 character LCD
Analog and sound 8-bit ADC, 8-bit DAC, piezo buzzer
Actuators and timing Eight relays, stepper motor, servo motor, DC motor with H-bridge, PWM output, cycle timer with display
Sensors and expansion Ultrasonic distance sensor, 8-bit serial shift register, I²C temperature/light sensor
Peripheral memory 16 × 4-bit memory, 256-byte SPI flash

Each configuration shows its register-bit mapping and operating instructions. For example, the switch/LED configuration supplies switch states in R3[7:4] and uses R3[3:0] to drive four LEDs. The ADC converts an adjustable simulated input of 0–5 V into a byte from 0–255; the DAC converts a register byte into a simulated voltage over the same range. Input devices refresh their assigned bits, so programs must account for those bits when using a connected register for calculations.

Some peripherals respond to sequences of register writes and retain their own state. The LED matrix stores a pixel on a rising write strobe. The LCD receives each byte as two four-bit transfers, with each nibble latched on the falling enable edge. Keypad scanning, stepper coil sequences, and SPI/I²C transfers similarly let programs practice device-control protocols through register operations. Stateful peripherals are processed on every simulated processor cycle, including cycles between screen updates.

These devices extend the simulator's teaching environment. Peripheral memory is accessed through its port protocol, while the processor retains its base architecture without data-memory load/store instructions. The models support experiments with polling, bit manipulation, timing, and device control; their behavior and signal mappings are defined by the simulator.


Design Scope

ADEL is intentionally not a general-purpose production processor. It omits features that would obscure the fundamental datapath and control-flow mechanisms being demonstrated:

  • no data memory or load/store instructions,
  • no stack or procedure-call mechanism,
  • no interrupts or exceptions,
  • no status/condition-code register,
  • no multiplication or division hardware,
  • no pipeline,
  • no caches,
  • no privileged state, and
  • no memory-mapped I/O in the base architecture.

These omissions are deliberate. The complete machine can be understood in terms of a small number of familiar digital-design blocks: registers, multiplexers, adders/subtractors, bitwise logic, comparators, a program counter, and an instruction ROM.

That is the central purpose of ADEL: a processor architecture whose complete instruction set and hardware datapath are small enough to learn as one system.

About

Minimal processor with a simple custom ISA designed to teach students computer architecture fundamentals in just one lecture meeting.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages