Chapter 5: Source Internals

A Practical SystemC Source-Reading Workflow

How to move from public API behavior to the implementation without getting lost in templates.

Reading SystemC source is not like reading a small application. It is a mature C++ library with compatibility concerns, macros, templates, platform code, and multiple abstraction layers. You need a workflow.

Start From a Tiny Example

Pick one behavior:

SC_METHOD(comb);
sensitive << a << b;

Ask one question: how does this method become runnable when a changes?

Now follow only the code needed for that question. Ignore unrelated template specializations until they become necessary.

Trace Public API to Internal Object

For any feature, identify:

  1. The public type or macro the user writes.
  2. The object created by that API.
  3. The simulation context it registers with.
  4. The callback or virtual function invoked later.
  5. The event or update that causes progress.

This turns source reading into a graph walk rather than a file-reading marathon.

Use Search Terms That Match Concepts

Useful searches:

rg "request_update" src
rg "notify" src/sysc
rg "sc_simcontext" src
rg "SC_METHOD" src
rg "b_transport" src

When a term is too broad, search for a public method name plus a class name.

Read Header First, Implementation Second

Headers show the API and object relationships. Implementation files show scheduling and policy.

For example, with signals:

  1. Read the signal class declaration.
  2. Find write().
  3. Find where it requests an update.
  4. Find update().
  5. Find where value-change events are notified.

That sequence explains user-visible behavior.

Keep a Source Notebook

For each source reading session, write down:

  • public API
  • internal type
  • key member fields
  • important callbacks
  • scheduler interaction
  • surprising edge cases

This site can grow those notes into new lessons. The best technical tutorials are not just explanations; they are maps of what the reader should inspect next.

Comments and Corrections