String Constant — Control Systems/Strings
Control_Systems/Strings/String_Constant · 0 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
String Constant
Control Systems / Strings
Produces the same piece of text on every step. It is where a text signal starts: nothing else in the library invents one.
Ports
- Output – the text (
str,ICoreString), one value, not a matrix. A text signal has no rows and columns to choose; it is a single piece of text carried on its own beside the wire's numeric slot, and it is drawn with a dash-dotted line so you can tell it from a number at a glance.
Parameters
- String – the text, written with its quotes:
"Hello!", notHello!. Single quotes work too. The quotes are part of the value because that is exactly how the same setting is spelled in Simulink, so the two agree without anything being added or removed in between. To put the quote character itself inside the text, write it twice, as MATLAB does:"say ""hi"""is the text say "hi", and'it''s'is it's. Text longer than 256 bytes is cut at 256. - Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
What can be connected to it
Only an input that accepts text. A link joins two ports of the same type or is refused, and there is no block that converts a number to text yet – so a String Constant reaches the text inputs of the other Strings blocks and a subsystem boundary, and nothing else.
Code export
C, C++, Python, MATLAB, Java and
Rust each carry the text in their own way: a fixed char
buffer of 256 bytes in C, and the language's own string type elsewhere. Every
one of them holds the same 256-byte limit the simulation holds, so a long
string is cut in the same place everywhere.
VHDL, Verilog and SystemVerilog do not carry text at all: every signal in those three is a fixed-point number of a fixed width, and there is nothing sensible to make a variable-length string into. PLC Structured Text is not supported either: the language has a string type, but the check that runs an exported core cannot read one back, so a text signal could not be verified there. An export to any of these four stops and names this block and the reason, rather than exporting something that would run and be wrong.
Simulink bridge
Import and export, mapped to simulink/String/String Constant. "String"
crosses unchanged, quotes and all, and both sides read a doubled quote inside it
the same way. Simulink's output data type is always string on this
block and is written as a fixed setting. The Simulink block has no
sampling-time setting of its own, so a positive Sampling Time (s) stays
on this side and is reported rather than written.
Simulink's String Constant accepts only Latin-1 characters in its text and refuses anything else (a Chinese or Arabic word, an emoji) when the parameter is set, so a constant holding such text runs here but does not cross.
Notes
- Algebraic, with no state: the output is the same on every step.
- The text is measured and cut in bytes of UTF-8, not characters, so a 256-byte cut can land in the middle of an accented or non-Latin character. That is deliberate: it is exactly what the fixed buffer in exported C does, and a simulation that cut somewhere else would disagree with it.
- Empty text (
"") is a perfectly good value and is what an unconnected text input reads.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Strings/String_Constant |
| family | Control_Systems/Strings |
| solver environment class | ICoreBlock_0_Control_Systems_1_Strings_2_String_Constant |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Strings/String_Constant/ICoreBlock_0_Control_Systems_1_Strings_2_String_Constant.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Strings/String_Constant/ICoreBlock_0_Control_Systems_1_Strings_2_String_Constant.h |
| default size on canvas | 90 × 60 px |
| ports at insert | 0 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++ |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | out | ICoreString | — |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
String | "Hello!" | String |
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::Both |
| Simulink path | simulink/String/String Constant |
| port-count rule | PortsParam:: |
SampleTime parameter | no — the counterpart defines none; the rate stays on the ICore side |
| ICore config | Simulink parameter | Value translation |
|---|---|---|
String | String | passes through |
Caveat (shown to the user): the text crosses VERBATIM, quotes included, because Simulink spells this parameter with its quotes too (measured on R2026a: the default reads "Hello!") -- so neither side adds or strips one and a round trip cannot
Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
String Constant -- the first source of a String signal y = a fixed piece of text, every step. There is no arithmetic here at all; what the block is FOR is the two things a String port does differently from every other port, both of which this file is the first block in the library to exercise:
- THE VALUE IS NOT IN THE MATRIX. A String port's ICoreMatrix is a 1x1 zero placeholder
and the text lives in the port's side carrier (D2). writeOutputPorts() carries only matrices, so compute_h writes the text onto the port itself and returns the placeholder.
- THE SIZE IS ALWAYS 1x1 and the PORT enforces it, so nothing here sizes anything.
The six languages whose map row says they can carry a string emit real string code below. The three HDL targets and PLC Structured Text refuse a String signal by name before a body is ever asked for (T5.7), so this file has no body for them at all -- an override there would be unreachable code that the description then owed a claim for.
Sample results#
This block carries a ICoreString signal, whose value is text rather than a number and is not something a plot has an axis for. The samples are in the table below, exactly as the run recorded them.
| t | out ICoreString-Out-0 |
|---|---|
| 0 | Hello! |
| 0.4 | Hello! |
| 0.8 | Hello! |
| 1.2 | Hello! |
| 1.6 | Hello! |
| 2 | Hello! |
| 2.4 | Hello! |
| 2.8 | Hello! |
| 3.2 | Hello! |
| 3.6 | Hello! |
| 4 | Hello! |
| 4.4 | Hello! |
| 4.8 | Hello! |
| 5.2 | Hello! |
Every 4th of 60 samples, from the free stimulus.
Plotted: free — No input: the block run alone
Category source · sample time 0.1 · 60 steps · commit 6280f52f3 · produced by docsSample --out <folder> --blocks Rational_Resample,Three_Axis_Accelerometer,Three_Axis_Gyroscope,Three_Axis_Inertial_Measurement_Unit,Eclipse_Shadow_Model,To_String,String_To_ASCII,ASCII_To_String,Substring,String_Constant,String_Concatenate,String_Compare,String_Length --steps 60 · data docs/generated/samples/Control_Systems__Strings__String_Constant.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).