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

A simple 16-bit CPU built in Logisim

License

NotificationsYou must be signed in to change notification settings

Theldus/MSW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSW is a 16-bit CPU, RISC, Unicycle, Harvard, built inLogisim.

It is designed to be as simple as possible, so it is not cumbersome to understand the entire circuit, as well as the instruction set and the assembler. It is primarily suitable for students of Computer Architecture. Because of this, it has no pipeline, branch prediction, cache, among other features.

msw overview
MSW Overview

Architecture

Inspired by the Intel 8086 and MIPS, but much simpler, its instruction set has 16 instructions and similar registers with Intel. Its general architecture looks like a MIPS unicycle.

It is divided into 4 parts:

  • ALU: Arithmetic Logic Unit
  • UControl: Unity Control, responsible for creating control flags throughout the CPU, according to the instruction currently running.
  • BRegs: Register Bank.
  • CPU: Final module, containing the full assembly of the other modules.

Instruction Set

The MSW's instructions follows the format below:

 OpCode      R1   R2              Imm/-------\    /-\ /-\     /------------------\    - Immediate instructions. 0 0 0 0     0 0 0 0     0 0 0 0      0 0 0 0

and

OpCode      R1   R2           Constant/-------\    /-\ /-\     /------------------\    - Only registers. 0 0 0 0     0 0 0 0     1 1 1 1      1 1 1 1

Supports 16 instructions and 4 registers: AX, BX, CX and DX.* Due the use of 0x00FF to identify Register-only instructions, youshouldn't use 255 as immediate value.

The following table illustrates all instructions:

Op CodeInstructionBehavior
0OR REGDest,REGSource/ImmREGDest <- REGDest | REGSource
1NOT REGDestREGDest <- ~REGDest
2AND REGDest,REGSource/ImmREGDest <- REGDest & REGOri
3XOR REGDest,REGSource/ImmREGDest <- REGDest ^ REGOri
4ADD REGDest,REGSource/ImmREGDest <- REGDest + REGOri
5SUB REGDest,REGSource/ImmREGDest <- REGDest - REGOri
6MULT REGDest,REGSource/ImmREGDest <- REGDest * REGOri
7DIV REGDest,REGSource/ImmREGDest <- REGDest / REGOri
8MOV REGDest, REGSourceREGDest <- REGSource
9MOV REGDest, ImmREGDest <- Imm
10LOAD REGDest, REGSourceREGDest <- MEM[REGSource]
11STORE REGDest, REGSourceMEM[REGDest] <- REGSource
12JMPZ REGDest/LabelJuMP if Zero
13JMPN REGDest/LabelJuMP if Negative
14JMPP REGDest/LabelJuMP if Positive
15HALTHalts CPU

Assembler

In order to avoid programming directly in binary, MSW also comes with an Assembler, that takes a file as input and generates a hex file ready to run. A code like below can be perfectly executed on the CPU:

####################FibonAsm, ^.^######################Calculation of Fibonaccimov ax,1   #ixor bx,bx  #jxor cx,cx  #<-- memmov dx,14  #counterfibo:add   ax,bx  #i=i+jstore cx,ax  #mem[0] = imov   ax,bx  #i=jload  bx,cx  #j=mem[0]sub   dx,1   #count=count-1jmpp  fibohalt#Result in bx

The assembler is case insensitive for instruction names, supports labels and comments.

To run the generated program (.hex), just load it to the leftmost memory and activate the clock.Here is a video of the CPUin operation (Portuguese).

What comes next?

This is my first CPU and I believe there are some design issues in both the CPU and the Assembler (not bugs, just the wayI developed).

So I don't intend to go far with it, there are still some things I want to add such as stack and I/O instructions, butthe ideal would be a re-work on a new CPU, very different from this first, starting with microcode addition eg.


That's it, if you have questions, suggestions or want to contribute, feel free to ask me, I would love hear from you.

About

A simple 16-bit CPU built in Logisim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp