SystemC TLM

Embed Size (px)

Citation preview

  • 8/18/2019 SystemC TLM

    1/33

    17-5-2011

    Challenge the future

    DelftUniversity of Technology

    SystemC-TLM Transaction Level Modeling

     Alexander de Graaf, EEMCS-CAS

  • 8/18/2019 SystemC TLM

    2/33

    2SystemC-TLM

    1.SystemC-TLM Transaction Level Modeling 

  • 8/18/2019 SystemC TLM

    3/33

    3SystemC-TLM

     Topics

    Simulation Use CasesBasic Concepts

    Generic Payload – Information

     API – The Transaction Call

    Sockets – ConnectivityLoosely Timed – Fast

     Approximately Timed – Accurate

    Base Protocol – Modeling

    abstraction

     An example

  • 8/18/2019 SystemC TLM

    4/33

    4SystemC-TLM

    Simulation Use Cases

     Architectural Analysis

    • Do interconnections meet

    needs?

    • Requires quick modeling and

    1st order accuracy

    Software Development

    • Early development

    • Requires speed

    Hardware Development

    • Early development

    • Improve schedule and

    ensure sufficient coverage

    • Requires some accuracy

     Architectural Analysis

    • Do interconnections meet

    needs?

    • Requires quick modeling and

    1st order accuracy

  • 8/18/2019 SystemC TLM

    5/33

    5SystemC-TLM

    Fundamental Ideas

    • TLM 2.0 models Memory-Mapped Bus-Transport

    • Exchange information (payload)

    between initiator and target

    Target

    TargetInitiator

    Initiator

    Initiator Target

    InformationUpdated

    time

  • 8/18/2019 SystemC TLM

    6/33

    6SystemC-TLM

    Four Basic TLM 2.0 Concepts

    6

    TargetTargetInitiatorInitiator

    1. Core interfaces

    my_skt->b_transport(gp, …)

    &2. Generic payload

    Command

     Address

    Data

    Byte enablesResponse status

    Extensions

    4. Base protocol

    BEGIN_REQ

    END_REQ

    BEGIN_RESP

    END_RESP

    payloadreference

    2. Sockets & Connectivity

  • 8/18/2019 SystemC TLM

    7/33

    7SystemC-TLM

    Many Configurations Considered

    I/OI/O

    MPUMPU

    I/OI/O

    InterconnectInterconnect

    CPUCPU

    MemMem Peripheral busPeripheral bus

    DMA DMA 

    MemMem

    Processor busProcessor bus

    CPUCPU

    PeriphPeriphMemMem  Arbiter Arbiter

  • 8/18/2019 SystemC TLM

    8/33

    8SystemC-TLM

    Core Interface –  

     The Transaction Call

    • Generally one of two simple transport calls1. void

    2. void

    • Declared beneath interface classes ( enables port/socket)

    tlm::tlm_fw_transport_if • tlm::tlm_bw_transport_if 

    • Implemented as methods (member function) of models

    • TLM models are disguised SystemC channels

    voidb_transport(TRANS& payload, sc_time& t);

    voidnb_transport_fw(TRANS& payload,

    PHASE& ph,sc_time& t);

  • 8/18/2019 SystemC TLM

    9/33

    9SystemC-TLM

    Generic Payload - 

    Information

    • What is the Payload?

    • Simple structured object that contains:

    • Control (command)

    • Data

    •  Various Properties & Extensions

    • Designed for memory mapped buses

    • Burst size

    • Byte lanes

    Defined as a class for flexibility• Payload is passed by reference

    • Speeds calling by reducing copy overhead

    • Need to be cognizant of lifetime

  • 8/18/2019 SystemC TLM

    10/33

    10SystemC-TLM

    Simple Transport Call

    sc_time tDelay;tlm::tlm_generic_payload payload;

    sc_core::uint32 addr(55);

    payload.set_address(addr);

    payload.set_data_ptr(&data);payload.set_write(); // commandtDelay = SC_ZERO_TIME;

     // Execute a transactionb_transport(payload, tDelay);wait(tDelay);

  • 8/18/2019 SystemC TLM

    11/33

    11SystemC-TLM

    InitiatorInitiator

     TLM Sockets - 

    more than convenient

    • Transactions include communications in both directions

    • Initiator to target

    • Target to initiator

    • Normally requires port/export and export/port pair(i.e. a lot of binding)

    • Replaced with specialized port

    (simplifies binding)

    TargetTarget

    TargetTargetInitiatorInitiator

  • 8/18/2019 SystemC TLM

    12/33

    12SystemC-TLM

    Target_mdlTarget_mdl

     TLM 2.0 Socket Graphically 

    Initiator_mdlInitiator_mdl

    init_skt->fw()

    Backwardmethods

    Forewardmethods

    init_skt->bw()

    init_process

    target_process

  • 8/18/2019 SystemC TLM

    13/33

    13SystemC-TLM

    Example: Initiator declaration

    class Initiator_mdl: public sc_module, public tlm_bw_transport_if

    {public:tlm::tlm_initiator_socket init_socket;SC_TOR (Initiator_mdl); // Constructor

    ~Initiator_mdl(); // Destructorvoid init_process(); // forward call made here

     // Backwards flowing API for initiator socket // Must implement all backward calls ( even if trivially)tlm::tlm_sync_enum nb_transport_bw( … );void invalidate_direct_mem_ptr ( … );

    };

  • 8/18/2019 SystemC TLM

    14/33

    14SystemC-TLM

    Example: Target declaration

    class Target_mdl: public sc_module, public tlm_fw_transport_if{

    public:tlm::tlm_target_socket targ_skt;SC_TOR (Target_mdl); // Constructor~Target_mdl(); // Destructor

     // Forwards flowing API for initiator socket // Must implement all forward calls ( even if trivially)

    void b_transport ( … );tlm::tlm_sync_enum nb_transport_fw( … );void get_direct_mem_ptr ( … );void transport_dbg ( … );

    };

  • 8/18/2019 SystemC TLM

    15/33

    15SystemC-TLM

    Example: Top-level connectivity 

    class Top_mdl : public sc_module{

    public:Initiator_mdl *init_ptr;Target_mdl *targ_ptr;SC_TOR (Top_mdl) {

    new Initiator_mdl(“init”);new Target_mdl(“targ”);init_ptr->init_skt.bind( targ_ptr->targ_skt );

    }

    ~Top_mdl(); // Destructor};

  • 8/18/2019 SystemC TLM

    16/33

    16SystemC-TLM

    Model Coding Styles

    • TLM 2.0 introduces two terms• Loosely Timed (LT) modeling – “fast” 

    • approximately Timed (AT) modeling – “accurate” 

    • Terminology that roughly defines

    • Simulation speed

    • Timing accuracy

    • Model applicability

    • Older terminology

    • Untimed(UT), Programmers View (PV),

    Programmers View with Timing (PVT), Cycle Accurate

    • Too specific and often miss the point

  • 8/18/2019 SystemC TLM

    17/33

    17SystemC-TLM

    Loosely Timed (LT) -

     

    fast

    • Use Case

    • Early Software Development

    • Hardware Verification of portions of functionality

    Speed up portions of other use cases prior to analysis• Characteristics

    • Just enough detail to boot O/S and run multicore-systems

    • Processes can run ahead of simulation time (temporal decoupling)

    • Transactions have two timing points: begin and end  • Maybe easier to code due to less detail

    template

    class tlm_blocking_transport_if : sc_interface {virtual void b_transport( PAYLD& , sc_time&) = 0;

    };

  • 8/18/2019 SystemC TLM

    18/33

    18SystemC-TLM

    Loosely Timed Mechanisms

    • Impediments to speed

    • Context switching

    • wait()

    • next_trigger(); return;

    • Doesn’t matter whether SC_THREAD or SC_METHOD

    • Complex bus protocols and lots of processes

    • Reduce context switching to improve simulation speed

    • Temporal decoupling

    When time doesn’t matter as much• Keep track of “local” time

    • Direct Memory Interface

    • Bypass bus for some purposes to gain performance

  • 8/18/2019 SystemC TLM

    19/33

    19SystemC-TLM

    Blocking Transport/ LT Modeling (1/2)

    19

    Initiator  Target

    tsim = 100ns

    tsim = 180ns

    wait(40ns)

    Initiator is blocked until return from b_transport

    b_transport(gp, 0ns)Call

    Returnb_transport(gp, 0ns)

    tsim = 140ns

    wait(40ns)

    b_transport(gp, 0ns)Call

    Returnb_transport(gp, 0ns)

    tsim = 140ns

    Initiator is blocked until return from b_transport

    Not Optimal

  • 8/18/2019 SystemC TLM

    20/33

    20SystemC-TLM

    Blocking Transport/ LT Modeling (2/2)

    20

    Initiator  Target

    tsim = 180ns

    tsim = 260ns

    wait(80ns)

    b_transport(gp, 40ns)Call

    Returnb_transport(gp, 80ns)

    t l o c a l  =  1 8 0 + 4 0  n s 

    b_transport(gp, 0ns)Call

    Returnb_transport(gp, 40ns)

    tsim = 180ns

    Fewer context switches = faster simulation

    t l o c a l  =  1 8 0 + 8 0  n s 

    t l o c a l  =  2 6 0 + 0  n s 

  • 8/18/2019 SystemC TLM

    21/33

    21SystemC-TLM

    Approximately Timed - 

    Accurate

    • Use cases

    •  Architectural Analysis, Software Performance Analysis

    • Hardware Verification

    • Characteristics

    • Sufficient for architectural and performance exploration

    Processes run in lock-step with simulation time• Transactions have four timing points

    templateclass tlm_nonblocking_transport_if : sc_interface {

    virtual void nb_transport_fw( PAYLD& , PHASE&, sc_time&) = 0;};

  • 8/18/2019 SystemC TLM

    22/33

    22SystemC-TLM

    Approximately Timed Mechanisms

    • Concerns – Providing sufficient accuracy• Negotiation time

    • Command (read/write) execution time

    • Response time

    • Simulation time fidelity

    • Bus interactions

    • Techniques

    • Base Protocol with four timing points

    • Non-blocking calls (slight coding complexity)

    • Payload Event Queue to model transport delay

  • 8/18/2019 SystemC TLM

    23/33

    23SystemC-TLM

    Non-Blocking/ AT Modeling continued

    • Also has backward initiated component

    template

    class tlm_bw_nonblocking_transport_if : sc_interface {

    virtual void nb_transport_bw( PAYLD& , PHASE&, sc_time&) = 0;};

    TargetTargetInitiatorInitiator

    Forward

    path

    Backward

    path

  • 8/18/2019 SystemC TLM

    24/33

    24SystemC-TLM

    Four Timing Points = Four Phases

    • BEGIN_REQ (Begin Request)

    • Initiator acquires bus

    • Connections becomes “busy” and blocks further requests

    • Payload becomes “busy” 

    • END_REQ

    • Target “accepts” request and completes the handshake

    Bus freed to start additional requests• BEGIN_RESP

    • Target acquires bus to provide a response

    • Bus becomes “busy” 

    • END_RESP• Initiator acknowledges response to complete it

    • Bus freed

    • Payload reference freed up

  • 8/18/2019 SystemC TLM

    25/33

    25SystemC-TLM

    Non-Blocking Return Type

    • TLM_ACCEPTED

    • Transaction, phase and timing arguments unmodified (ignored) on return

    • Target may respond later (depending on protocol)

    • TLM_UPDATED

    • Transaction, phase and timing arguments updated (used) on return

    • Target has advanced the protocol state machine to the next state

    • TLM_COMPLETED

    • Transaction, phase and timing arguments updated (used) on return

    • Target has advanced the protocol state machine straight to the final phase

    enum tlm_sync_enum{ TLM_ACCEPTED, TLM_UPDATED, TLM_COMPLETED };

  • 8/18/2019 SystemC TLM

    26/33

    26SystemC-TLM

    Base Protocol and AT 

    • TLM 2.0 defines “Base Protocol” 

    • High-level concept modeling time progression

    • Maps to many bus protocols in a rough manner

    • a single TLM transaction may cross one or more busses

    • Possibly each with a different hardware protocol

    • Following slides illustrate some of the TLM possibilities

    • 4 distinct phases using the backward path

    • 2 distinct phases using the return path

    • 1 combined phase with early return completion

    Use of timing annotation possible as well

  • 8/18/2019 SystemC TLM

    27/33

    27SystemC-TLM

    Notation for Message Sequence Charts

    -, BEGIN_REQ, 0ns

    status = nb_transport ( trans, phase, delay ) ;

    Call

    Local time

    Simulation time = 5us

    +10ns

    +20ns

    For temporal decoupl ing, local time is added to

    simulation time (explained on slides)

    = sc_time_stamp()

    TLM_COMPLETED, BEGIN_RESP, 10nsReturn

     Arguments passed to function

    Values returned from function

  • 8/18/2019 SystemC TLM

    28/33

    28SystemC-TLM

    Using the Backward Path

    Initiator  TargetPhase

    TLM_ACCEPTED, -, - Return

    BEGIN_REQ

    -, BEGIN_REQ, 0nsCall

    TLM_ACCEPTED, -, -Return

    Simulation t ime = 100ns

    -, END_REQ, 0ns

    END_REQ

    Call

    Simulation t ime = 110ns

    TLM_ACCEPTED, -, - Return

    -, BEGIN_RESP, 0ns

    BEGIN_RESP

    Call

    Simulation t ime = 120ns

    TLM_ACCEPTED, -, -Return

    END_RESP

    -, END_RESP, 0nsCall

    Simulation t ime = 130ns

    Transaction accepted now, caller asked to wait

  • 8/18/2019 SystemC TLM

    29/33

    29SystemC-TLM

    Using the Return Path

    Initiator  TargetPhase

    BEGIN_REQ

    -, BEGIN_REQ, 0nsCall

    Simulation time = 100ns

    TLM_UPDATED, END_RESP, 5ns Return

    -, BEGIN_RESP, 0ns

    BEGIN_RESP

    Call

    Simulation time = 150ns

    TLM_UPDATED, END_REQ, 10nsReturn

    END_REQ Simulation time = 110ns

    Callee annotates delay to next transition, caller waits

    END_RESP Simulation time = 155ns

  • 8/18/2019 SystemC TLM

    30/33

    30SystemC-TLM

    Early Completion

    Initiator  TargetPhase

    BEGIN_REQ

    -, BEGIN_REQ, 0nsCall

    TLM_COMPLETED, -, 10ns Return

    END_RESP Simulation time = 110ns

    Callee annotates delay to next transition, caller waits

    Simulation time = 100ns

  • 8/18/2019 SystemC TLM

    31/33

    31SystemC-TLM

     Timing AnnotationInitiator  TargetPhase

    -, BEGIN_REQ, 10nsCall

    TLM_ACCEPTED, -, - Return

    Simulation time = 100ns

    Payload

    EventQueue

    Simulation time = 110nsBEGIN_REQ

    -, END_REQ, 10ns Call

    Simulation time = 125ns

    TLM_ACCEPTED, -, -ReturnPayloadEvent

    Queue

    END_REQ Simulation time = 135ns

  • 8/18/2019 SystemC TLM

    32/33

    32SystemC-TLM

    Summary: Key Features of TLM-2

    Transport interfaces with timing annotation and phases

    DMI and debug interfaces

    Loosely-timed coding style and temporal decoupling for

    simulation speed

     Approximately-timed coding style for timing accuracy

    Sockets for convenience and strong connection checking

    Generic payload for memory-mapped bus modelling

    Base protocol for interoperability between TL- models

    Extensions for flexibility of modelling

  • 8/18/2019 SystemC TLM

    33/33

    33SystemC-TLM

    MBLite Platform

    MBLite ISS router 

    1i

    2i

    Ni

    Memory1t

    Uart Terminal2t 1t

    Wishbone bus

    Slave1 Slave2

    1i

    Nt

    2i1i

    1t 1t

    Router.map