Skip to content

TinyTapeout/tinyqv-byte-peripheral-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyQV Byte Peripheral Template for Tiny Tapeout

What is TinyQV?

TinyQV is a Risc-V CPU designed for Tiny Tapeout.

This template helps you create peripherals that can be integrated with TinyQV, and taped out for free as part of the Risc-V peripheral challenge.

What can a peripheral do?

A peripheral allows the CPU to interact with the input and output pins, or provides some additional functionality to the CPU, or both! All sorts of things are possible - from a UART or custom sensor driver to a graphics driver or division accelerator.

Each peripheral is allocated a range in the system's memory map, so that the CPU can read data from and write data to the peripheral. This allows the TinyQV CPU to communicate with the peripheral.

The peripheral also has access to the 8 input and 8 output pins available to Tiny Tapeout designs. The peripheral infrastructure can select which peripheral is in control of each output pin individually, so multiple peripherals can be used together. The bidirectional pins are not available to the peripherals as they are used by TinyQV to access the flash and RAM.

The interface to the peripheral is here.

How do I get started?

Implement your peripheral by replacing the implementation in the example with your own implementation. You may create additional modules.

Test your peripheral by replacing and extending the example test.

Submission checklist

Before submitting your design, please check:

  • You have renamed the peripheral module from tqvp_example to something unique that makes sense for your design.
  • You have created a test script that uses the tqv class to read and write your design's registers.
  • You have documented your design and its registers.

Submission process

Please raise a pull request against https://github.com/TinyTapeout/ttsky25a-tinyQV adding your peripheral.

To get started, fork that repo and clone it, then follow the steps below to add your peripheral into the project.

If you have any trouble following these steps, ask in the Tiny Tapeout Discord or in the PR.

Add your verilog source to src/user_peripherals

  • Copy the verilog files in to a subdirectory of src/user_peripherals
  • Add each source file to the info.yaml source_files section

Add your peripheral to the "Byte interface peripherals" section in src/peripherals.v

Each peripheral needs to go in its own slot in. Find an existing slot that is still set to use the tqvp_byte_example peripheral, this example shows slot 2:

tqvp_byte_example i_user_simple02 (
    .clk(clk),
    .rst_n(rst_n),

    .ui_in(ui_in),
    .uo_out(uo_out_from_simple_peri[2]),

    .address(addr_in[3:0]),

    .data_write((data_write_n != 2'b11) & peri_simple[2]),
    .data_in(data_in[7:0]),

    .data_out(data_from_simple_peri[2])
);

and change the first line to match your peripheral, for example:

tqvp_matt_encoder matt_encoder02 (

Add your test file to test/user_peripherals

  • Copy the test in to a subdirectory of test/user_peripherals
  • Update your testbench.py to set the PERIPHERAL_NUM to 16 plus the simple peripheral index used in peripherals.v.
  • In test/Makefile, add the name of your test to the list of user peripherals. If your test is test.py in the my_peripheral directory add this: my_peripheral.test

To run your test, make sure you have installed the requirements.txt, then:

make -B my_peripheral.test

And the compressed waveform will be in sim_build/rtl/tb.fst

Add your docs to docs/user_peripherals

  • Copy your docs/info.md into this folder and rename it with the peripheral index at the start (e.g. 18_my_peripheral.md)
  • Fill in the Peripheral Index in the document.

Raise the Pull Request through GitHub

The peripheral test harness

This template includes a test harness for your peripheral that communicates with the peripheral using SPI. This allows you to develop and test your peripheral independently of the rest of the Risc-V SoC.

The SPI interface implemented by the test harness has a one byte command with format:

Bits Meaning
7 Read or write command: 1 for a write, 0 for a read
6-4 Unused
3-0 The register address

For a write the next byte transmitted is the byte to write to the register. For a read, the test harness reads the register and transmits it back to the SPI controller.

Testing your design with TinyQV

When ttsky25a is delivered, the easiest way to test your design will be with TinyQV Micropython. The firmware will make it easy to read and write your registers, and set the output pins to be controlled by your peripheral (this is currently a work in progress).

In order to easily use TinyQV Micropython, you will need to avoid using the in7 and out0 IOs, as these are used for the UART peripheral to communicate with Micropython. So if you don't need to use all of the IOs then avoid using those ones.

You can also integrate directly with the tinyQV SDK to create programs in C.

What is Tiny Tapeout?

Tiny Tapeout is an educational project that aims to make it easier and cheaper than ever to get your digital and analog designs manufactured on a real chip.

To learn more and get started, visit https://tinytapeout.com.

Set up your Verilog project

  1. Add your Verilog files to the src folder.
  2. Edit the info.yaml and update information about your project, paying special attention to the source_files and top_module properties. If you are upgrading an existing Tiny Tapeout project, check out our online info.yaml migration tool.
  3. Edit docs/info.md and add a description of your project.
  4. Adapt the testbench to your design. See test/README.md for more information.

The GitHub action will automatically build the ASIC files using OpenLane.

Enable GitHub actions to build the results page

Resources

What next?

About

TinyQV Byte Peripheral Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7