System-on-Chip (SoC) Design

ECE382M.20, Fall 2026


Lab #3

Due: 6:00pm, November 03, 2026

 

Instructions:

•        This lab is a team exercise.

•        Please use the discussion board on ED for Q&A.

•        Submit the report on Canvas and code on Classroom 50.


 


1         Overview

The goals of this lab are to:

•        Integrate the dot product hardware accelerator with the rest of the ARM-based SoC platform and llama.cpp application.

•        Prototype the target platform running the llama.cpp application in a SystemC TLM2.0 environment.

 

The assignment of this lab includes the following:

•        Develop a SystemC module for the dot product hardware accelerator and integrate it into an overall SystemC TLM platform model.

•        Develop a hardware abstraction layer (HAL) and driver for access to the external dot product accelerator from the ARM, which you will integrate with the rest of the llama.cpp application.

•        Cross-compile the accelerated llama.cpp application to run under Linux on the (simulated) ARM platform.

•        Co-simulate the llama.cpp application running on a virtual platform model to validate the HW/SW implementation.

 


2         Tutorial

Go through the tutorial on how to setup the QEMU/SystemC simulation environment for ARM processor emulation of the Ultra96 board:

QEMU/SystemC Tutorial

Note that you don’t have to include this in your lab write up.

 


3         Integrating the Dot Product Accelerator

Here are some guidelines on generating a standalone dot product accelerator module modeled in SystemC and integrate it into a TLM-based virtual platform:

a)     Make sure to start from the standalone dot product that served as input for hardware synthesis in Lab 2.

b)     Turn the function into a SystemC process and wrap it in a SystemC module.

c)      Insert wait() statements to model estimated execution delays into the dot product process. You can use the measurements you obtained from the co-simulation and HLS reports in Lab 2 for a design point of your choice as basis for delay modeling.

d)     The dot product accelerator will have to communicate and synchronize with the ARM to exchange input and output data. Define the accelerator interfaces and describe them in TLM form in the SystemC module. You may have to instantiate local scratchpad memories (which can be simply modeled as C/C++ arrays) and additional interfacing methods or processes for temporary data buffering/storage and external communication in the accelerator module. This scratchpad memory corresponds to the local accelerator SRAM memory that contains the inputs/outputs of the dot product function Lab 2. However, keep in mind that local SRAM memory in the physical FPGA used in the final project will be limited, i.e. your model should not use more local memory than what will be available in the final system implementation later (216 block RAMs of 36kb each for a total of 7.6Mb in case of the ZU3EG devices used in our boards).  

e)     Design the overall system architecture and integrate the SystemC model of the dot product accelerator into the virtual QEMU/SystemC platform accordingly. You can use the zynqmp_demo platform example from the QEMU/SystemC tutorial as a starting point for system integration.

f)       (Extra credit) The zynqmp_demo only connects the debug demo device as a pure slave to the M_AXI_HPM0_FPD system bus port. This requires the ARM to copy all output and input data back and forth from/to the hardware device. As an alternative, you can design a bus-mastering accelerator that handles all such copying itself. The accelerator in this case will need to include an active load/store unit (as SystemC process) that copies data between external system DRAM and local accelerator SRAM under control of and in coordination with the dot product computations within the accelerator. The Zynq UltraScale+ provides ports between the processing subsystem (PS) and the programmable logic (PL)/FPGA fabric that will allow for a bus-mastering accelerator including direct cache or memory access. These ports are also exposed to the SystemC side as TLM sockets in the provided co-simulation library (see libsystemctlm-soc/soc/Xilinx/zynqmp/xilinx-zynqmp.h). For example, you can connect an initiator socket of your accelerator module to the S_AXI_HP0_FPD port for non-coherent bus-mastering main memory access as follows:

mbus = new iconnect<1,1> ("membus");
mbus->memmap(0x0LL, 0x8000000 - 1, ADDRMODE_RELATIVE, -1, *(zynq.s_axi_hp_fpd[0]));
accelerator->master_socket.bind(*mbus->t_sk[0]));

Note that our boards only have 2GB of DDR4 memory. As such, and as documented in the Zynq UltraScale+ manual (see address map), the addressable DRAM range shared between the CPU and the FPGA fabric (and hence SystemC) is 0x00000000 to 0x7FFFFFFF. In addition, the Zync has 256KB of on-chip scratchpad memory (OCM) that can be accessed from both the CPU and FPGA (by default mapped high to addresses 0xFFFC0000 to 0xFFFFFFFF in our platform) for sharing of data with faster SRAM access times.

 


4         Llama.cpp Application Mapping

To set up a simulation of the llama.cpp application running on the virtual prototype of our accelerated target platform, the following steps need to be performed:

a)     Using the application example in the tutorial as a reference, develop a hardware abstraction layer (HAL) and driver (kernel module) that can serve as a stub for the dot product functionality. The HAL should be a drop-in substitute for the existing dot product function call, i.e. it replaces the call with an implementation that makes equivalent calls to the external hardware instead. Make any necessary modifications to the kernel module if you need to.

b)     Integrate your HAL into llama.cpp, cross-compile the ‘llama.cpp’ executable, add it to the simulated platform and run the setup in the co-simulated ARM+FPGA environment. Verify that the hardware/software interaction is working properly and that the correct output is produced when running the Tiny-Stories network (from Lab 1) on top of your llama.cpp framework. To ensure fast simulation, you can limit generation to 10 or fewer tokens, using the command line flag -n <max tokens>. To validate, add optional checks within the HAL (e.g., by calculating the dot product using the original Llama.cpp code and comparing vector outputs).

c)      (Extra credit) Explore different accelerator architectures, possibly including changing where the boundary is for your accelerator calls. In other words, consider: is the dot product is the best place to split llama.cpp? How can you reduce the number of accelerator calls, and how can you improve reuse across dot products, remembering that decode is dominated by GEMV operations?

 


5         Lab Submission

Submit your report to Canvas and code to Classroom 50. The report should summarize your work flow, describe your simulation setup, document the model and application code modifications, and analyze your simulation results. Generally include the following in your Classroom 50 repository:

•        The SystemC platform model, including sources.

•        Source code for the dot product SystemC module.

•        Source code for the ARM HAL and driver code.

•        README files that describe how to compile and run your platform simulation.

Specifically, submit the following deliverables for Parts 3 and 4 in Classroom 50:

•        A directory named part3 in the lab3 repository in Classroom 50 that includes the following:

–       A README file including how to compile your design.

–       A Makefile or script to compile and/or run your code, if necessary.

–       All required C/C++ code (source files).

–       Any golden input/output test files. Please keep the total size of these files to less than 50MB.

•        A directory named part4 in the lab3 repository in Classroom 50 that includes the following:

–       A README file including how to compile your design.

–       A Makefile or script to compile and/or run your code, if necessary.

–       All required C/C++ code (source files, ideally using a new llama.cpp branch).

–       Any golden input/output test files. Please keep the total size of these files to less than 50MB.