Show HN:E80:一個以結構化VHDL實現的8位元CPU

Show HN:E80:一個以結構化VHDL實現的8位元CPU

Hacker News·

一位開發者展示了E80,這是一個為教育目的從頭開始用VHDL構建的簡單8位元CPU,旨在易於使用並能運行用於課堂場景的真實程式。

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

To see all available qualifiers, see our documentation.

A simple CPU in VHDL for educational purposes

License

Uh oh!

There was an error while loading. Please reload this page.

Stokpan/E80

Folders and files

Latest commit

History

Repository files navigation

E80 CPU

A simple CPU in VHDL, developed from scratch for my undergraduate thesis to provide all three characteristics of a Constructionist Microworld:

This makes it easy to use, capable of running pretty complex and realistic programs, and can be used in multiple lab or classroom scenarios.

ISA cheatsheet

Notes

Flags cheatsheet

Assembly cheatsheet

Notes

Example 1 - One-click simulation with GHDL/GTKWave or ModelSim

The following program writes the null-terminated string `az{"0 to memory after the last instruction (notice the label under HLT) and converts the lowercase characters to uppercase, stopping when it hits the terminator:

To simulate it, first install the E80 Toolchain package from the Releases, then open the E80 Editor and paste the code into it:

Image

Notice that syntax highlighting for the E80 assembly language has been enabled by default for all code (except for VHDL files).

Press F5. The editor will automatically assemble the code, save the VHDL output, compile the entire design with GHDL, and launch a GTKWave instance. Subsequent simulations will be closing the previous GTKWave window to open a new one.

You should see the following waveform, in which the RAM has been expanded to show how the lowercase letters of the string have changed to uppercase:

Image

Notice that the HLT instruction has stopped the simulation in GHDL, allowing for the waveforms to be drawn for the runtime only. This useful feature is supported in ModelSim as well.

You can also press F7 to view the generated Firmware.vhd file, without simulation:

Image

Notice how the assembler formats the output into columns according to instruction size, and annotates each line to its respective disassembled instruction, ASCII character or number.

If you have installed ModelSim, you can press F8 to automatically open ModelSim and simulate into it. Subsequent simulations on ModelSim will update its existing window:

Image

The Memory Data tab next to the Wave tab contains the RAM in the end of simulation. The contents can also be displayed by hovering on the RAM in the Wave tab, but there's a catch: if the radix is set to ASCII and the data include a curly bracket, ModelSim will throw an error when trying to show the tooltip.

Example 2 - Testing on the Tang Primer 25K

First, install Gowin EDA Student Edition (Windows, Linux, MacOS).

Study the pin assignments in the Gowin\E80.cst file and apply them to your board. Use a five-direction navigation button/joystick with Left, Right, Up, Down, Set (for Pause), and Reset. All input pins must be active high with a 10kΩ pull-down resistor and the joystick's COM port must be connected to a 3.3V output. Below is a reference photo of the board setup:

Image

The top module (FPGA.vhd) uses three 8-LED rows for display, and the joystick buttons for control:

LEDs

Buttons

To run the test, paste the following program into the editor and press F7. This will automatically update Firmware.vhd with your new code.

You can also simulate (F5 or F8) the program prior to running in the FPGA; in this case it's suggested to match the .SIMDIP value with the DIP switches on the board.

Open the Gowin\Gowin.gprj file in the Gowin IDE. Compile the project using Run All, wait for completion, connect your Tang Primer 25K board on your PC, and then use the Programmer function to upload the configuration.

When the upload is finished, press the Reset button to initialize the RAM with your firmware, and release it when the Clock LED stops pulsing. The Clock LED will be pulsing as the program runs. LED Row B defaults to R0, so you will see it rotating. Then the HLT instruction will be executed and the Clock LED will stop pulsing.

About

A simple CPU in VHDL for educational purposes

Topics

Resources

License

Uh oh!

There was an error while loading. Please reload this page.

Stars

Watchers

Forks

Releases

  1

Packages

  0

Languages

Footer

Footer navigation

Hacker News

相關文章

  1. Show HN:開源 8 通道腦機介面 (BCI) 板載 ESP32、ADS1299 及 OpenBCI GUI

    4 個月前

  2. Show HN:具備AI助教的自架設微學習平台 (Django/SolidJS)

    4 個月前

  3. Show HN:在網頁瀏覽器中除錯您的 AI 應用程式

    4 個月前

  4. 在 Jetson 平台上部署開源視覺語言模型 (VLM)

    Huggingface · 2 個月前

  5. 文件更新:con-terminal 提取請求中新增 Windows Scoop 安裝說明

    Wey Gu 古思为 · 2 天前