奇偶校验器的一个代码,process那一直有错误,大神给看一下(递归等不支持或不好的地方出口或下一语句。)
时间:10-02
整理:3721RD
点击:
package types is
subtype short is integer range 0 to 255;
end types;
use work.types.all;
entity parity is
port(in0 :in bit;
in1 :in bit;
in2 :in bit;
in3 :in bit;
in4 :in bit;
in5 :in bit;
in6 :in bit;
in7 :in bit;
EVEN_IN:in bit;
ODD_IN :in bit;
IN_READY:in bit;
OUT_REQ:in bit;
CLK :in bit;
OUT_READY:out bit;
ODD_OUT:out bit;
EVEN_OUT:out bit);
end parity;
architecture algorithm of parity is
begin
process
variable cond: boolean :=true;
variable count: short;
begin
wait until CLK'EVENT and CLK='1' and IN_READY='1';
if EVEN_IN=ODD_IN then
cond:=false;
end if;
count:=0;
if in0='1' then
count:=count+1;
end if;
if in1='1' then
count:=count+1;
end if;
if in2='1' then
count:=count+1;
end if;
if in3='1' then
count:=count+1;
end if;
if in4='1' then
count:=count+1;
end if;
if in5='1' then
count:=count+1;
end if;
if in6='1' then
count:=count+1;
end if;
if in7='1' then
count:=count+1;
end if;
L1:while count>1 loop
count:=count-2;
end loop L1;
if count=1 and ODD_IN='0' then
cond:=false;
end if;
if count=0 and EVEN_IN='0' then
cond:=false;
end if;
if count=1 then
EVEN_OUT<='0';
ODD_OUT<='1';
else
EVEN_OUT<='1';
ODD_OUT<='0';
end if;
wait until CLK'EVENT and CLK='1' and OUT_REQ='1';
OUT_READY<='1';
wait until CLK'EVENT and CLK='1' and OUT_REQ='0';
OUT_READY<='0';
assert cond
report "ODD_IN even_in error"
severity warning;
end process;
end algorithm;
subtype short is integer range 0 to 255;
end types;
use work.types.all;
entity parity is
port(in0 :in bit;
in1 :in bit;
in2 :in bit;
in3 :in bit;
in4 :in bit;
in5 :in bit;
in6 :in bit;
in7 :in bit;
EVEN_IN:in bit;
ODD_IN :in bit;
IN_READY:in bit;
OUT_REQ:in bit;
CLK :in bit;
OUT_READY:out bit;
ODD_OUT:out bit;
EVEN_OUT:out bit);
end parity;
architecture algorithm of parity is
begin
process
variable cond: boolean :=true;
variable count: short;
begin
wait until CLK'EVENT and CLK='1' and IN_READY='1';
if EVEN_IN=ODD_IN then
cond:=false;
end if;
count:=0;
if in0='1' then
count:=count+1;
end if;
if in1='1' then
count:=count+1;
end if;
if in2='1' then
count:=count+1;
end if;
if in3='1' then
count:=count+1;
end if;
if in4='1' then
count:=count+1;
end if;
if in5='1' then
count:=count+1;
end if;
if in6='1' then
count:=count+1;
end if;
if in7='1' then
count:=count+1;
end if;
L1:while count>1 loop
count:=count-2;
end loop L1;
if count=1 and ODD_IN='0' then
cond:=false;
end if;
if count=0 and EVEN_IN='0' then
cond:=false;
end if;
if count=1 then
EVEN_OUT<='0';
ODD_OUT<='1';
else
EVEN_OUT<='1';
ODD_OUT<='0';
end if;
wait until CLK'EVENT and CLK='1' and OUT_REQ='1';
OUT_READY<='1';
wait until CLK'EVENT and CLK='1' and OUT_REQ='0';
OUT_READY<='0';
assert cond
report "ODD_IN even_in error"
severity warning;
end process;
end algorithm;