For models containing read and write operations for Data Store Memory blocks, you can generate code that contains a single variable to hold the value for each Data Store Read and Write operation. Generating one variable for each operation improves data access coherency.
The data_store_latching
model contains a single Data Store Memory block
that is accessed by two different Data Store Memory Read and two Data Store Memory Write
blocks. Two Sum blocks perform addition on the input generated by the Data Store Read
blocks and output the data to the Data Store Write blocks .
Building the model with the Implement each data store block as a unique access point parameter turned off by default, generates this code:
void data_store_latching_step(void) { /* DataStoreWrite: '<Root>/Data Store Write' incorporates: * DataStoreRead: '<Root>/Data Store Read' * Sum: '<Root>/Add' */ data_store_latching_DW.A += data_store_latching_DW.A + data_store_latching_DW.A; /* DataStoreWrite: '<Root>/Data Store Write1' incorporates: * DataStoreRead: '<Root>/Data Store Read1' * Sum: '<Root>/Add1' */ data_store_latching_DW.A += data_store_latching_DW.A + data_store_latching_DW.A; }
data_store_latching_DW.A
. In the Configuration Parameters dialog box, on the Interface pane, select the Implement each data store block as a unique access point parameter. Click Apply.
The generated code is now:
void data_store_latching_step(void) { real_T rtb_DataStoreRead; real_T rtb_DataStoreRead1; /* DataStoreRead: '<Root>/Data Store Read' */ rtb_DataStoreRead = data_store_latching_DW.A; /* DataStoreWrite: '<Root>/Data Store Write' incorporates: * Sum: '<Root>/Add' */ data_store_latching_DW.A = (rtb_DataStoreRead + rtb_DataStoreRead) + rtb_DataStoreRead; /* DataStoreRead: '<Root>/Data Store Read1' */ rtb_DataStoreRead1 = data_store_latching_DW.A; /* DataStoreWrite: '<Root>/Data Store Write1' incorporates: * Sum: '<Root>/Add1' */ data_store_latching_DW.A = (rtb_DataStoreRead1 + rtb_DataStoreRead1) + rtb_DataStoreRead1; }
rtb_DataStoreRead
and rtb_DataStoreRead1
.
These separate variables improve data access coherency.