# US 2024/0201965 A1 · Method for generating source code

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0201965 A1
- Document ID: US20240201965A1
- Status: Published application
- Kind: A1
- Application number: 18/067,738
- Filed: 2022-12-19
- Published: 2024-06-20
- Earliest claimed: 2022-12-19
- Assignees: dSPACE GmbH
- Applicants: dSPACE GmbH
- Inventors: Michael MAIR; Florian GAYK
- Web page: https://patentgrep.com/patent/US20240201965A1

## CPC

- G06F 8/40: Transformation of program code
- G06F 8/30: Creation or generation of source code
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A block diagram includes at least three blocks, including a source block emitting a first composite signal, a passing block receiving the first composite signal and emitting a second composite signal with the same dimensions, and a filter block receiving the second composite signal and discarding at least one component of the second composite signal. A method for generating source code from one or more blocks of the block diagram includes: transforming the block diagram into an intermediate representation, including transforming the at least three blocks; applying at least one optimization to the intermediate representation, including determining whether a memory condition is fulfilled; based on the memory condition being fulfilled, replacing an output variable of the passing block with an auxiliary variable of smaller dimension; and translating the optimized intermediate representation into source code.

## Claims

### Claim 1

A method for generating source code from one or more blocks of a block diagram that comprises at least three blocks, wherein the at least three blocks include a source block emitting a first composite signal corresponding to a multi-component variable, a passing block receiving the first composite signal and emitting a second composite signal with the same dimensions, and a filter block receiving the second composite signal and discarding at least one component of the second composite signal, the method comprising:
transforming the block diagram into an intermediate representation, wherein transforming the block diagram into the intermediate representation comprises transforming the at least three blocks;
applying at least one optimization to the intermediate representation, wherein applying the at least one optimization comprises determining whether a memory condition is fulfilled;
based on the memory condition being fulfilled, replacing an output variable of the passing block with one or more auxiliary variables of smaller dimension; and
translating the optimized intermediate representation into source code.

### Claim 2 (depends on 1)

The method of claim 1, wherein the first composite signal is a bus.

### Claim 3 (depends on 1)

The method of claim 1, wherein the multi-component variable is a structure comprising multiple components of different data types.

### Claim 4 (depends on 1)

The method of claim 1, wherein the multi-component variable is a vector comprising multiple components of the same data type.

### Claim 5 (depends on 1)

The method of claim 1, wherein the passing block is a selection block receiving the first composite signal and a third composite signal of the same dimension, wherein the selection block transmits either the first composite signal or the third composite signal.

### Claim 6 (depends on 1)

The method of claim 1, wherein the passing block is a calculation block that performs elementwise calculation on the first composite signal

### Claim 7 (depends on 1)

The method of claim 1, wherein the passing block is a delay block that emits received signals after one or more periods.

### Claim 8 (depends on 1)

The method of claim 1, wherein the memory condition is fulfilled based on the at least one component discarded in the filter block being of bigger dimension than a predefined threshold.

### Claim 9 (depends on 1)

The method of claim 1, wherein the memory condition is fulfilled based on the dimension of the remaining components emitted by the filter block being lower than a predefined threshold.

### Claim 10 (depends on 1)

The method of claim 1, wherein applying the at least one optimization further comprises replacing the output variable of at least one block directly upstream of the passing block with one or more auxiliary variables of smaller dimension based on the memory condition being fulfilled.

### Claim 11 (depends on 1)

The method of claim 1, further comprising:
compiling the source code for at least one arithmetic logic unit of a control unit to generate an executable code;
transmitting the executable code to the control unit; and
storing the executable code on a non-volatile memory of the control unit and/or executing the executable code by the at least one arithmetic logic unit of the control unit.

### Claim 12

A method for generating source code from one or more blocks of a block diagram that comprises at least three blocks, wherein the at least three blocks include a source block emitting a first composite signal corresponding to a multi-component variable, a passing block receiving the first composite signal and emitting a second composite signal with the same dimensions, and a filter block receiving the second composite signal and discarding at least one component of the second composite signal, the method comprising:
transforming the block diagram into an intermediate representation, wherein transforming the block diagram into the intermediate representation comprises transforming the at least three blocks;
applying at least one optimization to the intermediate representation, wherein applying the at least one optimization comprises determining whether a memory condition is fulfilled;
based on the memory condition not being fulfilled, determining whether a cost condition is fulfilled; and
based on the cost condition being fulfilled, replacing an assignment of the entire multi-component variable by a partial assignment pertaining to one or more components of the multi-component variable.

### Claim 13 (depends on 12)

The method of claim 12, wherein the cost condition is fulfilled if the execution time for the partial assignment is lower than a predefined threshold.

### Claim 14 (depends on 12)

The method of claim 12, wherein replacing an assignment of the entire multi-component variable by a partial assignment pertaining to one or more components of the multi-component variable further comprises replacing an assignment of the entire multi-component variable by a partial assignment pertaining to one or more components of the multi-component variable of at least one block directly upstream of the passing block.

### Claim 15

A non-transitory computer-readable medium having processor-executable instructions stored thereon for generating source code from one or more blocks of a block diagram that comprises at least three blocks, wherein the at least three blocks include a source block emitting a first composite signal corresponding to a multi-component variable, a passing block receiving the first composite signal and emitting a second composite signal with the same dimensions, and a filter block receiving the second composite signal and discarding at least one component of the second composite signal, wherein the processor-executable instructions, when executed, facilitate:
transforming the block diagram into an intermediate representation, wherein transforming the block diagram into the intermediate representation comprises transforming the at least three blocks;
applying at least one optimization to the intermediate representation, wherein applying the at least one optimization comprises determining whether a memory condition is fulfilled;
based on the memory condition being fulfilled, replacing an output variable of the passing block with one or more auxiliary variables of smaller dimension; and
translating the optimized intermediate representation into source code.
