Posts

Showing posts from April, 2023

Limerick(9) - Cocotb Tutorial: Test Bench Structure

Image
Hello, everyone. Welcome to the nineth episode of FPGA limerick. In this episode, we will take a deep look into the test bench structure of cocotb. As we know, cocotb stands for Coroutine Cosimulation Testbench. So before we start, we might ask ourselves: What is coroutine? In multi-task scenario, coroutine can be viewed as a collaborative non-preemptive thread. The following shows two coroutines calling each other, with yield at every step. And the execution order will always be 1, 2, 3, 4, 5 In cocotb, the coroutine is marked by putting “async” in front of the function name. And the yield is done with “await” command. We will soon see the details when it comes to the test bench next. The Classic Way If you read the official document of cocotb, it uses Makefile to organize the test bench. And for each coroutine, it will be decorated @cocotb.test(), like the following example: @cocotb.test() async def test_xxx(dut):    … However, what we will recommend is something differe...

Limerick(8) - Cocotb Tutorial: Introduction

Image
Hello everyone, welcome to the eighth episode of FPGA Limerick. In this episode, we will talk about the cocotb to make Python based test bench. And to show why we choose cocotb for verification, let’s visit other possible options: Overview 1. Verification, the old-fashioned way: Use Verilog/VHDL to make both testbench and DUT: As of today, a lot of companies still do things this way. However, because the Verilog/VHDL lacks the features offered by high level programming language, this method becomes very inflexible, verbose and unproductive. 2. Verification: HVL + HDL 3. Verification / Design with System Verilog Although System Verilog did a good job introducing high level programming language features, such as Object Oriented syntax, it is still considered too verbose and low level comparing to newer programming languages like Python. And thus comes the cocotb. Cocotb stands for Coroutine Cosimulation Testbench. It is a Python based verification framework. And practically it can be a g...