Search code examples
vhdlxilinx-isespartan

VHDL : Selector (Constant ' ' of type STRING) is an unconstrained array


I downloaded a VHDL LCD Library from http://www.intesc.mx/soporte and I'm getting the following error when checking Syntax :

Started : "Check Syntax for LIB_LCD_INTESC_REVB".
Running xst...
Command Line: xst -intstyle ise -ifn {D:/My pc/My documents/ISE/Libreria/LIB_LCD_INTESC_REVB.xst} -ofn LIB_LCD_INTESC_REVB.stx

=========================================================================
*                          HDL Compilation                              *
=========================================================================
Compiling vhdl file "D:/Drive/Cetys/3R semestre/Digitales 2/Morsese/LCD2x16RevB/LCD2x16RevB/COMANDOS_LCD_REVB.vhd" in Library work.
ERROR:HDLParsers:839 - "D:/Drive/Cetys/3R semestre/Digitales 2/Morsese/LCD2x16RevB/LCD2x16RevB/COMANDOS_LCD_REVB.vhd" Line 77. Selector (Constant 'DATO1' of type STRING) is an unconstrained array.

I'm getting the error in the line selected with (->) :

->    FUNCTION CHAR(DATO1 : STRING) RETURN STD_LOGIC_VECTOR IS     
VARIABLE DATAOUT1 : STD_LOGIC_VECTOR(8 DOWNTO 0);
BEGIN
    CASE DATO1 IS
    WHEN a => RETURN '1'&x"09";
    WHEN b => RETURN '1'&x"0A";
    WHEN c => RETURN '1'&x"0B";
    WHEN d => RETURN '1'&x"0C";
    WHEN e => RETURN '1'&x"0D";
    WHEN f => RETURN '1'&x"0E";
    WHEN g => RETURN '1'&x"0F";
    WHEN h => RETURN '1'&x"10";
    WHEN i => RETURN '1'&x"11";
    WHEN j => RETURN '1'&x"12";
    WHEN k => RETURN '1'&x"13";
    WHEN l => RETURN '1'&x"14";

I know the basics of VHDL, but I don't know how to debug these type of errors.

Thanks for the help.


Solution

  • The selector of a case statement cannot be a string because strings are unconstrained arrays (arrays which length is unknown until you specify it) and are not a locally static type. VHDL case statements accept only selectors of a locally static type. Moreover, a, b, c... are not string literals. What you have downloaded is not VHDL. You can try to fix all this by modifying the code but I would not even try. It has been written by people who do not know VHDL and there are probably zillions of other problems. Anyway, you can try this, instead:

    FUNCTION CHAR(DATO1 : character) RETURN STD_LOGIC_VECTOR IS     
    VARIABLE DATAOUT1 : STD_LOGIC_VECTOR(8 DOWNTO 0);
    BEGIN
        CASE DATO1 IS
        WHEN 'a' => RETURN '1'&x"09";
        WHEN 'b' => RETURN '1'&x"0A";
        WHEN 'c' => RETURN '1'&x"0B";
        ...
    

    Of course, you will have to edit the calls to the CHAR function too: check that the passed parameter is a character, not a string.