GithubHelp home page GithubHelp logo

wel97459 / fpgacosmacelf Goto Github PK

View Code? Open in Web Editor NEW
35.0 6.0 7.0 9.38 MB

A re-creation of a Cosmac ELF computer, Coded in SpinalHDL

License: GNU General Public License v3.0

VHDL 42.68% Scala 41.68% Assembly 4.66% CMake 0.81% C++ 10.17%
fpga cosmac-elf cpu processor spinalhdl cosmac rca fred risc 8bit

fpgacosmacelf's Introduction

FPGA Cosmac ELF

This is a re-creation of a Cosmac ELF computer, Coded in SpinalHDL.

The goal of this project is to end up with a cycle-accurate 1802 processor that can be used in FPGA designs easily. When I start the project I was new to SpinalHDL but I had attempted in the past to write the same processor in VHDL. However, language complexity and the sheer amount of code and time needed to write and debug that project ended the work on it.

To make verification of the CPU easier, I made the simulation capable of reading the Emma debug trace log format. The theory is that the CPU should follow that same path as the debug log from Emma.
If the Address or D register doesn't match the one in the log, then there is an issue and it will halt the simulation at that point. Using GTKWave you can view the output of the simulation and debug the issue.

The test program included uses the Floating Point Subroutines by Paul Wasserman. I copied the subroutine listings by hand into a hex editor and checked them by overlaying an image of the hex code I copied, with the scanned images. Included is a copy of the scans, and a copy of the binary file for the subroutines. Along with the assemble code I wrote to test the CPU.

If you would like to learn more about the 1802 processor here's a video about the designer Joseph Weisbecker, For information about the Cosmac Elf computer there's the wiki page.

Way build an RCA1802 processor

Josh Bensadon had a goal when designing computers and that was they had to be fun. The computer that led to the development of 1802 processor was called FRED.


The assembly language for the 1802 process is easy to understand, and the data flow of the cpu is easy to follow.


Using SpinalHDL made this project fun to work on. The Verilog code generated by SpinalHDL for just the CPU is 1500 lines, and cpu1802.scala file is 700 lines. I highly suggest installing and playing with SpinalHDL, it very powerful and the code is maintainable and reusable, and just works without the headaches.

Features:

  • Able to load programs over the serial interface while in load mode. Bytes sent to the serial interface are loaded into ram using the DMA IN function.
  • While in run and single step mode you can read the RX Serial data with INP N1 and check if it has data with BN2
  • Interrupts are generated when the serial RX has data in its FIFO, and also when you press the write button. You can check the button state with BN4.
  • Processor can send serial data with opcode OUT 1 and can check if the serial FIFO is full with opcode BN1

How to set up your project:

  1. You will need to have SpinalHDL setup and working on your system to generate the HDL code.
  2. For simulation, you will need to have Verilator setup.
  3. In your FPGA project, you will need to generate a PPL with a clock out of 8mhz to have the serial baud rate be 115200
  4. You will also need to generate a block ram.
  5. You may have to edit the BlackBoxes for the PLL and Ram to match your targets.
  • or you can just generate the CPU core by itself to get the HDL/Verilog.
  • or copy the cpu1802.scala file to your own SpinalHDL project.

Pictures

alt text

alt text

fpgacosmacelf's People

Contributors

wel97459 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fpgacosmacelf's Issues

Problems with TopLevelGen

When I do `sbt "runMain Spinal1802.TopLevelGen" I get a width mismatch error. segdis seems to need to be 12 bits not 11 bits. I am a bit confused about how many seven-segment digits you are using.

On the board I am using I will probably use a 7-segment display PMOD. I have one with 2 digits, and one with 3 digits. How many digits are you currently using. I believe the original Cosmac ELF had just two digits.

I also don't understand why you have targetDirectory = ".." in TopSpinalConfig. What directory are you doing the generation from and what directory do you want it generated in?

File names on Linux

I am running your simulation on Linux, but the file names such as verification\test_FPM_Verification.bin don't work. If you change those to use use / instead, would they then work on all operating systems?

Also it would be helpful if you could put the log file verification\test_FPM_Verification.log in the repository.

I mainly use open source FPGA boards, and am interesting in getting this running on one of those boards, possibly a Ulx3s board.

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.