Changes between Initial Version and Version 1 of Writing Rules/Caba


Ignore:
Timestamp:
Mar 26, 2007, 6:54:41 PM (17 years ago)
Author:
Nicolas Pouillon
Comment:

First draft, from AG

Legend:

Unmodified
Added
Removed
Modified
  • Writing Rules/Caba

    v1 v1  
     1= Introduction =
     2
     3This manual describes the modeling rules for writing "cycle-accurate / bit-accurate" SystemC simulation models. Those models can be used with the "standard" OSCI simulation engine (SystemC 2.0), but can be used also with others simulation engines, such as SystemCASS, which is optimized for models complying with those rules.
     4
     5Those modeling rules are based on the "Synchronous Communicating Finite State Machines" theory. The idea is to force the "event driven" SystemC simulation engine to run as a cycle based simulator.
     6
     7A given hardware architecture is obtained by direct instanciation of hardware modules, connected by signals. A given architecture can contain several instances of the same module. Each module is described as one (or several) synchronous FSM(s).
     8
     9If all internal register are clearly identified, any FSM can be described by three types of functions:
     10 * The Transition function computes the next values of the register, depending on the current values of the register and the values of the input ports signals.
     11 * The Moore generation function  computes the values of those output port signals that depend only on the internal registers.
     12 * The Mealy generation functions computes values of those output port signals that depend both on the internal registers AND the values of the input port signals.
     13
     14[[Image(fsm.png)]]
     15
     16In this figure we represented a single FSM, but a SoCLib component contains generally several small FSMs running in parallel inside a single module. This internal parallelism should be properly described.
     17
     18= How to write simulation models =
     19
     20== Component's module ==
     21
     22A SoCLib CABA component XXX is generally described as a class derived from the `soclib::caba ::BaseModule` class.
     23At least two files are associated to each hardware component:
     24 * The `XXX.h` file describes the component interface, the internal registers, and the structural parameters.
     25 * The `XXX.cpp` file contains the code of the methods associated to this component.
     26
     27== Component indexation ==
     28
     29In a VCI-based architecture, all initiators must be indexed by an index. Targets are indexes by their assigned address space. For simplification purposes, we'll also assign an index to the targets. Index space for targets is different from index space for initiators.
     30
     31The target index is used in the routing table implemented by the interconnect components in order to choose destination port for command packet.
     32The initiator index is used by the interconnect components to route the response packets.
     33
     34For the initiators, the index corresponds to the VCI SRCID value.
     35
     36This index can be a simple scalar index, in case of a « flat » interconnect, or it can be a composite index in case a hierarchical two level interconnect where each component is identified by two indexes : (cluster_index, local_index).
     37
     38== VCI Interface ==
     39
     40In order to enforce interoperability between components, all SoCLib hardware components should respect the advanced VCI interface.
     41Any component having a VCI interface must include one of the the two following files
     42 * [source:trunk/soclib/systemc/include/caba/interface/vci_target.h]
     43 * [source:trunk/soclib/systemc/include/caba/interface/vci_initiator.h]
     44
     45The advanced VCI signals are defined in [source:trunk/soclib/systemc/include/caba/interface/vci_signals.h caba/interface/vci_signals.h].
     46
     47As several VCI signals can have variable widths , all VCI components must be defined with templates. The caba/interface/vci_param.h file contains the definition of the VCI parameters object. This object must be passed as a template parameter to the component.
     48
     49== Address space segmentation ==
     50
     51In a shared memory architecture, the address space segmentation (or memory map) is a global characteristic of the system. This memory map must be defined by the system designer, and is used by both software, and hardware components.
     52
     53Most hardware components use this memory map:
     54 * VCI interconnect components contain a « routing table » used to decode the addresses and
     55   route VCI commands to the proper targets. This routing table is implemented as a ROM.
     56 * VCI target components must be able to check for segmentation violation when receiving a
     57   command packet. Therefore, the base address and size of the segment allocated to a given
     58   VCI target must be ''known'' by this target.
     59 * A cache controller supporting ''uncached segments'' must contain a ''cacheability table''
     60   addressed by the address MSB bits.
     61
     62In order to simplify the memory map definition, and the hardware component configuration, a generic object, called ''mapping table'' has been defined in [source:trunk/soclib/systemc/include/common/mapping_table.h common/mapping_table.h]. This is an associative table of memory segments. Any segment must be allocated to one single VCI target. The segment object is defined in [source:trunk/soclib/systemc/include/common/segment.h common/segment.h], and contains five attributes:
     63{{{
     64const std::string   m_name;           // segment's name
     65addr_t              m_base_address;   // base address
     66size_t              m_size;           // size (bytes)
     67IntTab              m_target_index;   // VCI target index
     68bool                m_cacheability;   // cacheable attribut
     69}}}
     70
     71Any hardware component using the memory map should have a constant reference to the mapping table as constructor argument.
     72
     73== Constructor arguments ==
     74
     75Any hardware component must have an instance name, and most SoCLib component must have a VCI index. Moreover, generic simulation models can have structural parameters, that must be defined as arguments in the constructor. A typical VCI component will have the following constructor arguments:
     76
     77{{{
     78VciLocks(
     79    sc_module_name                     insname,
     80    const soclib::common::IntTab       &index,
     81    const soclib::common::MappingTable &mt);
     82}}}
     83
     84In this example, the first argument is the instance name, the second argument is the VCI target index, and the third argument is the mapping table.
     85
     86== Naming conventions ==
     87
     88The following conventions are not mandatory, but can help to read the code.
     89 * All port names should be prefixed with `p_`
     90 * All internal register names should be prefixed with `r_`
     91 * All member variables should be prefixed with `m_`
     92
     93== Component ressources ==
     94
     95The component ''XXX.h'' file contains the following informations
     96
     97=== Interface definition ===
     98
     99A typical VCI target component will contain the following ports:
     100{{{
     101sc_in<bool>                         p_resetn;
     102sc_in<bool>                         p_clk;
     103soclib::caba::VciTarget<vci_param>  p_vci;
     104}}}
     105
     106=== Internal registers ===
     107
     108All internal registers must be defined with the type ''sc_signal''
     109
     110This point is a bit tricky: It allows the model designer to benefit from the delayed update mechanism associated by SystemC to the sc_signal type. When a single module contains several interacting FSMs, it helps to write the `Transition()`, as the registers values are not updated until the exit from the transition function. Conversely, any member variable declared with the `sc_signal` type is considered as a register.
     111
     112In order to improve the code readability, all internal registers should be prefixed with `_r`.
     113
     114A typical VCI target will contain the following registers :
     115
     116{{{
     117sc_signal<int>                          r_vci_fsm;
     118sc_signal<typename vci_param::trdid_t>  r_buf_trdid;
     119sc_signal<typename vci_param::pktid_t>  r_buf_srcid;
     120sc_signal<typename vci_param::srcid_t>  r_buf_srcid;
     121}}}
     122
     123''typename vci_param::trdid_t and others are generically-defined VCI field types.''
     124
     125=== Structural parameters ===
     126
     127All structural parameters must be be defined as member variables. The values are generally defined by a constructor argument.
     128A typical SoCLib component will contain an instance name, and a reference to the segment allocated to this component :
     129
     130{{{
     131sc_module_name                  m_name;
     132const soclib::common::Segment   m_segment;
     133}}}
     134
     135== Constructor & descructor ==
     136
     137The first constructor argument must be the instance name. Other arguments can be identifiers (such as a target VCI index or initiator VCI index). The constructor must configure some hardware ressources, such as the address decoding ROM that exists in any VCI interconnect. An argument frequently used is a reference on the Soclib segment table, that defines the segmentation of the system address space.
     138
     139Moreover, the constructor must define the sensitivity list of the Transition,(), genMoore() and genMealy() methods, that are described below. The sensitivity list of the Transition () method contains only the clock rising edge. The sensitivity list of the genMoore()n method contains only the clock falling edge. The sensitivity list of the genMealy() method contains the clock falling edge, as well as all input ports thare in the support of the Mealy generation function.
     140
     141Be careful : the constructor should NOT initialize the registers. The register initialisation must be an hardware mechanism explicitely described in the Transition function on reset condition.
     142
     143== Transition() method ==
     144
     145For each hardware component, there is only one `Transition()` method. It is called once per cycle, as the sensitivity list contains only the clock rising edge. This method computes the next values of the registers (variables that have the sc_signal type). No output port can be assigned in this method. Each register should be assigned only once.
     146
     147== genMoore() method ==
     148
     149For each hardware component, there is only one `genMoore()` method. It is called once per cycle, as the sensitivity list contains only the clock falling edge. This method computes the values of the Moore output ports. (variables that have the sc_out type)
     150No register can be assigned in this method. Each output port can be assigned only once.  No input port can be read in this method
     151
     152== genMealy() method ==
     153
     154For each hardware component, there is zero, one or several `genMealy()` methods (one method for each output port). These methods can be called several times per cycle. The sensitivity list can contain several input ports. This method computes the Mealy values of the ouput ports, using only the register values and the input ports values.
     155No register can be assigned in this method. Each output port can be assigned only once. This method can use automatic variables. It can be missing if there is no Mealy output.
     156