GithubHelp home page GithubHelp logo

zipcpu / icozip Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 5.0 1.11 MB

A ZipCPU demonstration port for the icoboard

Makefile 3.20% Perl 0.24% Verilog 63.79% C++ 25.07% C 6.64% Shell 0.26% Objective-C 0.81%

icozip's Introduction

The Zip CPU

The Zip CPU is a small, light-weight, RISC CPU. Specific design goals include:

  • 32-bit. All registers, addresses, and instructions are 32-bits in length.

  • A RISC CPU. Instructions nominally complete in one cycle each, with exceptions for multiplies, divides, memory accesses, and (eventually) floating point instructions.

    (Note that the ZipCPU is not a RISC-V CPU, nor does it copy from any other instruction set but its own.)

  • A load/store architecture. Only load and store instructions may access memory.

  • Includes Wishbone, AXI4-Lite, and AXI4 memory options.

  • A (minimally) Von-Neumann architecture

    The Wishbone wrappers share buses for instructions and data, the AXI4-Lite and AXI4 wrappers have separate bus interfaces for each. The address space itself, however, needs to be common.

  • A pipelined architecture, having stages for prefetch, decode, read-operand(s), a combined stage containing the ALU, memory, divide, and floating point units, and then the final write-back stage.

  • A two mode machine: supervisor and user, with each mode having a different access level.

  • Completely open source, licensed under the GPLv3.

Unique features and characteristics

  • Only 29 instructions are currently implemented. Six additional instructions have been reserved for a floating point unit, but such a unit has yet to be implemented.

  • (Almost) all instructions can be executed conditionally. Exceptions include load immediate (LDI), the debug break instruction (BREAK), the bus lock (LOCK) and simulation instructions (SIM), and the no-operation instruction (NOOP). The assembler will quietly turn a conditional load immediate into a two-instruction equivalent (BREV, LDILO).

  • The CPU makes heavy use of pipelining wherever and whenever it can. Hence, when using a pipelined memory core, loading two vaues in a row may cost only one clock more than just loading the one value.

  • The CPU has no interrupt vectors, but rather two register sets. On any interrupt, the CPU just switches from the user register set to the supervisor register set. This simplifies interrupt handling, since the CPU automatically saves, preserves, and restores the supervisor's context between enabling interrupts and receiving the next interrupt. An optional interrupt peripheral may be used to combine multiple external interrupts into a single interrupt line.

Getting Started

If you'd like to get started with the ZipCPU, you might wish to know that this repository contains the CPU, its documentation, and the toolchain. The CPU implementation found here, though, is just that: a CPU. This implementation requires a bus with peripherals hanging off of it, things such as RAM, flash (ROM), serial port, etc. This is just where I keep the CPU apart from any necessary peripherals.

So, if you want to try out the CPU, feel free to download and build this repository (use git-clone with a depth of 1--there's a lot of stuff in the git repo that you don't necessarily need). You'll need it for the binutils, GCC, and newlib support provided by it.

Once you've built these tools, then I'd suggest you look into the ZBasic repository. That repository places the CPU in an environment with block RAM, QSPI flash, and SD-card (SPI protocol) access. From that repository, you can either tweak the distro (main.v, regdefs.h, board.h, board.ld) to add the peripherals you want to use the CPU with, or you can use AutoFPGA to adjust your RAM size, add or remove peripherals and so forth while maintaining (creating, really) all of these files for you.

The sim/ subdirectory also contains a version of the ZipCPU in a usable environment for simulation purposes. This includes the CPU, possibly more CPU's for a multiprocessor environment, bus interconnect, memory, a simulated serial port, and a couple more peripherals.

If you aren't interested in simulating the CPU, there is an assembly level debugger that you can use to stop and step the CPU, as well as an integrated wishbone scope that you can use to get traces from within the design while it is running.

Need help?

If you'd like to use the ZipCPU, and don't know where to begin, feel free to find me on IRC as ZipCPU. I've created a #zipcpu channel on several IRC servers that I tend to inhabit. If you get stuck, feel free to drop by and ask for help. You can also drop by just to say hi. Either way, please introduce yourself and give me some time to respond.

Current Status

You can also read about the ZipCPU via several blog articles posted at zipcpu.com! Articles you might find valuable include:

Not yet integrated

  • The MMU that was written for the ZipCPU now needs to be rewritten in order to work in the new ZipCore context. My plan is to place the MMU between the ZipCore and the various bus aware wrappers, providing a similar interface to the one offered by the ZipCore. That way, caches will be based on physical addressing--solving one of the bigger problems I had when using the MMU.

  • FATFS support now exists for the SDCard, it's just not (yet) integrated into the newlib C-library.

  • The ZipOS would greatly speed up and improve the bare bones newlib library--primarily by providing "O/S" level interrupt support when using the library. This integration has not (yet) been accomplished.

    On the other hand, if the MMU is available, I might rather just create a Linux distribution.

Commercial Opportunities

The GPLv3 license should be sufficient for most (all) academic and hobby purposes, and certainly for all simulation based purposes. If you find, however, that the GPLv3 license is insufficient for your needs, other licenses can be purchased from Gisselquist Technology, LLC.

This applies to all but the toolchain, for which GPLv3 should work for all purposes. (Besides, I don't own the licenses for Binutils, GCC, or newlib.)

icozip's People

Contributors

zipcpu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

icozip's Issues

Test sram

Hi dan
in the cputest
Do You test full sram (0-ffff) ?
Best regard
Tzahi

iCE40HX8K-EVB olimex

Hi
Very nice web site Zipcpu
Very nice work
Can i generate project with AutoFpga
For this board iCE40HX8K-EVB olimex
It is very similar to icoboard
Best regard

fedora 31 error with arachne-pnr

I have been testing icozip with fedora 31 , fedora 30 and rpi buster.
This error appears on fedora 31 but not fedora 30.
Not sure if this has anything to do with icozip but asking for advice.

2.46. Executing BLIF backend.

End of script. Logfile hash: f057ca0d26
CPU: user 0.66s system 0.02s, MEM: 50.52 MB total, 44.84 MB resident
Yosys 0.9 (git sha1 UNKNOWN, gcc 9.1.1 -O2 -fexceptions -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -Os)
Time spent: 52% 10x read_verilog (0 sec), 14% 1x share (0 sec), ...
arachne-pnr -d 8k -r -P ct256 -p blinky.pcf -o blinky.asc blinky.blif
seed: 2281212662
device: 8k
read_chipdb +/share/arachne-pnr/chipdb-8k.bin...
supported packages: bg121, bg121:4k, cb132, cb132:4k, cm121, cm121:4k, cm225, cm225:4k, cm81, cm81:4k, ct256, tq144:4k
read_blif blinky.blif...
prune...
read_pcf blinky.pcf...
instantiate_io...
pack...

After packing:
IOs 6 / 206
GBs 0 / 8
GB_IOs 0 / 8
LCs 32 / 7680
DFF 3
CARRY 2
CARRY, DFF 24
DFF PASS 0
CARRY PASS 1
BRAMs 0 / 32
WARMBOOTs 0 / 1
PLLs 0 / 2

place_constraints...
promote_globals...
promoted i_clk$2, 27 / 27
promoted 1 nets
1 clk
1 globals
1 clk
realize_constants...
place...
initial wire length = 355
at iteration #50: temp = 12.9827, wire length = 192
at iteration #100: temp = 5.42833, wire length = 132
at iteration #150: temp = 1.43048, wire length = 106
final wire length = 99

After placement:
PIOs 5 / 206
PLBs 8 / 960
BRAMs 0 / 32

place time 0.06s
route...
/usr/include/c++/9/bits/stl_vector.h:1042: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::reference = std::pair<int, int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
make[2]: *** [Makefile:48: blinky.asc] Aborted (core dumped)
rm blinky.blif
make[1]: *** [Makefile:47: basic] Error 2
make: *** [Makefile:158: rtl] Error 2
[pstan@daidokoro-ci-org icozip]$

icozip make error

fedora 30 /usr/local/src for default directory
yosys, arachne-pnr, icestorm from repositories

yosys -V
Yosys 0.8 (git sha1 UNKNOWN, gcc 9.0.1 -O2 -fexceptions -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -Os)

git clone autofpga and make
autofpga -V
autofpga
built on 20190830

I have copied board.ld and icozip.pcf to auto-fpga directory
then run make which errors after some time

yosys -ql yosys.log -p synth_ice40 -blif icozip.blif -top toplevel ...
toplevel.v:184: ERROR: Identifier \i_clk' is implicitly declared and default_nettype is set to none.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.