Changes between Version 65 and Version 66 of Writing Rules/Tlmt


Ignore:
Timestamp:
Nov 15, 2008, 5:59:14 PM (15 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Writing Rules/Tlmt

    v65 v66  
    4242channels: one to transmit the VCI command packet, one to transmit the VCI response packet.
    4343
    44 = C) VCI initiator Modeling =
    45 
    46 In the proposed example, the initiator module is modeled by the '''my_initiator''' class.
    47 This class inherits from the standard SystemC '''sc_core::sc_module''' class, that acts as the root class for all TLM-T modules.
    48 
    49 The initiator local time is contained in a member variable named '''m_localTime''', of type '''sc_core::sc_time'''. The
    50 local time can be accessed with the following accessors: '''addLocalTime()''', '''setLocalTime()'''
    51 and '''getLocalTime()'''.
    52 {{{
    53   sc_core::sc_time m_localTime;                     // the initiator local time
    54   ...
    55   void addLocalTime(sc_core::sc_time t);            // add an increment to the local time
    56   void setLocalTime(sc_core::sc_time& t);           // set the local time
    57   sc_core::sc_time getLocalTime(void);              // get the local time
    58 }}}
    59 
    60 The boolean member variable '''m_activity''' indicates if the initiator is currently active.
    61 It is used by the arbitration threads contained in the '''vci_vgmn''' interconnect, as described in section E.
    62 The corresponding access functions are '''setActivity()''' and '''getActivity()'''.
    63 {{{
    64   bool m_activity;
    65   ...
    66   void setActivity(bool t);                         // set the activity status (true if the component is active)
    67   bool getActivity(void);                           // get the activity state
    68 }}}
    69 
    70 The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function.
    71 
    72 Finally, the class '''my_initiator''' must contain a member variable '''p_vci_init''', of type '''tlmt_simple_initiator_socket'''.
    73 This member variable represents the VCI initiator port.
    74 
    75 == C.1) Sending a VCI command packet ==
    76 
    77 To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, that is a member
    78 function of the '''p_vci_init''' port. The prototype of this method is the following:
    79 {{{
    80 
    81   tlm::tlm_sync_enum nb_transport_fw               /// sync status
    82   ( soclib_vci_types::tlm_payload_type &payload,      ///< VCI payload pointer
    83     soclib_vci_types::tlm_phase_type   &phase,       ///< transaction phase
    84     sc_core::sc_time                   &time);        ///< time
    85 }}}
    86 
    87 The first parameter of this member function is the VCI packet, the second represents the phase (TLMT_CMD in this case), and the third
    88 parameter contains the initiator local time.
    89 
    90 To prepare a VCI packet for sending, the '''execLoop''' function must declare two objects locally, '''payload''' and '''phase'''.
    91 {{{
    92   soclib_vci_types::tlm_payload_type payload;
    93   soclib_vci_types::tlm_phase_type phase;
    94 }}}
     44= C) TLM-T VCI Transaction =
     45
     46The TLM2.0 standard allows the user to redefine both the payload and the phases of a transaction.
     47Two classes are defined in '''soclib_vci_types''' :  a '''tlmt_vci_transaction''' and a '''tlmt_phase".
     48
    9549A payload of type '''soclib_vci_types::tlm_payload_type''' corresponds to a '''tlmt_vci_transaction'''.
    9650It contains three groups of information:
     
    9852 * TLM-T related fields
    9953 * VCI related fields
    100 The contents of a '''tlmt_vci_transaction''' is defined below:
    10154{{{
    10255class tlmt_vci_transaction
     
    13992and '''set_store_cond()''' (for atomic store conditional). The '''set_src_id()''', '''set_trd_id()''' and '''set_pkt_id()''' functions
    14093respectively set the VCI source, thread and packet identifiers.
    141 The following example describes a VCI write command:
    142 {{{
    143     payload.set_address(0x10000000);//ram 0
    144     payload.set_byte_enable_ptr(byte_enable);
    145     payload.set_byte_enable_length(nbytes);
    146     payload.set_data_ptr(data);
    147     payload.set_data_length(nbytes); // 5 words of 32 bits
    148 
    149     payload.set_write();
    150     payload.set_src_id(m_id);
    151     payload.set_trd_id(0);
    152     payload.set_pkt_id(pktid);
    153 
    154     phase= soclib::tlmt::TLMT_CMD;
    155     sendTime = getLocalTime();
    156 
    157     p_vci_init->nb_transport_fw(payload, phase, sendTime);
    158 }}}
    159 
     94
     95= D) VCI initiator Modeling =
     96
     97== D1) Member variables ==
     98
     99In the proposed example, the initiator module is modeled by the '''my_initiator''' class.
     100This class inherits from the standard SystemC '''sc_core::sc_module''' class, that acts as the root class for all TLM-T modules.
     101
     102The initiator local time is contained in a member variable named '''m_localTime''', of type '''sc_core::sc_time'''. The
     103local time can be accessed with the following accessors: '''addLocalTime()''', '''setLocalTime()'''
     104and '''getLocalTime()'''.
     105{{{
     106  sc_core::sc_time m_localTime;                     // the initiator local time
     107  ...
     108  void addLocalTime(sc_core::sc_time t);            // add an increment to the local time
     109  void setLocalTime(sc_core::sc_time& t);           // set the local time
     110  sc_core::sc_time getLocalTime(void);              // get the local time
     111}}}
     112
     113The boolean member variable '''m_activity''' indicates if the initiator is currently active.
     114It is used by the arbitration threads contained in the '''vci_vgmn''' interconnect, as described in section E.
     115The corresponding access functions are '''setActivity()''' and '''getActivity()'''.
     116{{{
     117  bool m_activity;
     118  ...
     119  void setActivity(bool t);                         // set the activity status (true if the component is active)
     120  bool getActivity(void);                           // get the activity state
     121}}}
     122
     123The '''execLoop()''' method, describing the initiator behaviour must be declared as a member function.
     124
     125Finally, the class '''my_initiator''' must contain a member variable '''p_vci_init''', of type '''tlmt_simple_initiator_socket'''.
     126This member variable represents the VCI initiator port.
     127
     128== D.2) Sending a VCI command packet ==
     129
     130To send a VCI command packet, the '''execLoop()''' method must use the '''nb_transport_fw()''' method, that is a member
     131function of the '''p_vci_init''' port. The prototype of this method is the following:
     132{{{
     133
     134  tlm::tlm_sync_enum nb_transport_fw           
     135  ( soclib_vci_types::tlm_payload_type &payload,      // VCI payload pointer
     136    soclib_vci_types::tlm_phase_type   &phase,       // transaction phase (TLMT_CMD)
     137    sc_core::sc_time                   &time);        // local time
     138}}}
     139
     140The first argument is a pointer to the payload, the second represents the phase (TLMT_CMD in this case), and the third
     141argument contains the initiator local time.
    160142
    161143The '''nb_transport_fw()''' function is non-blocking.
     
    164146the '''execLoop()''' thread is then suspended, and will be reactivated when the response packet is actually received.
    165147
    166 == C.2) Receiving a VCI response packet ==
     148== D.3) Receiving a VCI response packet ==
    167149
    168150To receive a VCI response packet, a call-back function must be defined as a member function of the
    169 class '''my_initiator'''. This call-back function (named '''vci_rsp_received()''' in the example), must be
    170 declared in the '''my_initiator''' class and
     151class '''my_initiator'''. This call-back function (named '''vci_rsp_received()''' in the example),
    171152is executed each time a VCI response packet is received on the '''p_vci_init''' port. The function name is not
    172153constrained, but the arguments must respect the following prototype:
     
    174155  tlm::tlm_sync_enum vci_rsp_received             
    175156    ( soclib_vci_types::tlm_payload_type &payload,     // payload
    176       soclib_vci_types::tlm_phase_type   &phase,      // transaction phase
    177       sc_core::sc_time                   &time);       // resp time
    178 }}}
    179 The return value (type tlm::tlm_sync_enum)  must be sytematically set to tlm::TLM_COMPLETED in this implementation
    180 The function parameters are identical to those described in the forward transport function
     157      soclib_vci_types::tlm_phase_type   &phase,      // transaction phase (TLMT_RSP)
     158      sc_core::sc_time                   &time);       // response time
     159}}}
     160The return value (type tlm::tlm_sync_enum)  is not used in this tlmt implementation, and must be sytematically set to tlm::TLM_COMPLETED.
    181161
    182162In the general case, the actions executed by the call-back function depend on the response transaction type ('''m_command''' field), as well as
    183163the '''pktid''' and '''trdid''' fields.
    184 For sake of simplicity, the call-back function proposed below does not make any distinction between VCI transaction types.
    185 
    186 == C.3) Initiator Constructor ==
     164For sake of simplicity, the call-back function proposed in the example below does not make any distinction between transaction types.
     165
     166== D.4) Initiator Constructor ==
    187167
    188168The constructor of the class '''my_initiator''' must initialize all the member variables, including
     
    195175}}}
    196176
    197 == C.4) Lookahead parameter ==
     177== D.5) Lookahead parameter ==
    198178
    199179The SystemC simulation engine behaves as a cooperative, non-preemptive multi-tasks system. Any thread in the system must stop execution
     
    208188and a slower simulation speed.
    209189
    210 == C.4) VCI initiator example ==
     190== D.6) VCI initiator example ==
    211191
    212192{{{
     
    220200}}}
    221201
    222 = D) VCI target modeling =
     202= E) VCI target modeling =
    223203
    224204In the proposed example, the '''my_target''' component handles all VCI commands in the same way, and there is no error management.
     205
     206== E1) Member variables & methods
    225207
    226208The class '''my_target''' inherits from the class '''sc_core::sc_module'''. The class '''my_target''' contains a member
    227209variable '''p_vci_target''' of type '''tlmt_simple_target_socket'''. This object has 3 template parameters, that are identical to
    228210those used for declaring initiator ports (see above).
    229 
    230 == D.1) Receiving a VCI command packet ==
     211It contains a call-back function as described below.
     212
     213== E.2) Receiving a VCI command packet ==
    231214
    232215To receive a VCI command packet, a call-back function must be defined as a member function of the class '''my_target'''.
    233 This call-back function (named '''vci_cmd_received()''' in the example), will be executed each time a VCI command packet is received on
     216This call-back function (named '''vci_cmd_received()''' in the example), is executed each time a VCI command packet is received on
    234217the '''p_vci_target''' port. The function name is not constrained, but the arguments must respect the following prototype:
    235218{{{
     
    240223}}} 
    241224
    242 == D.2) Sending a VCI response packet ==
    243 
    244 To send a VCI response packet the call-back function '''vci_cmd_received()''' must use the '''nb_transport_bw()''' method, that is a member function of
     225== E.3) Sending a VCI response packet ==
     226
     227To send a VCI response packet the call-back function '''vci_cmd_received()''' use the '''nb_transport_bw()''' method, that is a member function of
    245228the class '''tlmt_simple_target_socket''', and has the same arguments as the '''nb_transport_fw()''' function.
    246229Respecting the general TLM2.0 policy, the payload argument refers to the same '''tlmt_vci_transaction''' object for both the '''nb_transport_fw()''' and '''nb_transport_bw()''' functions,
    247 and the associated call-back functions. The set_response_status field must be documented for all transaction types, but only two values are used in this implementation:
     230and the associated call-back functions. The set_response_status field must be documented for all transaction types, but only two values are used in this TLM-T implementation:
    248231 * TLMT_OK_RESPONSE
    249232 * TLMT_ERROR_RESPONSE
     
    257240}}}
    258241
    259 == D.3) Target Constructor ==
     242== E.4) Target Constructor ==
    260243
    261244The constructor of the class '''my_target''' must initialize all the member variables, including
     
    267250}}}
    268251
    269 == D.4) VCI target example ==
     252== E.5) VCI target example ==
    270253 {{{
    271254
     
    278261}}}
    279262
    280 = E) VCI Interconnect modelling =
    281 
    282 The VCI interconnect used for the TLM-T simulation is a generic simulation model, named '''!VciVgmn'''.
     263= F) VCI Interconnect modelling =
     264
     265The VCI interconnect used for the TLM-T simulation is a generic interconnection network, named '''!VciVgmn'''.
    283266The two main parameters are the number of initiators, and the number of targets. In TLM-T simulation,
    284267we don't want to reproduce the cycle-accurate behavior of a particular interconnect. We only want to simulate the contention in
     
    291274[[Image(tlmt_figure_2.png, nolink)]]
    292275
    293 == E.1) Generic network modeling ==
     276== F.1) Generic network modeling ==
    294277
    295278 There is actually two fully independent networks for VCI command packets and VCI response packets. There is a routing function for each input
     
    304287[[Image(tlmt_figure_3.png, nolink)]]
    305288
    306 == E.2) Arbitration Policy ==
     289== F.2) Arbitration Policy ==
    307290
    308291As described above, there is one '''cmd_arbitration''' thread associated to each VCI target. This thread is in charge of selecting one timed request between
     
    331314}}}
    332315
    333 As the net-list of the simulated pltform mus be explicitely defined before constructing those LocalTime and ActivityStatus arrays, the vgmn hardware component
     316As the net-list of the simulated platform mus be explicitely defined before constructing those LocalTime and ActivityStatus arrays, the vgmn hardware component
    334317provides an utility function '''fill_time_activity_arrays()''' that must be called in the SystemC top-cell, before starting the simulation.
    335318