What is functional simulation?

This article discusses functional simulation in the Caravel platform.

Functional simulation is a crucial step in the digital design process, allowing designers to verify that their logic behaves as expected before moving forward to physical implementation. In simple terms, it involves simulating the behavior of a design to ensure that it performs its intended functions correctly, without yet considering the physical aspects like timing or power.

Once you’ve written your RTL Verilog code, functional simulation is essential to validate the design. This step helps you catch and resolve any logical errors early in the design cycle, saving time and resources down the line.

In the context of Caravel, functional simulation allows users to validate their design within the Caravel environment. By simulating your design inside Caravel, you can ensure that it interacts correctly with the platform's peripherals and interfaces, such as the Wishbone bus, GPIOs, and any other integrated components. This process provides a comprehensive check, giving you confidence that your design will operate as intended when it moves forward to the next stages of the ASIC development process.

Introducing Firmware and Test Benches

To effectively carry out functional simulation, two key elements come into play: firmware and test benches.

  • Firmware: Firmware is a specialized software written in C that runs on the CPU, and in Caravel’s case, this CPU is a RISC-V core. The firmware tells the CPU what to do, guiding the hardware’s operations and interactions. During functional simulation, firmware is used to control and test the behavior of your design by providing specific instructions to the CPU. For example, you might write firmware that initializes certain peripherals, runs a sequence of operations, or triggers specific inputs to test how your design responds.

    In real hardware, this same firmware can be loaded onto the CPU to control its behavior in the actual environment. For instance, if your design includes a communication protocol, the firmware could instruct the CPU to send and receive data packets, ensuring that the hardware handles communication correctly. By simulating with firmware, you’re essentially rehearsing how your design will perform once deployed, making sure it behaves as expected under real-world conditions.

  • Test Benches: A test bench is a virtual environment used to verify the functionality of your RTL code. It consists of both the test stimuli and the expected outputs that you define to ensure that your design behaves as intended. In functional simulation, test benches are crucial because they provide the controlled environment needed to rigorously test every aspect of your design. They allow you to simulate various scenarios and edge cases, ensuring that your design is robust and reliable.

In summary, both firmware and test benches are essential for functional simulation by providing the tools and environments needed to validate your design thoroughly. These elements help you ensure that your design will function correctly within the Caravel, giving you the confidence to proceed to the next stages of development.