MCPInstall
mcpu-verilog-8bitworkshop logo

mcpu-verilog-8bitworkshop

by max1220 max1220/mcpu-verilog-8bitworkshop

MCPU implemented in verilog, made for the 8bitworkshop web IDE

READMEmain

mcpu-verilog-8bitworkshop

Open this project in 8bitworkshop.

This repository also contains some support files to run the CPU using verilator outside the browser.

Memory map

FromToUsage
0x00000x3fffDRAM
0x40000x7fffIROM
0x80000x9fffVRAM

Special registers in VRAM

AddressNameUsage
0x9fffCTL_CONFIGMain control/graphics mode select register
0x9ffeCTL_COLOR0Primary fg/bg colors used in 1-bit text/framebuffer modes
0x9ffdCTL_COLOR1Secondary fg/bg colors used in two-color text mode
0x9ffcCTL_BORDERBorder pattern colors
0x9ffbCTL_PAGEOffset in VRAM added to scanout address, to enable scrolling/double buffering. Value is left-shifted 5x before add.

CTL_CONFIG bits

BitsNameUsage
0CTL_CONFIG_MODEif set is fb graphics mode, text mode otherwise
2-1CTL_CONFIG_FB_MODEfb mode: 2 bit framebuffer format, see below
1CTL_CONFIG_TEXT_COLORtext mode: if set uses 2-color mode(highest bit in character byte selects between color0 and color1)
2CTL_CONFIG_TEXT_EXTENDtext mode: this bit replaces the already used highest character byte bit when the CTL_CONFIG_TEXT_COLOR bit is set.

Framebuffer formats:

BitsNamePage size
00128x128_4bpp8KB/page
01256x256_1bpp8KB/page
10128x128_1bpp2KB/page
11128x64_4bpp4KB/page

Misc commands

# remove old build artifacts
rm -rf obj_dir irom.hex

# run nanoasm on the program for the instruction ROM
node ~/stuff/mcpu/mcpu_nanoasm/src/asmmain.js ~/stuff/mcpu/mcpu_nanoasm/examples/mcpu_asm.json irom.asm | tee irom.hex

# build the Lua interpreter-wrapped module
./build_and_run.sh mcpu_top.v

# run the module with the test script
./obj_dir/Vmcpu_top test_mcpu_top.lua +verilator+rand+reset+2

# combined full rebuild & run:
clear && node ~/stuff/mcpu/mcpu_nanoasm/src/asmmain.js ~/stuff/mcpu/mcpu_nanoasm/examples/mcpu_asm.json irom.asm > irom.hex && ./build_and_run.sh mcpu_top.v test_mcpu_top.lua

# combined asm re-compile and run:
node ~/stuff/mcpu/mcpu_nanoasm/src/asmmain.js ~/stuff/mcpu/mcpu_nanoasm/examples/mcpu_asm.json irom.asm > irom.hex && ./obj_dir/Vmcpu_top test_mcpu_top.lua +verilator+rand+reset+2