为lcd-data

时间:2016-02-05 12:03:12

标签: vhdl

我想创建动态字符串数组,因此我可以将其传输到Altera DE2-115板上的lcd模块。到目前为止,大部分工作都在起作用,但最后一部分并未涉及以下代码:

CREATE_STRING:  PROCESS (CLK, RESET, X)
    BEGIN
        IF RESET = '1' THEN
            FOR i IN 0 TO 31 LOOP
                lcd_data(i) <= x"30";
            END LOOP;
        END IF;

        IF X /= 0 THEN
            FOR i IN 0 TO 15 LOOP
                IF X(15-i) = '0' THEN   
                    lcd_data(i) <= x"30";
                END IF;
                IF X(15-i) ='1' THEN 
                    lcd_data(i) <= x"31";
                END IF;
            END LOOP;
        END IF;

        IF char_count > 15 AND lcd_y = '1' THEN 
            ELSIF CLK = '1' AND CLK'event THEN
                lcd_data(to_integer(char_count)) <= x"31";
        END IF;

END PROCESS CREATE_STRING;

我收到此错误消息:

Error (10818): Can't infer register for "lcd_data[31][0]" at seqdec.vhd(75) because it does not hold its value outside the clock edge

表示每个lcd_data [31] [x]。

我搜索了这个错误,如果我没有完全按照错误的想法,我认为我理解它,但我仍然无法做到这一点......

如果有人可以提供建议,那会很棒。

祝你好运 阿德里安

这是否改变了:

CREATE_STRING:  PROCESS (CLK, RESET)
    BEGIN
        IF RESET = '1' THEN
            FOR i IN 0 TO 31 LOOP
                lcd_data(i) <= x"30";
            END LOOP;

        ELSIF CLK = '1' AND CLK'event THEN
            IF X /= 0 THEN
                FOR i IN 0 TO 15 LOOP
                    IF X(15-i) = '0' THEN   
                        lcd_data(i) <= x"30";
                    END IF;
                    IF X(15-i) ='1' THEN 
                        lcd_data(i) <= x"31";
                    END IF;
                END LOOP;
            END IF;
        ELSIF lcd_y = '1' THEN  
                lcd_data(to_integer(pos_count)) <= x"31";
        END IF;

END PROCESS CREATE_STRING;

但仍然是同样的问题。

1 个答案:

答案 0 :(得分:2)

要正确描述寄存器,您必须按如下方式颠倒if语句的顺序:

CREATE_STRING:  PROCESS (CLK, RESET)
    BEGIN
        IF RESET = '1' THEN
            FOR i IN 0 TO 31 LOOP
                lcd_data(i) <= x"30";
            END LOOP;
        ELSIF CLK = '1' AND CLK'event THEN
            IF X /= 0 THEN
                FOR i IN 0 TO 15 LOOP
                    IF X(15-i) = '0' THEN   
                        lcd_data(i) <= x"30";
                    END IF;
                    IF X(15-i) ='1' THEN 
                        lcd_data(i) <= x"31";
                    END IF;
                END LOOP;
            END IF;

            IF char_count > 15 AND lcd_y = '1' THEN 
                lcd_data(to_integer(char_count)) <= x"31";
            END IF;
        END IF;
END PROCESS CREATE_STRING;