Skip to content

C/C++ conversion #12

@vitaly-castLabs

Description

@vitaly-castLabs

I wonder if someone managed to convert the code to C/C++ with Matlab's codegen or something else? Matrices changing sizes, recursion and globals like bits, bits_updated, etc are an absolute PITA - I beg everyone who reads this, please avoid Matlab like a plague.

Here's what I've got so far:

cfg = coder.config('lib');
cfg.EnableVariableSizing = true;
cfg.DynamicMemoryAllocation = 'AllVariableSizeArrays';
cfg.DynamicMemoryAllocationForFixedSizeArrays = true;
cfg.InlineThreshold = 0;
cfg.EnableVariableSizing = true;
cfg.DynamicMemoryAllocationForFixedSizeArrays = true;
cfg.CompileTimeRecursionLimit = 500;

codegen -lang:c++ -config cfg test_ecc -globals {'bits', coder.typeof(0, [Inf, Inf, Inf], [1, 1, 1]), 'bits_updated', coder.typeof(logical(0), [Inf, Inf], [1, 1]), 'llrs', coder.typeof(0, [Inf, Inf, Inf], [1, 1, 1]), 'llrs_updated', coder.typeof(logical(0), [Inf, Inf], [1, 1])} -report -package pkg
Warning: The 'DynamicMemoryAllocation' option will be removed in a future release. Use 'EnableDynamicMemoryAllocation' and 'DynamicMemoryAllocationThreshold' options instead. Alternatively, in the MATLAB Coder app select "Enable dynamic memory allocation" and set a value for
"Dynamic memory allocation threshold". 
Compile-time recursion limit reached. Value of input #2 of function 'update_llr' may change at every call.

Error in ==> update_llr Line: 25 Column: 13
Warning: While saving an object of class 'coder.Function':
Recursion limit exceeded when saving instance of class to a MAT-file. This is either because the instance contains an extremely long chain of references, or the class definition contains an error. 
> In coder.report/ContributionContext/saveMatFile
In genReportData
In codergui.evalprivate
In codergui.ReportServices.defaultReportGenerator
In coder.internal.gui/Serviceable/doInvoke
In coder.internal.gui/Serviceable/run
In indexing
In coder.internal.cli/ReportGenSupport/doReportGen
In coder.internal.cli/ReportGenSupport/performReportGen
In coder.internal.cliapi/CodegenExtensionDispatcher/dispatchFulfillable
In coder.internal.cliapi/CodegenExtensionDispatcher/performReportGen
In coder.internal.cliapi/CodegenExtensionDispatcher/dispatch
In coder.internal/CodegenKernel/invokePhase
In coder.internal/CodegenKernel/doExecute
In coder.internal/CodegenKernel/execute
In coder.internal.cli.invokeDefaultCodegenKernel
In codegen 
Warning: While saving an object of class 'coder.Function':
Recursion limit exceeded when saving instance of class to a MAT-file. This is either because the instance contains an extremely long chain of references, or the class definition contains an error. 
> In coder.report/ContributionContext/saveMatFile
In genReportData
In codergui.evalprivate
In codergui.ReportServices.defaultReportGenerator
In coder.internal.gui/Serviceable/doInvoke
In coder.internal.gui/Serviceable/run
In indexing
In coder.internal.cli/ReportGenSupport/doReportGen
In coder.internal.cli/ReportGenSupport/performReportGen
In coder.internal.cliapi/CodegenExtensionDispatcher/dispatchFulfillable
In coder.internal.cliapi/CodegenExtensionDispatcher/performReportGen
In coder.internal.cliapi/CodegenExtensionDispatcher/dispatch
In coder.internal/CodegenKernel/invokePhase
In coder.internal/CodegenKernel/doExecute
In coder.internal/CodegenKernel/execute
In coder.internal.cli.invokeDefaultCodegenKernel
In codegen 
Code generation failed: View Error Report

Error using codegen

test_ecc I'm trying to convert is just some simple test code using PUCCH

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions