Homepage Blogs
myisa

12th March, 2026

About a very basic ISA I designed in approximately a week.

myisa

Who is this written for?

A person with basic knowledge in Computer Architecture, digital design, SystemVerilog, and the C programming language.

Check out the github repository.

This is a very basic ISA(Instruction Set Architecture) implemented in C and SystemVerilog. I did this as an experiment and to learn about ISAs. The idea for this ISA is slightly unusual. I’ve also kept this ISA very very basic, both in imlpementation and use. Thus, I’ve not involved myself in implementing stacks and heaps. There is not even a clearly defined program section!

In this blog, I plan to just explain my thought process behind designing this ISA, and its implementation in C.

The Architecture

I decided upon a 16 bit architecture, with 2 byte words. Hence, each address would require 16 bits and goes from 0x0000 to 0xFFFF. Here’s the interesting part. The program section starts from 0xFFFF and moves downwards! This completely eliminates the need of separate sections. This does have the problem that you might accidentally overwrite your program, but I leave that to the programmer. I’ve implemented a bunch of basic operations in my ISA, which can be seen in the github repository here. I’ve taken inspiration from MIPS, RISC-V and IAS computer architectures.

The idea behind the memory structure was straightforward: make it as simple as possible. The best thing I could think of was making it Von Neumann style, and keeping everything nice and together. I didn’t want to limit the address values of the PC or whatever, so I just made everything 2 byte(16 bit), and thus it is. This leads to 128KiB of main memory.

Registers, I chose 16 registers, because 16 bits made sense to have 16 registers. Also, 4 bits (1 nibble) to pick a register. The registers are named r0 through r9, and a bunch of other pre-defined ones - PC(program counter), IBR(immediate buffer register), hi, lo(multiplication and division), flg(a flag register) and the zero register.

About the immediates… Given the tiny instruction size(a max upper limit of 16 bits), if I were to make place for immediates there, it would be highly insufficient. Hence, I made the novel(?) idea of placing immediates on their own line. Hence, I could get the full potential use of 16 bits in my computations. The way I’m doing things are as follows:

addi r1, r2, ; r1 <= r2 + 5(5 is in decimal)
  0d5
  ; OR
  addi r4, r5, ; Same thing, but now r4 is given r5 + 0x45A2
  0x45A2
  ; This is very useful in cases including branching
  addi r9, zero, ; Save the address of that instruction in r9
  0xFFF9

In designing instruction splits within 16 bits, I chose 4+4+4+4. This became quite restrictive, but what else can you do with just 2 nibbles? Hence, the opcodes go from 0x0 to 0xF. Basic instructions are implemented. The only logical instruction implemented is NAND, since you can make any other logical operation from that(though it would be better..?). Arithmetic operators are of course, implemented. I’ve also done a cmp instruction that sets the flg register. Branch instructions then use this value. 0xF is given as a syscall. I am yet to fully utilize that.

C implementation

Obviously, implementing this in a high level programming language like C would be much easier than doing it directly in Verilog. Hence, I started out with this.

I made an assembler.c which assembles your myisa program into machine level code(binary), according to the opcodes and architecture. Here, I finally managed to learn to use enums in C properly. I also learnt of some smart trick using union to be able to use nibbles in C(since the smallest data type is of 1 byte which is char). I write the machine code to a binary file directly.

Further, I made a computer.c, which initially reads the machine code, and stores it in a large array(of size 128KiB). Here, I make use of high level programming constructs to implement the operations. So it isn’t technically a proper computer. I also made use of do...while construct!

Conclusion

All in all, this wasn’t a very impressive project(in my opinion), but it sure was interesting. There were certain nuances that were needed to be taken care of even when writing it down with a high level language (as in using the trick of union to make use of smaller than 1 byte stuff).

Last Edited: