finished initial support for ROM
diff --git a/src/packages/xdc/runtime/Diags__prologue.h b/src/packages/xdc/runtime/Diags__prologue.h
index f199273..6ec6c16 100644
--- a/src/packages/xdc/runtime/Diags__prologue.h
+++ b/src/packages/xdc/runtime/Diags__prologue.h
@@ -1,6 +1,6 @@
 /* --COPYRIGHT--,ESD
- *  Copyright (c) 2008 Texas Instruments. All rights reserved. 
- *  This program and the accompanying materials are made available under the 
+ *  Copyright (c) 2008-2016 Texas Instruments. All rights reserved.
+ *  This program and the accompanying materials are made available under the
  *  terms of the Eclipse Public License v1.0 and Eclipse Distribution License
  *  v. 1.0 which accompanies this distribution. The Eclipse Public License is
  *  available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
@@ -22,7 +22,7 @@
  */
 #include <xdc/runtime/Main.h>
 
-/* 
+/*
  * Only define these symbols for xdc.runtime.Main if this file is not one that
  * will be included in the Registry. This check ensures that Registry.h (which
  * similarly defines these Module__* symbols) can be included in any order
@@ -35,34 +35,50 @@
  *  The set of diags categories that are runtime controllable _or_ always on
  *
  *  This costant is computed at config time and enables us to eliminate
- *  expensive runtime time checks and unnecessary data (the module's diags 
+ *  expensive runtime time checks and unnecessary data (the module's diags
  *  mask) when whole program optimization is used.
  */
 #undef Module__DGSINCL
+#ifdef xdc_runtime_Main_Module__diagsIncluded__CR
+#define Module__DGSINCL (*((CT__xdc_runtime_Main_Module__diagsIncluded*)(xdcRomConstPtr + xdc_runtime_Main_Module__diagsIncluded__R_offset)))
+#else
 #define Module__DGSINCL xdc_runtime_Main_Module__diagsIncluded__C
+#endif
 
 /*
  *  ======== Module__DGSENAB ========
  *  The set of diags categories that are _always_ enabled
  *
  *  This costant is computed at config time and enables us to eliminate
- *  expensive runtime time checks and unnecessary data (the module's diags 
+ *  expensive runtime time checks and unnecessary data (the module's diags
  *  mask) when whole program optimization is used.
  */
 #undef Module__DGSENAB
+#ifdef xdc_runtime_Main_Module__diagsEnabled__CR
+#define Module__DGSENAB (*((CT__xdc_runtime_Main_Module__diagsEnabled*)(xdcRomConstPtr + xdc_runtime_Main_Module__diagsEnabled__R_offset)))
+#else
 #define Module__DGSENAB xdc_runtime_Main_Module__diagsEnabled__C
+#endif
 
 /*
  *  ======== Module__DGSMASK ========
- *  Pointer to the set of diags categories that are runtime controllable 
+ *  Pointer to the set of diags categories that are runtime controllable
  */
 #undef Module__DGSMASK
+#ifdef xdc_runtime_Main_Module__diagsMask__CR
+#define Module__DGSMASK (*((CT__xdc_runtime_Main_Module__diagsMask*)(xdcRomConstPtr + xdc_runtime_Main_Module__diagsMask__R_offset)))
+#else
 #define Module__DGSMASK xdc_runtime_Main_Module__diagsMask__C
+#endif
 
 /*
  *  ======== Module__MID ========
  */
 #undef Module__MID
+#ifdef xdc_runtime_Main_Module__id__CR
+#define Module__MID (*((CT__xdc_runtime_Main_Module__id*)(xdcRomConstPtr + xdc_runtime_Main_Module__id__R_offset)))
+#else
 #define Module__MID xdc_runtime_Main_Module__id__C
+#endif
 
 #endif
diff --git a/src/packages/xdc/services/intern/gen/Config.java b/src/packages/xdc/services/intern/gen/Config.java
index 239b75c..d92bfcf 100644
--- a/src/packages/xdc/services/intern/gen/Config.java
+++ b/src/packages/xdc/services/intern/gen/Config.java
@@ -1593,9 +1593,15 @@
         fm.switchMod(mod);
         glob.genTitleD(ds);
         if (fm.switchMod(mod) == FileManager.SEPARATE_FILE) {
+            /* ROM check */
+            glob.out.printf("#ifndef %1%2R\n", cname, ds);
             glob.out.printf(
-                "extern __FAR__ const xdc_runtime_Core_ObjDesc %1%2;\n", cname, 
+                "extern __FAR__ const xdc_runtime_Core_ObjDesc %1%2;\n", cname,
                 ds);
+            glob.out.printf("#else\n");
+            glob.out.printf("#define %1%2 (*((xdc_runtime_Core_ObjDesc*)"
+                + "(xdcRomConstPtr + %1%2_offset)))\n", cname, ds);
+            glob.out.printf("#endif\n");
         }
         else {
             glob.out.printf("__FAR__ const xdc_runtime_Core_ObjDesc %1%2;\n",
@@ -1807,8 +1813,15 @@
              */ 
             if (fm.switchMod(mod) == FileManager.SEPARATE_FILE) {
                 glob.genTitleD(ps);
-                glob.out.printf("extern __FAR__ const %1Params %1%2;",
+                /* ROM check */
+                glob.out.printf("#ifndef %1%2R\n", cname, ps);
+                glob.out.printf("extern __FAR__ const %1Params %1%2;\n",
                     cname, ps);
+                glob.out.printf("#else\n");
+                glob.out.printf("#define %1%2 (*((%1Params*)"
+                    + "(xdcRomConstPtr + %1%2_offset)))\n",
+                    cname, ps);
+                glob.out.printf("#endif\n");
             }
             fm.switchCommon();
 
@@ -2080,14 +2093,23 @@
             ArrayList<String> configTypes = new ArrayList();
             for (Decl.Config cfg : unit.getConfigs()) {
                 if (cfg.isInst() || cfg.isMeta()
-                    || mod.get(cfg.getName(), mod) == 
+                    || mod.get(cfg.getName(), mod) ==
                     xdc.services.intern.xsr.Value.NOGEN) {
                     continue;
                 }
 
+                String cn = glob.cname + cfg.getName();
+                /* consts that end up in the big structure for ROM can't be
+                 * declared extern because they are not separate variables
+                 * anymore.
+                 */
+                if (romConstFields.containsKey(cn + "__C")) {
+                    continue;
+                }
+
                 configQuals.add("const");
-                configTypes.add("CT__" + glob.cname + cfg.getName());
-                configNames.add(glob.cname + cfg.getName() + "__C");
+                configTypes.add("CT__" + cn);
+                configNames.add(cn + "__C");
             }
             Context cx = Global.getContext();
             Scriptable gscope = Global.getTopScope();
@@ -2485,6 +2507,9 @@
 
     /*
      *  ======== genRomStruct ========
+     *
+     *  Generates two structure that contain all constants referenced by ROM,
+     *  and all module states referenced by ROM.
      */
     private void genRomStruct()
     {
@@ -2492,7 +2517,7 @@
         glob.out.printf("typedef struct {\n%+");
         for (String cnst: romConstFields.keySet()) {
             glob.out.printf("%t%1 %2;\n", romConstFields.get(cnst).get(0),
-                cnst);
+                cnst.replaceFirst("__C$", "__R"));
         }
         glob.out.printf("} CT__constStruct;%-\n\n");
 
@@ -2505,12 +2530,19 @@
         glob.out.printf("%-} TROM__stateStruct;\n\n");
 
         for (String cnst: romConstFields.keySet()) {
-            //glob.out.printf("const xdc_SizeT %1_offset = "
-            //    + "offsetof(CT__constStruct, %1);\n", cnst);
+            glob.out.printf("const xdc_SizeT %1_offset = "
+                + "offsetof(CT__constStruct, %2);\n", cnst,
+                cnst.replaceFirst("__C$", "__R"));
+        }
+
+        for (String state: romModStates.keySet()) {
+            glob.out.printf("const xdc_SizeT %1_offset = "
+                + "offsetof(TROM__stateStruct, %1);\n", state);
         }
 
         for (String cnst: romConstFields.keySet()) {
-            glob.out.printf("#define %1 (ROM_constStruct.%1)\n", cnst);
+            glob.out.printf("#define %1 (ROM_constStruct.%2)\n", cnst,
+                cnst.replaceFirst("__C$", "__R"));
         }
         for (String state: romModStates.keySet()) {
             glob.out.printf("#define %1 (ROM_stateStruct.%1)\n", state);
@@ -2525,7 +2557,8 @@
             Pattern pat = Pattern.compile("^",Pattern.MULTILINE);
             Matcher m = pat.matcher(value);
             value = m.replaceAll("    ");
-            glob.out.printf("%1, /* %2 */\n", value, cnst);
+            glob.out.printf("%1, /* %2 */\n", value,
+                cnst.replaceFirst("__C$", "__R"));
         }
         glob.out.printf("};\n");
 
@@ -2541,13 +2574,31 @@
         }
         glob.out.printf("%-};\n");
 
-        glob.genTitleD("ROM_constPtr");
-        glob.out.printf("const CT__constStruct * const ROM_constPtr"
-            + " = &ROM_constStruct;\n");
+        glob.genTitleD("xdcRomConstPtr");
+        glob.out.printf("#ifdef __ti__sect\n");
+        glob.out.printf("#pragma DATA_SECTION(xdcRomConstPtr,"
+            + " \".const:xdcRomConstPtr\");\n");
+        glob.out.printf("#endif\n");
+        glob.out.printf("#ifdef __GNUC__\n");
+        glob.out.printf("#ifndef __TI_COMPILER_VERSION__\n");
+        glob.out.printf("const xdc_UInt8 * const xdcRomConstPtr __attribute__"
+            + " ((section(\".rodata_xdcRomConstPtr\")));\n");
+        glob.out.printf("#endif\n#endif\n");
+        glob.out.printf("const xdc_UInt8 * const xdcRomConstPtr"
+            + " = (xdc_UInt8 *)&ROM_constStruct;\n");
 
-        glob.genTitleD("ROM_statePtr");
-        glob.out.printf("TROM__stateStruct * const ROM_statePtr"
-            + " = &ROM_stateStruct;\n");
+        glob.genTitleD("xdcRomStatePtr");
+        glob.out.printf("#ifdef __ti__sect\n");
+        glob.out.printf("#pragma DATA_SECTION(xdcRomStatePtr,"
+            + " \".const:xdcRomStatePtr\");\n");
+        glob.out.printf("#endif\n");
+        glob.out.printf("#ifdef __GNUC__\n");
+        glob.out.printf("#ifndef __TI_COMPILER_VERSION__\n");
+        glob.out.printf("xdc_UInt8 * const xdcRomStatePtr __attribute__"
+            + " ((section(\".rodata_xdcRomStatePtr\")));\n");
+        glob.out.printf("#endif\n#endif\n");
+        glob.out.printf("xdc_UInt8 * const xdcRomStatePtr"
+            + " = (xdc_UInt8 *)&ROM_stateStruct;\n");
 
     }
 
diff --git a/src/packages/xdc/services/intern/gen/Glob.java b/src/packages/xdc/services/intern/gen/Glob.java
index a24991b..89badad 100644
--- a/src/packages/xdc/services/intern/gen/Glob.java
+++ b/src/packages/xdc/services/intern/gen/Glob.java
@@ -847,47 +847,138 @@
         this.genTitleD("per-module runtime symbols");
 
         this.out.printf("#undef Module__MID\n");
+        this.out.printf("#ifdef %1Module__id__CR\n", this.cname);
+        this.out.printf("#define Module__MID (*((CT__%1Module__id *)"
+            + "(xdcRomConstPtr + %1Module__id__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
         this.out.printf("#define Module__MID %1Module__id__C\n", this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__DGSINCL\n");
-        this.out.printf("#define Module__DGSINCL %1Module__diagsIncluded__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__diagsIncluded__CR\n", this.cname);
+        this.out.printf("#define Module__DGSINCL "
+            + "(*((CT__%1Module__diagsIncluded *)(xdcRomConstPtr +"
+            + " %1Module__diagsIncluded__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__DGSINCL %1Module__diagsIncluded__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__DGSENAB\n");
-        this.out.printf("#define Module__DGSENAB %1Module__diagsEnabled__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__diagsEnabled__CR\n", this.cname);
+        this.out.printf("#define Module__DGSENAB "
+            + "(*((CT__%1Module__diagsEnabled *)(xdcRomConstPtr +"
+            + " %1Module__diagsEnabled__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__DGSENAB %1Module__diagsEnabled__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__DGSMASK\n");
-        this.out.printf("#define Module__DGSMASK %1Module__diagsMask__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__diagsMask__CR\n", this.cname);
+        this.out.printf("#define Module__DGSMASK (*((CT__%1Module__diagsMask *)"
+            + "(xdcRomConstPtr + %1Module__diagsMask__C_offset)))\n",
+            this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__DGSMASK %1Module__diagsMask__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__LOGDEF\n");
-        this.out.printf("#define Module__LOGDEF %1Module__loggerDefined__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__loggerDefined__CR\n", this.cname);
+        this.out.printf("#define Module__LOGDEF "
+            + "(*((CT__%1Module__loggerDefined *)(xdcRomConstPtr +"
+            + " %1Module__loggerDefined__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGDEF %1Module__loggerDefined__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__LOGOBJ\n");
-        this.out.printf("#define Module__LOGOBJ %1Module__loggerObj__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__loggerObj__CR\n", this.cname);
+        this.out.printf("#define Module__LOGOBJ %1Module__loggerObj__R\n",
+            this.cname);
+        this.out.printf("#define Module__LOGOBJ (*((CT__%1Module__loggerObj *)"
+            + "(xdcRomConstPtr + %1Module__loggerObj__C_offset)))\n", 
+            this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGOBJ %1Module__loggerObj__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__LOGFXN0\n");
-        this.out.printf("#define Module__LOGFXN0 %1Module__loggerFxn0__C\n", this.cname);
-        
+        this.out.printf("#ifdef %1Module__loggerFxn0__CR\n", this.cname);
+        this.out.printf("#define Module__LOGFXN0 "
+            + "(*((CT__%1Module__loggerFxn0 *)(xdcRomConstPtr +"
+            + " %1Module__loggerFxn0__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGFXN0 %1Module__loggerFxn0__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
+
         this.out.printf("#undef Module__LOGFXN1\n");
-        this.out.printf("#define Module__LOGFXN1 %1Module__loggerFxn1__C\n", this.cname);
-        
+        this.out.printf("#ifdef %1Module__loggerFxn1__CR\n", this.cname);
+        this.out.printf("#define Module__LOGFXN1 "
+            + "(*((CT__%1Module__loggerFxn1 *)(xdcRomConstPtr +"
+            + " %1Module__loggerFxn1__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGFXN1 %1Module__loggerFxn1__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
+
         this.out.printf("#undef Module__LOGFXN2\n");
-        this.out.printf("#define Module__LOGFXN2 %1Module__loggerFxn2__C\n", this.cname);
-        
+        this.out.printf("#ifdef %1Module__loggerFxn2__CR\n", this.cname);
+        this.out.printf("#define Module__LOGFXN2 "
+            + "(*((CT__%1Module__loggerFxn2 *)(xdcRomConstPtr +"
+            + " %1Module__loggerFxn2__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGFXN2 %1Module__loggerFxn2__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
+
         this.out.printf("#undef Module__LOGFXN4\n");
-        this.out.printf("#define Module__LOGFXN4 %1Module__loggerFxn4__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__loggerFxn4__CR\n", this.cname);
+        this.out.printf("#define Module__LOGFXN4 "
+            + "(*((CT__%1Module__loggerFxn4 *)(xdcRomConstPtr +"
+            + " %1Module__loggerFxn4__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGFXN4 %1Module__loggerFxn4__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__LOGFXN8\n");
-        this.out.printf("#define Module__LOGFXN8 %1Module__loggerFxn8__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__loggerFxn8__CR\n", this.cname);
+        this.out.printf("#define Module__LOGFXN8 "
+            + "(*((CT__%1Module__loggerFxn8 *)(xdcRomConstPtr +"
+            + " %1Module__loggerFxn8__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__LOGFXN8 %1Module__loggerFxn8__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__G_OBJ\n");
-        this.out.printf("#define Module__G_OBJ %1Module__gateObj__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__gateObj__CR\n", this.cname);
+        this.out.printf("#define Module__G_OBJ (*((CT__%1Module__gateObj *)"
+            + "(xdcRomConstPtr + %1Module__gateObj__C_offset)))\n", this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__G_OBJ %1Module__gateObj__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         this.out.printf("#undef Module__G_PRMS\n");
-        this.out.printf("#define Module__G_PRMS %1Module__gatePrms__C\n", this.cname);
+        this.out.printf("#ifdef %1Module__gatePrms__CR\n", this.cname);
+        this.out.printf("#define Module__G_PRMS (*((CT__%1Module__gatePrms *)"
+            + "(xdcRomConstPtr + %1Module__gatePrms__C_offset)))\n", 
+            this.cname);
+        this.out.printf("#else\n");
+        this.out.printf("#define Module__G_PRMS %1Module__gatePrms__C\n",
+            this.cname);
+        this.out.printf("#endif\n\n");
 
         for (String fxn : GATEFXNS) {
             this.out.printf("#undef Module__GP_%1\n", fxn);
-            this.out.printf("#define Module__GP_%2 %1Module_GateProxy_%2\n", this.cname, fxn);
+            this.out.printf("#define Module__GP_%2 %1Module_GateProxy_%2\n",
+                this.cname, fxn);
         }
     }
 
diff --git a/src/packages/xdc/services/intern/gen/Header.java b/src/packages/xdc/services/intern/gen/Header.java
index d825a6f..6824939 100644
--- a/src/packages/xdc/services/intern/gen/Header.java
+++ b/src/packages/xdc/services/intern/gen/Header.java
@@ -886,11 +886,15 @@
         glob.out.printf("%-%t};\n");
 
         if (unit.isMod()) {
+            /* ROM check */
             glob.out.printf("#ifndef %1Module__FXNS__CR\n", glob.cname);
             glob.genTitleD("Module__FXNS__C");
             glob.out.printf("%t__extern const %1Fxns__ %1Module__FXNS__C;\n",
                 glob.cname);
             glob.out.printf("#else\n");
+            /* There is no cast here for the ROM use case because this value
+             * is always used with an added cast.
+             */
             glob.out.printf("%t#define %1Module__FXNS__C "
                 + "(*(xdcRomConstPtr + %1Module__FXNS__C_offset))\n",
                 glob.cname);
@@ -898,6 +902,7 @@
         }
         else {
             String bs = "xdc_runtime_Types_Base";
+            /* ROM check */
             glob.out.printf("#ifndef %1Module__BASE__CR\n", glob.cname);
             glob.genTitleD("Interface__BASE__C");
             glob.out.printf("%t__extern const %2 %1Interface__BASE__C;\n",
@@ -1063,7 +1068,7 @@
                     cfg.getName());
                 /* We expand non-system configs to a member of a structure
                  * without going through an intermediate step of expanding to
-                 * __C and then to a member of a structure because these 
+                 * __C and then to a member of a structure because these
                  * configs are used by user's code. System configs are used
                  * internally and are always referred to with __C names.
                  */
@@ -1130,7 +1135,16 @@
             glob.genStateFlds(unit, false, false, true);
             glob.out.printf("%-};\n");
             glob.genTitleD("Module__state__V");
-            glob.out.printf("extern struct %1Module_State__ %1Module__state__V;\n", glob.cname);
+            /* ROM check */
+            glob.out.printf("#ifndef %1Module__state__VR\n", glob.cname);
+            glob.out.printf("extern struct %1Module_State__ %1Module__state__V;"
+                + "\n", glob.cname);
+            glob.out.printf("#else\n");
+            glob.out.printf(
+                "#define %1Module__state__V (*((struct %1Module_State__*)"
+                + "(xdcRomStatePtr + %1Module__state__V_offset)))\n",
+                glob.cname);
+            glob.out.printf("#endif\n");
         }
 
         if (unit.isInst()) {
@@ -1151,8 +1165,12 @@
             String base = mflg ? ("&" + glob.cname + "Module__state__V") :
                 "obj";
             glob.genTitleD(sn + '_' + fld.getName());
-            glob.out.printf("#ifndef %1on__OR\n", on);
+            /* ROM check */
+            glob.out.printf("#ifndef %1__OR\n", on);
             glob.out.printf("__extern __FAR__ const xdc_SizeT %1__O;\n", on);
+            glob.out.printf("#else\n");
+            glob.out.printf("#define %1__O (*((xdc_SizeT*)"
+                + "(xdcRomConstPtr + %1__O_offset)))\n", on);
             glob.out.printf("#endif\n");
             glob.out.printf("static inline %1 %2(%3)\n{\n%+", ot, on, a0);
             glob.out.printf("%treturn (%1)(((char*)%2) + %3__O);\n}\n%-", ot,
diff --git a/src/packages/xdc/services/intern/gen/Internal.java b/src/packages/xdc/services/intern/gen/Internal.java
index ebcec08..eabe544 100644
--- a/src/packages/xdc/services/intern/gen/Internal.java
+++ b/src/packages/xdc/services/intern/gen/Internal.java
@@ -14,7 +14,10 @@
 import xdc.services.global.*;
 import java.io.*;
 import java.util.*;
-import xdc.services.spec.*;
+
+import xdc.services.spec.Unit;
+import xdc.services.spec.Decl;
+import xdc.services.spec.Attr;
 
 public class Internal
 {
@@ -74,7 +77,7 @@
                                 fxn.getName(), fn);
             }
 
-            String[] fns = {"Module_startup", "Instance_init", 
+            String[] fns = {"Module_startup", "Instance_init",
                 "Instance_finalize"};
 
             for (String fn : fns) {
@@ -85,10 +88,24 @@
 
             if (unit.getSession().findDecl(unit, "Module_State") != null) {
                 glob.genTitleD("module");
-                glob.out.printf("#define %1_module ((%2Module_State *)(xdc__MODOBJADDR__(%2Module__state__V)))\n", unit.getName(), glob.cname);
-                glob.out.printf("#if !defined(__cplusplus) || !defined(%1_cplusplus)\n", glob.cname);
-                glob.out.printf("#define module ((%1Module_State *)(xdc__MODOBJADDR__(%1Module__state__V)))\n", glob.cname);
-                glob.out.printf("#endif");
+                /* ROM check */
+                glob.out.printf("#ifdef %1Module__state__VR\n", glob.cname);
+                glob.out.printf("#define %1_module ((%2Module_State *)"
+                    + "(xdcRomStatePtr + %2Module__state__V_offset))\n",
+                    unit.getName(), glob.cname);
+                glob.out.printf("#define module ((%1Module_State *)"
+                    + "(xdcRomStatePtr + %1Module__state__V_offset))\n",
+                    glob.cname);
+                glob.out.printf("#else\n");
+                glob.out.printf("#define %1_module ((%2Module_State *)"
+                    + "(xdc__MODOBJADDR__(%2Module__state__V)))\n",
+                    unit.getName(), glob.cname);
+                glob.out.printf("#if !defined(__cplusplus) ||"
+                    + "!defined(%1_cplusplus)\n", glob.cname);
+                glob.out.printf("#define module ((%1Module_State *)"
+                    + "(xdc__MODOBJADDR__(%1Module__state__V)))\n", glob.cname);
+                glob.out.printf("#endif\n");
+                glob.out.printf("#endif\n");
             }
 
             glob.genModuleDefines();