Update to message on strings of variable length using a function which expands to 25 char 
Author Message
 Update to message on strings of variable length using a function which expands to 25 char

-- This is a more rubust function than the one I just  passed.  It checks
-- strings longer than 25.   It can be used to clamp a string to 25
-- Thus an element can be defined of type String25_Typ, and a value can be
assigned as shown -- below:
-- variable SomeVAr :  String25_Typ;
-- SomeVar := T25("Hello");   -- expanded to 25 charactes.
-- This is not a truly variable length (i.e. it is constrained), but the
user need not concern
-- himself with counting the number of necessary spaces to make up a total
of 25.  
-- In addition, the access type "line" is not used.  
package T25_Pkg is
subtype String25_Typ is string(1 to 25);  
   function T25(StringIn_c : string) return String25_Typ;
end T25_Pkg;

package body T25_Pkg is
   function T25(StringIn_c : string) return String25_Typ is
    variable Char25_v : String25_Typ := (others => ' ');
      if StringIn_c'length > 25 then
        return StringIn_c(String25_Typ'range);
        assert false
          report "String is linger than 25"
          severity warning;
      end if;
      LP_Lbl : for Index_i in 1 to StringIn_c'length  loop
        Char25_v(Index_i) := StringIn_c(Index_i);
      end loop LP_Lbl;
      return Char25_v;
    end T25;
end T25_Pkg;
Ben Cohen is the author of an upcoming book "VHDL Coding Styles and
Methodologies" to be published by Kluwer Academics Publishers.

Wed, 08 Oct 1997 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Using Variable Length Strings in VHDL

2. expanding variables in strings

3. Loading a module by expanding a string variable?

4. expanding string variables

5. Variable Length Strings and the ANY type

6. Legacy, Clacom, Variable length string

7. Variable length string on Report

8. Variable length string

9. Variable length string packages

10. Variable length strings??

11. Variable Length Strings

12. Variable Length strings...


Powered by phpBB® Forum Software