case st is when st0=>en1<='0';green<='0';red<='0';sp<='0'; if start='1'then st<=st1; else st<=st0; end if; when stl=>en1<='1';green<='0';red<='0';sp<='0'; if result='1'then st<=st2; elsif iopen=′1'then st<=st4; elsif set='1'then st<=st0; else st<=stl; end if; when st2=>en1<='1';green<='0';red<='0';sp<='0'; if iopen=′1′then st<=st3; elsif set='1′then st<=st0; else st<=st2; end if; when st3=>en1<='0';green<='1';red<='0';sp<='0'; if set=′1′then st<=st0; else st<=st3; end if; when st4=>en1<='1';green<='0';red<='1';sp<='0'; if result=′1′then st<=st2; elsif set=′1′then st<=st0; elsif result=′0′and iopen=′1′then st<=st5; else st<=st4; end if; when st5=>en1<='0';green<='0';red<='1';sp<='1'; if set='1'then st<=st0; else st<=st5; end if; when others=>st<=st0; end case;这段代码错误在哪,并帮我改正
时间: 2024-02-14 15:10:57 浏览: 145
Delphi中使用串口控件MSComm的0字符接收例程祥解
这段代码的错误在于if语句应该被放在process块中,而不是在case块中。此外,'和′是不同的符号,应该使用正确的符号。以下是修改后的代码:
```
process(st, start, result, iopen, set)
begin
case st is
when st0=>
en1<='0';
green<='0';
red<='0';
sp<='0';
if start='1' then
st<=st1;
else
st<=st0;
end if;
when stl=>
en1<='1';
green<='0';
red<='0';
sp<='0';
if result='1' then
st<=st2;
elsif iopen='1' then
st<=st4;
elsif set='1' then
st<=st0;
else
st<=stl;
end if;
when st2=>
en1<='1';
green<='0';
red<='0';
sp<='0';
if iopen='1' then
st<=st3;
elsif set='1' then
st<=st0;
else
st<=st2;
end if;
when st3=>
en1<='0';
green<='1';
red<='0';
sp<='0';
if set='1' then
st<=st0;
else
st<=st3;
end if;
when st4=>
en1<='1';
green<='0';
red<='1';
sp<='0';
if result='1' then
st<=st2;
elsif set='1' then
st<=st0;
elsif result='0' and iopen='1' then
st<=st5;
else
st<=st4;
end if;
when st5=>
en1<='0';
green<='0';
red<='1';
sp<='1';
if set='1' then
st<=st0;
else
st<=st5;
end if;
when others=>
st<=st0;
end case;
end process;
```
请注意,代码中仍然可能存在其他错误,因此您应该进行仔细的测试和验证。
阅读全文