Chapter 14: SystemC

CCI Parameters and Brokers

Deep dive into cci_param mechanics, mutability, locking, and callbacks.

CCI Parameters, Brokers, and Callbacks

The IEEE 1666.1 CCI standard does more than just initialize values. It provides an exhaustive API for locking parameters during simulation and triggering software callbacks when parameters change.

Locking Parameters

In hardware, certain configurations cannot change once silicon boots (e.g., the physical bit-width of a data bus). The LRM allows a cci_param to be locked. Any subsequent attempt to call set_value() on a locked parameter throws a fatal CCI error.

cci::cci_param<int> bus_width("bus_width", 32);
 
// Inside end_of_elaboration():
bus_width.lock();

Complete CCI Callback Example

GUI debuggers heavily utilize CCI Callbacks. When a user changes a value in a graphical property tree, the debugger pushes the change to the broker. The IP block's callback fires, allowing it to reconfigure itself mid-simulation dynamically.

#include <systemc>
#include <cci_configuration>
 
void my_cci_callback(const cci::cci_param_write_event<int>& ev) {
    std::cout << ">>> [CCI CALLBACK] Parameter changed from " 
              << ev.old_value << " to " << ev.new_value << std::endl;
}
 
SC_MODULE(ConfigurableIP) {
    cci::cci_param<int> power_mode;
 
    SC_CTOR(ConfigurableIP) : power_mode("power_mode", 0) {
        // Register the callback
        power_mode.register_write_callback(&my_cci_callback);
        
        SC_THREAD(run);
    }
 
    void run() {
        wait(10, sc_core::SC_NS);
        // Writing to the parameter triggers the callback immediately
        power_mode.set_value(1);
    }
};
 
int sc_main(int argc, char* argv[]) {
    ConfigurableIP ip("ip");
    sc_core::sc_start(20, sc_core::SC_NS);
    return 0;
}

The CCI API separates the mechanisms of configuration from the IP source code, ensuring a highly decoupled and professional Virtual Platform architecture.

Comments and Corrections