代码之家  ›  专栏  ›  技术社区  ›  Karthik

你好,我是VHDL编程新手,请帮助我解决这些错误

  •  -4
  • Karthik  · 技术社区  · 11 年前

    我不知道为什么它显示错误,尽管语法似乎是正确的。

    我不想编程sramctl,其中地址adds_in是输入地址,sram_add是输出地址,我只是映射地址,没有考虑数据总线。

    library IEEE;
    use IEEE.std_logic_1164.all;
    
    entity sramctrl is
    port(clk,adsn,blastn,lwdrn,lhold:in std_logic;
     adds_in :in std_logic_vector(9 downto 2);          
    
     adds_4msb:in std_logic_vector(31 downto 28);
     readyn,btermn,sramcsn,sramoen,lholda :out std_logic;
     sram_adds:out std_logic_vector(9 downto 2));
     end sramctrl;
    architecture behavioral of sramctrl is
    type state_type is(s0,s1,s2);
    signal state:state_type;
    begin
    process(clk,adsn,blastn,lwdrn,lhold,adds_in,adds_4msb)
    begin
        variable sa:std_logic:='0';
        variable a31_a28 :std_logic_vector(3 downto 0):="0000";
        variable temp:std_logic_vector(9 downto 2):="00000000";
        if(rising_edge(clk))then
            if ((not adsn) and (adds_4msb="0000"))then         
            a31_28 := adds_4msb; 
            end if;
            if (lhold='1')then
                lholda<='1';
            else
                 lholda<='0';
            end if;
            sa:=lhold and lholda ;
            case state is
                when s0=>sramoen<='1';
                        sramcsn<='1';
                        readyn<='1';
                        btermn<='1';
                        if((not adsn) and (not adds_4msb) and sa)then
                            temp:=adds_in;
                                if(lwdrn='1')then
                                    state<=s1;
                                    ready<='0';
                                else
                                    state<=s2;
                                end if;
                        else
                            state<=s0;
                        end if;
                    when s1=>sramoen<='1';
                            sramcsn<='0';
                            if(lwdrn and (not blastn) and sa)then
                                sram_adds<=temp;
                                readyn<='1';
                                btermn<='1';
                                state<=s0;
                            elsif(lwdrn and blastn and sa)then
                                if(temp=X"fe")then
                                    sram_adds<=temp;
                                    temp:=temp+1;
                                    btermn<='0';
                                    readyn<='0';
                                    state<=s1;
                                elsif(temp=X"ff")then
                                    sram_adds<=temp;
                                    btermn<='1';
                                    readyn<='1';
                                    state<=s0;
                                else
                                    sram_adds<=temp;
                                    temp:=temp+1;
                                    btermn<='1';
                                    readyn<='0';
                                    state<=s1;
                                end if;
                            else
                                state<=s2;
                            end if;
                 when s2=>sramoen<='0';
                          sramcsn<='0';
                         if((not lwdrn) and (not blastn) and sa)then
                            sram_adds<=temp;
                            readyn<='1';
                            btermn<='1';
                            state<=s0;
                        elsif((not lwdrn) and blastn and sa)then
                            if(temp=X"fe")then
                                sram_adds<=temp;
                                temp:=temp+1;
                                btermn<='0';
                                readyn<='0';
                                state<=s2;
                            elsif(temp=X"ff")then
                                sram_adds<=temp;
                                btermn<='1';
                                readyn<='1';
                                state<=s0;
                            else
                                sram_adds<=temp;
                                temp:=temp+1;
                                btermn<='1';
                                readyn<='0';
                                state<=s2;
                            end if;
                        else
                         state<=s2;
                        end if;
           when others =>state<=s0;
          end case;
          end if;
          end process;
          end behavioral ;
    

    我找不到解决办法,请帮我解决。弹出的错误:

    COMP96编译实体“sramctrl”的体系结构“行为”
    COMP96错误COMP96_0019:“需要关键字'end'。”“design.vhd”18 9
    COMP96错误COMP96_0019:“需要关键字'end'。”“design.vhd”19 3
    COMP96错误COMP96_0016:“需要设计单元声明。”“Design.vhd”

    1 回复  |  直到 11 年前
        1
  •  1
  •   user1155120 user1155120    11 年前

    不,你的语法不正确。

    阿米尔指出:

    process(clk,adsn,blastn,lwdrn,lhold,adds_in,adds_4msb)
    begin
        variable sa:std_logic:='0';
        variable a31_a28 :std_logic_vector(3 downto 0):="0000";
        variable temp:std_logic_vector(9 downto 2):="00000000";
    

    应该是:

    process(clk,adsn,blastn,lwdrn,lhold,adds_in,adds_4msb)
        variable sa:std_logic:='0';
        variable a31_a28 :std_logic_vector(3 downto 0):="0000";
        variable temp:std_logic_vector(9 downto 2):="00000000";
    begin
    

    begin 这里将流程声明部分与流程语句部分分开。

    此外,此处:

            if ((not adsn) and (adds_4msb="0000"))then    
    

    没有 and 运算符,将std_logic与布尔值进行and运算(右表达式的结果)。 not 不是逻辑归约运算符,在这种情况下,它返回stdlogic。

    应遵循以下原则:

            if adsn = '0' and adds_4msb = "0000" then
    

    对两个布尔结果进行AND运算。请注意 adds_4msb .

    下一行:

            a31_28 := adds_4msb; 
    

    拼写错误,应该是a31_a28。

    在这里:

            if lhold = '1' then
                lholda <= '1';
            else
                 lholda <= '0';
            end if;
            sa := lhold and lholda ;
    

    lholda 是一个输出,在一些不符合IEEE Std 1076-2008的工具中无法读取。它还产生 sa 这只是延迟了一个增量模拟周期(没有时间推进),除了在 holda 对于 sa公司 或从开始 lhold 。如果你指望着三角洲周期不在那里,那么你的设计就有缺陷。增量循环模拟并行性,时序关系不应依赖变量。这意味着你没有一个合成合格的sram_ctl模型。合成将看到 lhold公司 奥尔达 作为一个整体,以及 sa公司 作为同一事物的不同名称。

    在这里:

                                    ready<='0';
    

    没有信号 ready 在您的设计中呈现。

    以及:

                            if(lwdrn and (not blastn) and sa)then
    

    以及:

                            elsif(lwdrn and blastn and sa)then
    

    您正在尝试使用逻辑运算符生成布尔条件。(所有这些括号也是多余的)尝试将两个表达式条件测试为std_logic值。

    这两个条件分别显示两个位置。

    以及:

                                    temp:=temp+1;
    

    没有直接可见的添加运算符“+”(两个位置)。您应该使用包std_logic_signed或 temp 应该是无符号的,并且应该使用包numeric_std(在分配给 sram_adds ).