title: Unconstrained Strings in VHDL
body: <p>I need to design a record with an unconstrained string that has this effect (below). Right now that type does not synthesize because of a <code>Type for a record element may not be an unconstrained array</code> error.</p>
  
  <pre><code>type type_textChunk is
  record
      text: string;
      color: std_logic_vector(7 downto 0); -- "111" &amp; "111" &amp; "11"
  end record;
  type type_textPassage is array(natural range &lt;&gt;) of type_textChunk; 
  </code></pre>
  
  <p>This way I can have a text block with multiple sections of variable length and color in it. This will be used in a text module for VGA display. </p>
  
  <p>I already have working version that does not use this new found design. You can find it on <a href="https://github.com/MadLittleMods/FP-V-GA-Text" rel="nofollow noreferrer">GitHub under the name FP(V)GA-Text</a>. It currently uses a generic on the component which defines the length of the string but is not suitable to draw a sentence of multiple colors easily (manual positioning of multiple components could mimic this effect, although painstaking)</p>
  
  <p>I understand that infinite hardware is not possible but I want this to be re-usable and generic as possible in order to suit everyone's needs. If this is not the right way to go about my plan then how do I design this functionality in.</p>
  
  <p>It looks like there is a <a href="https://stackoverflow.com/questions/6356657/">topic on the subject</a> but only a <a href="https://stackoverflow.com/a/6366226/796832">VHDL-2008 solution</a>. I am using Xilinx 14.5 which I believe does not support VHDL-2008 because is it is producing that error.</p>
  
  <p>A possible solution may be a "&amp;" concatenating function for the custom type that repositions the right side element relatively to the left side element to line it up correctly... This is not ideal though.</p>
  
  <h2>Update <em>(7/17/2013)</em></h2>
  
  <p>I had a huge flaw in my design. I was making a whole new gigantic font ROM for every text_line element. This has been fixed by creating a shared fontROM and an arbiter to interface to the text_line elements. This version is on <a href="https://github.com/MadLittleMods/FP-V-GA-Text" rel="nofollow noreferrer">GitHub project</a>. Another feature that has been added is a color map. Since you can not have a unconstrained item in a record I had to split it up.</p>
  
  <pre><code>type type_textColorMap is array(natural range &lt;&gt;) of std_logic_vector(7 downto 0); 
  </code></pre>
  
  <p>There is a color for each character. I wish you could use <code>others =&gt; ...</code> syntax but it doesn't like it in the entity instantiation so you have to use a bit more combersome and less maintainable syntax. A goal syntax would be something like: <code>colorMap =&gt; (others =&gt; "111" &amp; "111" &amp; "11", 2 =&gt; "111" &amp; "000" &amp; "00"),</code></p>
  
  <p>But you have to use:</p>
  
  <pre><code>colorMap =&gt; (10 downto 0 =&gt; "111" &amp; "111" &amp; "11"),
  </code></pre>
  
  <p>or mix and match the colors by:</p>
  
  <pre><code>colorMap =&gt; (7 downto 4 =&gt; "111" &amp; "111" &amp; "11", 3 downto 2 =&gt; "111" &amp; "000" &amp; "00", 1 downto 0 =&gt; "111" &amp; "111" &amp; "11"),
  </code></pre>