########################################################################
#
# This confidential and proprietary software may be used only as
# authorised by a licensing agreement from ARM Limited
#   (c) COPYRIGHT 1999-2010 ARM Limited
#       ALL RIGHTS RESERVED
# The entire notice above must be reproduced on all authorised
# copies and copies may only be made to the extent permitted
# by a licensing agreement from ARM Limited.
#
########################################################################

The model exports certain aspects of the programmer's model as signals available in
the top level.

        r0         User and System Mode R0
        r1         User and System Mode R1
        r2         User and System Mode R2
        r3         User and System Mode R3
        r4         User and System Mode R4
        r5         User and System Mode R5
        r6         User and System Mode R6
        r7         User and System Mode R7
        r8         User and System Mode R8
        r9         User and System Mode R9
        r10        User and System Mode R10
        r11        User and System Mode R11
        r12        User and System Mode R12
        r13        User and System Mode R13
        r14        User and System Mode R14
        pc         Pseudo Program Counter
        cpsr       Current Processor Status Register


Please note that the values of the cpsr and spsrs are shown as follows:

  Bit      31 30 29 28 27     26-25      24      15-10             8-0
            N  Z  C  V  Q  ICI/IT[7:6]   T    ICI/IT[5:0]    Exception Number[8:0]

                                              
The model also exports the clock cycle count for the debug purpose.
        ClkCount
which is correlated with Clock cycle count in tarmac.log file.

Other group of debug registers include:

  // FPU register bank and flags
           s0
           s1
           s2
           s3
           s4
           s5
           s6
           s7
           s8
           s9
           s10
           s11
           s12
           s13
           s14
           s15
           s16
           s17
           s18
           s19
           s20
           s21
           s22
           s23
           s24
           s25
           s26
           s27
           s28
           s29
           s30
           s31
           fpscr
   
  // SCS registers
          scs_actlr;
          scs_cpuid;
          scs_icsr;
          scs_vtor;
          scs_aircr;
          scs_scr;
          scs_ccr;
          scs_shpr1;
          scs_shpr2;
          scs_shpr3;
          scs_shcsr;
          scs_cfsr;
          scs_hfsr;
          scs_dfsr;
          scs_mmfar;
          scs_bfar;
          scs_afsr;
          scs_cpacr;
          scs_dhcsr;
          scs_dcrdr;
          scs_demcr;
          scs_fpccr;
          scs_fpcar;
          scs_fpdscr;

  // System Timer registers
          syst_csr;
          syst_rvr;
          syst_cvr;
          syst_calib;

  // NVIC registers
          nvic_ictr;
          nvic_iser0;
          nvic_iser1;
          nvic_iser2;
          nvic_iser3;
          nvic_iser4;
          nvic_iser5;
          nvic_iser6;
          nvic_iser7;
          nvic_icer0;
          nvic_icer1;
          nvic_icer2;
          nvic_icer3;
          nvic_icer4;
          nvic_icer5;
          nvic_icer6;
          nvic_icer7;
          nvic_ispr0;
          nvic_ispr1;
          nvic_ispr2;
          nvic_ispr3;
          nvic_ispr4;
          nvic_ispr5;
          nvic_ispr6;
          nvic_ispr7;
          nvic_icpr0;
          nvic_icpr1;
          nvic_icpr2;
          nvic_icpr3;
          nvic_icpr4;
          nvic_icpr5;
          nvic_icpr6;
          nvic_icpr7;
          nvic_iabr0;
          nvic_iabr1;
          nvic_iabr2;
          nvic_iabr3;
          nvic_iabr4;
          nvic_iabr5;
          nvic_iabr6;
          nvic_iabr7;
          nvic_ipr0;
          nvic_ipr1;
          nvic_ipr2;
          nvic_ipr3;
          nvic_ipr4;
          nvic_ipr5;
          nvic_ipr6;
          nvic_ipr7;
          nvic_ipr8;
          nvic_ipr9;
          nvic_ipr10;
          nvic_ipr11;
          nvic_ipr12;
          nvic_ipr13;
          nvic_ipr14;
          nvic_ipr15;
          nvic_ipr16;
          nvic_ipr17;
          nvic_ipr18;
          nvic_ipr19;
          nvic_ipr20;
          nvic_ipr21;
          nvic_ipr22;
          nvic_ipr23;
          nvic_ipr24;
          nvic_ipr25;
          nvic_ipr26;
          nvic_ipr27;
          nvic_ipr28;
          nvic_ipr29;
          nvic_ipr30;
          nvic_ipr31;
          nvic_ipr32;
          nvic_ipr33;
          nvic_ipr34;
          nvic_ipr35;
          nvic_ipr36;
          nvic_ipr37;
          nvic_ipr38;
          nvic_ipr39;
          nvic_ipr40;
          nvic_ipr41;
          nvic_ipr42;
          nvic_ipr43;
          nvic_ipr44;
          nvic_ipr45;
          nvic_ipr46;
          nvic_ipr47;
          nvic_ipr48;
          nvic_ipr49;
          nvic_ipr50;
          nvic_ipr51;
          nvic_ipr52;
          nvic_ipr53;
          nvic_ipr54;
          nvic_ipr55;
          nvic_ipr56;
          nvic_ipr57;
          nvic_ipr58;
          nvic_ipr59;

  // MPU registers
          mpu_ctrl;
          mpu_rnr;
          mpu_rbar;
          mpu_rasr;


===========================================
     ECS and TARMAC Tracing
===========================================
ECS - ETM Comparison Stream
TARMAC - Trace ARM Accesses

The ECS has extra information over the TARMAC trace to allow the ETM 
trace to be predicted for validation purposes.
The ECS does not support testing of the use of NIDEN to dynamically
enable the generation of trace.
The ECS generation assumes that TSVALUEB increments by 1 for every
core clock cycle.

The TARMAC trace is done via tarmac toplevel verilog modules.

This model supports the use of multiple trace output files, which 
name is controlled by means of the generic/defparam 'ID'.

For example if 'ID' is 3, the output of ECS trace is written to 
'log.ecs3' and the output of TARMAC trace is written to 'tarmac.log3'.
By default 'ID' is '0' and the output goes to 'log.ecs' or 'tarmac.log'.

To set the value of 'ID', follow the instructions given in the next 
paragraph :  'Memories Configurability  
              Multi Processor Designs'

1- Control of ECS tracing

   The ECS tracing, by default, is off.  
   To enable it, 
      setenv ecs_trace_on  "any string"
   To disable it,
      unsetenv ecs_trace_on

   Once the ECS tracing is on, the output is only written to a file.

2- Control of TARMAC tracing

   The TARMAC tracing, by default, is off.  
   To enable it, 
      setenv tarmac_trace_on  "any string"
   To disable it,
      unsetenv tarmac_trace_on

   Once the TARMAC tracing is on, by default, the output will be written 
   to a file.  However, it can be echo to stdout as well.
   To enable "echo to stdout"
      setenv tarmac_echo_to_stdout  "any string"
   To disable "echo to stdout"
      unsetenv tarmac_echo_to_stdout


Summary of ECS tracing
==============================

Default ECS tracing is :

ECS tracing OFF

Once it is on, ECS is logged in a file called "log.ecs"

To turn ON the ECS tracing set environment variable "ecs_trace_on"
setenv ecs_trace_on  "any string"
             
To change log file name define generic "ID" at point of instantiation of model.




Summary of TARMAC tracing
==============================

Default TARMAC tracing is :

TARMAC tracing OFF

Once it is on, TARMAC is logged in file called "tarmac.log"

NO echo to screen 

To turn ON the TARMAC tracing set environment variable "tarmac_trace_on"
   setenv tarmac_trace_on "any string"
             
To turn ON echo to stdout set environment variable "tarmac_echo_to_stdout"
   setenv tarmac_echo_to_stdout "any string"
 
To change log file name define generic "ID" at point of instantiation of model.

===========================================
     Configurability  
     Multi Processor Designs
===========================================

The CORTEXM4 DSM can be configured to match the rtl parameter configurations.
The following features can be configured for the CORTEXM4 DSM : 

        1- The device identifier, for multi processor designs. 
           Up to 8 CORTEXM4 DSMs can run concurrently in a single design
--------------------------------------------
        2- MPU present or not. MPU present or not. 1 is included, 0 is not 
           included.
--------------------------------------------
        3- Number of interrupts. Allowed range is 1 to 240.
--------------------------------------------
        4- Interrupt priority width. Allowed range is 3 to 8.
--------------------------------------------
        5- Trace support level.
             0 = No trace. No ITM or DWT triggers and counters.
             1 = Std trace. ITM and DWT triggers and counters.
             2 = Full trace. Standard trace (same as option 1 for CORTEXM4 level).
             3 = Full trace plus HTM port

           Note: This parameter does not affect watchpoints and must be 0 if
                 debug support level is 0.
--------------------------------------------
        6- Debug support level.
             0 = No debug. No DAP, break points, watchpoints, flash patch
                 or halting debug
             1 = Min debug. 2 break points, 1 watchpoint, no FP.
             2 = Full debug minus DWT data matching.
             3 = Full debug plus DWT data matching.

             Note: With debug support level = 1 there is only one comparator
                   implemented in the DWT and this therefore only allows one
                   watchpoint but also only one trigger for trace.
             Note: Halting debug includes halt, step, maskints, snapstall,
                   DbgTmp register & associated transfer logic and vector 
                   catch.
             Note: Debug support level < 3 removes the DATAVADDR0, DATAVADDR1, 
                   DATAVSIZE and DATAVMATCH registers which are present in the 
                   DWT Function Register 1 at address 0xE0001038.
--------------------------------------------
        7- Clock gate present. Architectural clock gating instantiated or not.
--------------------------------------------
        8- Reset all registers. Reset all registers if 1. Apply reset to all
           registers, even if not functionally required.
--------------------------------------------
        9- WIC present. WIC present or not. 1 is included, 0 is not included.
--------------------------------------------
        10- WIC lines. Number of available WIC lines. Allowed range
            is 3 to 243. If 3, WICMASKNMI, WICMASKMON and WICMASKRXEV 
            are driven. If more than 3, WICMASKISR is also driven.
--------------------------------------------
        11- BitBand present. Bit-banding present or not. 1 is included, 0 is 
            not included.
--------------------------------------------
        12- Constant AHB Control. Constant AHB control information during
            wait-stated transfers.
            Set to 1 to include the required logic, or 0 to exclude it.
--------------------------------------------
        13- FPU present. FPU present or not. 1 is included, 0 is not included.
--------------------------------------------

Note - The CLKGATE_PRESENT option is not included because including or not including
       architectural clock gating has no affect on the functionality of the device.

To configure the DSM, the user must modify the component instantiation 
of the CORTEXM4, by adding the lines of the required generic(s) Verilog 
'defparam' mappings.

For example, to configure the 5th processor of the design with:
    * no MPU,
    * 16 interrupts,
    * 3 bits of priority,
    * trace support level = 1,
    * debug support level = 3,
    * no architectural clock gating
    * not reset all registers,
    * no WIC,
    * 3 WIC sensitivity lines,
    * no Bit-banding,
    * no constant AHB control.
    * include FPU,

the user will add the following mappings if the CORTEXM4 model is instantiated as
theCORTEXM4 :

           defparam theCORTEXM4.MPU_PRESENT    = 0;
           defparam theCORTEXM4.NUM_IRQ        = 16;
           defparam theCORTEXM4.LVL_WIDTH      = 3;
           defparam theCORTEXM4.TRACE_LVL      = 1;
           defparam theCORTEXM4.DEBUG_LVL      = 3;
           defparam theCORTEXM4.CLKGATE_PRESENT= 1;
           defparam theCORTEXM4.RESET_ALL_REGS = 0;
           defparam theCORTEXM4.WIC_PRESENT    = 0;
           defparam theCORTEXM4.WIC_LINES      = 3;
           defparam theCORTEXM4.BB_PRESENT     = 0;
           defparam theCORTEXM4.CONST_AHB_CTRL = 0;
           defparam theCORTEXM4.FPU_PRESENT    = 1;
           defparam theCORTEXM4.ID             = 5;

           // COMPONENT INSTANTIATION
           CORTEXM4 theCORTEXM4 (PORESETn, ... etc ... )
             

             NOTE THAT : 
    ===============================

1- To set one generic parameter, and leave the others as their default values, 
   the user just needs to add the line of this particular parameter, and not 
   to bother about the others. 

2- Default values :
   - the device identifier is 0
--------------------------------------------
   Default parameter set up is full compliment:
    MPU not included                      - MPU_PRESENT     = 0
    16 interrupts                         - NUM_IRQ         = 16
    3 bits priority width                 - LVL_WIDTH       = 3
    Standard trace support                - TRACE_LVL       = 1
    Full debug - including data matching  - DEBUG_LVL       = 3
    No architectural clock gating         - CLKGATE_PRESENT = 0
    All registers are not reset           - RESET_ALL_REGS  = 0
    WIC not included                      - WIC_PRESENT     = 0
    WIC has 3 sensitivity lines           - WIC_LINES       = 3
    Bit-banding included                  - BB_PRESENT      = 1
    NO Constant AHB control               - CONST_AHB_CTRL  = 0
    FPU not included                      - FPU_PRESETMT    = 0


3- The values must be integers.
--------------------------------------------
   
4- The 'model identifier' (generic/defparam 'dsm_ID') is an integer from 0 to 7.
   This identifier allows the software to distinguish different instantiations
   of the same model in a single design. 

5- If the user uses defparams then CORTEXM4 should not be instantiated using parameter
   passing in parallel otherwise a conflict may occur.

==========================================================
Generic/parameters used in the HDL wrapper
==========================================================

  o MG_LOGFILE_NAME.  This generic is used to specify the name of the file to
    log pin activity of the model.  The MG_MODEL_LOG environment variable must
    be set to 'yes' to enable log generation

  o MG_FORCED_DELAY. Obsolete as it is for built-in timing shell.

  o MG_OBJECT. This generic contains the directory path used by the Model Manager 
    to find the shared object (.so or .sl) file for the model.  By default it
    is the value of the DIR_<device> environment variable.

  o MG_OMI_PATH. This generic is only used in the OMI based model. It is a
    colon-separated list of directory paths used by the Model Manager to find
    the bootstrap file for OMI dropins used in this model. 

  o MG_MSG_TIME.  When this is set to 1, the simulation time is printed with
    all messages coming from this instance of the model.  When set to -1, it
    is never printed.  When set to 0 (the default), this generic has no 
    effect (so whether or not the time is printed is determined by the dropin
    source or SWIFT/OMI runtime library, as with ModelGen);

  o MG_MSG_INSTANCE.  When this is set to 1, the path to this instance of the
    model is printed with all messages coming from this instance.  When set 
    to -1, it is never printed.  When set to 0 (the default), this generic
    has no effect (so whether or not the path is printed is determined by the
    dropin source or SWIFT/OMI runtime library, as with ModelGen);

  o MG_MSG_SEVERITY.  This can be set to "NOSEVERITY", "WARNING",
    "INFORMATIONAL", "FATAL" or "ERROR" (or any abbreviation of these), in
    which case all messages produced by this instance of the model will take
    that severity level.  If set to the empty string (or anything else), this
    generic has no effect;

  o MG_MSG_SUPPRESS.  This can be set to "NOSEVERITY", "WARNING",
    "INFORMATIONAL", "FATAL" or "ERROR" (or any abbreviation of these), in
    which case any message produced by this instance of the model which has
    a severity of less than or equal to this will be suppressed.  If set to
    the empty string (or anything else), this generic has no effect.

  o MG_MSG_V4_FORMAT.  For backward compatibility, the ModelGen message format 
    can be re-enabled by setting the MG_MSG_V4_FORMAT generic to 1; this 
    capability may be removed in a future release;

  A few things should be noted here:

  - The above MG_MSG_* generics do not affect the messages produced by timing 
    shells.  These messages can be controlled using other generics/parameters 
    at the timing shell level;

  - Messages originating from SWIFT or OMI dropins often do not supply their
    severity information to the Model Manager.  So even though they may 
    contain words such as "WARNING" or "ERROR".  Such messages will be
    treated as "INFORMATIONAL" or "NOSEVERITY" messages as far as
    MG_MSG_SUPPRESS is concerned;

  - MG_MSG_TIME affects timestamps in message headers, not the (bogus)
    timestamps which may appear within the body of messages originating from
    SWIFT or OMI dropins.
