If statement 您好,我是VHDL编程新手,请帮助我解决这些错误
我不知道为什么它会显示错误,尽管语法似乎是正确的 我打算编写SAMRCTL地址地址是地址,SRAMYA增加输出地址,我只是映射地址,没有考虑数据总线。If statement 您好,我是VHDL编程新手,请帮助我解决这些错误,if-statement,vhdl,state-machine,If Statement,Vhdl,State Machine,我不知道为什么它会显示错误,尽管语法似乎是正确的 我打算编写SAMRCTL地址地址是地址,SRAMYA增加输出地址,我只是映射地址,没有考虑数据总线。 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
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错误COMP960019:应为关键字“end”。design.vhd 18 9
COMP96错误COMP960019:应为关键字“end”。设计语言vhd 19 3
COMP96错误COMP960016:应为设计单元声明。设计语言
不,你的语法不正确 正如埃米尔指出的那样:
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_逻辑和正确表达式的布尔结果相加。not不是逻辑缩减运算符,在本例中它返回std_逻辑
应遵循以下原则:
if adsn = '0' and adds_4msb = "0000" then
这是两个布尔结果。请注意adds_4msb的正确拼写
下一行:
a31_28 := adds_4msb;
有一个拼写错误,应该是a31_a28
这里::
if lhold = '1' then
lholda <= '1';
else
lholda <= '0';
end if;
sa := lhold and lholda ;
您的设计中没有现成的信号
以及:
以及:
elsif(lwdrn and blastn and sa)then
您正在尝试使用逻辑运算符生成布尔条件。所有这些括号都是多余的,可以将两个表达式测试为std_逻辑值
这两种情况分别出现在两个地方
以及:
没有添加运算符+直接可见的两个位置。您应该使用package std_logic_unsigned或者temp应该是unsigned,并且您应该使用package numeric_std,在分配给sram_adds时需要进行类型转换。必须在begin语句之前声明进程变量内部。有关VHDL编程的任何参考资料建议?任何参考资料建议关于VHDL编程?请求Stackoverflow之外的资源不是一个合适的问题。请参见“我可以在此处提出什么问题”页面。这是一个获取特定问题具体答案的地方,而不是获取一般问题的一般答案的地方。尝试用谷歌搜索VHDL备忘。
if(lwdrn and (not blastn) and sa)then
elsif(lwdrn and blastn and sa)then
temp:=temp+1;