[td]各位大哥,下面这段断码应该怎么修改才能编译通过啊?每次都要报错。。。。鄙人没玩过vhdl,很是惆怅啊
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all; --必须声明这个包集才能使用Signed和Unsigned
USE ieee.std_logic_signed.all;
USE ieee.std_logic_unsigned.all;
ENTITY OC_ERR IS
PORT(
Reset : IN STD_LOGIC; --全局复位
Clk : IN STD_LOGIC; --全局时钟
cpuCS : IN STD_LOGIC; --CPU片选
CpuWr : IN STD_LOGIC; --CPU写信号
CpuData : IN STD_LOGIC_VECTOR(15 downto 0); --CPU数据线
AD1Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
AD2Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
AD3Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
A_Fault_Flag : OUT STD_LOGIC ; --故障标志
B_Fault_Flag : OUT STD_LOGIC ;
C_Fault_Flag : OUT STD_LOGIC
);
END OC_ERR;
ARCHITECTURE behave OF OC_ERR IS
SIGNAL A_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL B_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL C_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL ProtectPara : SIGNED(15 DOWNTO 0);
SIGNAL ProtectPara_BackUp : SIGNED(15 DOWNTO 0);
SIGNAL ProtectParaUpper : SIGNED(15 DOWNTO 0);
SIGNAL ProtectParaLow : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff1 : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff2 : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff3 : SIGNED(15 DOWNTO 0);
SIGNAL A_Err_Flag_Buff : STD_LOGIC;
SIGNAL B_Err_Flag_Buff : STD_LOGIC;
SIGNAL C_Err_Flag_Buff : STD_LOGIC;
SIGNAL cpuwr_r1 : STD_LOGIC;
SIGNAL cpuwr_r2 : STD_LOGIC;
BEGIN
----------------------------------------------------------------------
-- 从CPU获取保护值
-- -------------------------------------------------------------------
Delay_Proc:process(Reset,Clk)
begin
if (Reset=‘0’) then
cpuwr_r1 《= ‘0’;
cpuwr_r2 《= ‘0’;
ProtectPara 《= x“7530”; --默认30000;
ProtectPara_BackUp《= x“7530”; --默认30000;
ProtectParaUpper 《= (others=》‘0’);
ProtectParaLow 《= (others=》‘0’);
ADDataBuff1《=(others=》‘0’);
ADDataBuff2《=(others=》‘0’);
ADDataBuff3《=(others=》‘0’);
ELSIF RISING_EDGE(Clk) THEN
--------------------------CPU写信号两次同步----------------
cpuwr_r1 《= CpuWr;
cpuwr_r2 《= cpuwr_r1;
ProtectPara_BackUp《= x“7530”; --默认30000;
--------------------------数据处理-----------------------
if ((CPUCS=‘1’) and (cpuwr_r2=‘1’) and (cpuwr_r1=‘0’)) then
ProtectPara 《= SIGNED(CpuData); --获取保护值
end if;
if((ProtectPara 《 32500)and(ProtectPara 》 10))then
ProtectParaUpper 《= SIGNED(ProtectPara);
ProtectParaLow 《= 0 - SIGNED(ProtectPara);
else
ProtectParaUpper 《= SIGNED(ProtectPara_BackUp);
ProtectParaLow 《= 0 - SIGNED(ProtectPara_BackUp);
end if;
--------------------------读取AD数据-----------------------
if(AD1Data = x“7FFF”) then
ADDataBuff1 《= ADDataBuff1;
else
ADDataBuff1 《= SIGNED(AD1Data);
end if;
if(AD2Data = x“7FFF”) then
ADDataBuff2 《= ADDataBuff2;
else
ADDataBuff2 《= SIGNED(AD2Data);
end if;
if(AD3Data = x“7FFF”) then
ADDataBuff3 《= ADDataBuff3;
else
ADDataBuff3 《= SIGNED(AD3Data);
end if;
--ADDataBuff2 《= SIGNED(AD2Data);
--ADDataBuff3 《= SIGNED(AD3Data);
end if;
end process;
----------------------------------------------------------------------
-- 保护处理
-- -------------------------------------------------------------------
ERR_DELAY_PROC
《img smilie border=“0” al》
ROCESS(Clk,Reset)
BEGIN
IF Reset=‘0’ THEN
A_Err_Cnt《=(others=》‘0’);
A_Err_Flag_Buff 《= ‘0’;
B_Err_Cnt《=(others=》‘0’);
B_Err_Flag_Buff 《= ‘0’;
C_Err_Cnt《=(others=》‘0’);
C_Err_Flag_Buff 《= ‘0’;
ELSIF RISING_EDGE(Clk) THEN
if(( ADDataBuff1 》= ProtectParaUpper ) or ( ADDataBuff1 《= ProtectParaLow )) then --如果瞬时值大于门限值
A_Err_Cnt 《= A_Err_Cnt + 1;
if( A_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
A_Err_Flag_Buff 《= ‘1’; --故障置1
A_Err_Cnt 《= (others=》‘0’);
end if;
else
A_Err_Cnt 《= (others=》‘0’);
A_Err_Flag_Buff 《= ‘0’;
end if;
if(( ADDataBuff2 》= ProtectParaUpper ) or ( ADDataBuff2 《= ProtectParaLow )) then --如果瞬时值大于门限值
B_Err_Cnt 《= B_Err_Cnt + 1;
if( B_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
B_Err_Flag_Buff 《= ‘1’; --故障置1
B_Err_Cnt 《= (others=》‘0’);
end if;
else
B_Err_Cnt 《= (others=》‘0’);
B_Err_Flag_Buff 《= ‘0’;
end if;
if(( ADDataBuff3 》= ProtectParaUpper ) or ( ADDataBuff3 《= ProtectParaLow )) then --如果瞬时值大于门限值
C_Err_Cnt 《= C_Err_Cnt + 1;
if( C_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
C_Err_Flag_Buff 《= ‘1’; --故障置1
C_Err_Cnt 《= (others=》‘0’);
end if;
else
C_Err_Cnt 《= (others=》‘0’);
C_Err_Flag_Buff 《= ‘0’;
end if;
END IF;
END PROCESS;
A_Fault_Flag 《= A_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
B_Fault_Flag 《= B_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
C_Fault_Flag 《= C_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
END behave;
[td]各位大哥,下面这段断码应该怎么修改才能编译通过啊?每次都要报错。。。。鄙人没玩过vhdl,很是惆怅啊
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all; --必须声明这个包集才能使用Signed和Unsigned
USE ieee.std_logic_signed.all;
USE ieee.std_logic_unsigned.all;
ENTITY OC_ERR IS
PORT(
Reset : IN STD_LOGIC; --全局复位
Clk : IN STD_LOGIC; --全局时钟
cpuCS : IN STD_LOGIC; --CPU片选
CpuWr : IN STD_LOGIC; --CPU写信号
CpuData : IN STD_LOGIC_VECTOR(15 downto 0); --CPU数据线
AD1Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
AD2Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
AD3Data : IN STD_LOGIC_VECTOR(15 downto 0); --AD采样数据
A_Fault_Flag : OUT STD_LOGIC ; --故障标志
B_Fault_Flag : OUT STD_LOGIC ;
C_Fault_Flag : OUT STD_LOGIC
);
END OC_ERR;
ARCHITECTURE behave OF OC_ERR IS
SIGNAL A_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL B_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL C_Err_Cnt : STD_LOGIC_VECTOR(12 DOWNTO 0);
SIGNAL ProtectPara : SIGNED(15 DOWNTO 0);
SIGNAL ProtectPara_BackUp : SIGNED(15 DOWNTO 0);
SIGNAL ProtectParaUpper : SIGNED(15 DOWNTO 0);
SIGNAL ProtectParaLow : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff1 : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff2 : SIGNED(15 DOWNTO 0);
SIGNAL ADDataBuff3 : SIGNED(15 DOWNTO 0);
SIGNAL A_Err_Flag_Buff : STD_LOGIC;
SIGNAL B_Err_Flag_Buff : STD_LOGIC;
SIGNAL C_Err_Flag_Buff : STD_LOGIC;
SIGNAL cpuwr_r1 : STD_LOGIC;
SIGNAL cpuwr_r2 : STD_LOGIC;
BEGIN
----------------------------------------------------------------------
-- 从CPU获取保护值
-- -------------------------------------------------------------------
Delay_Proc:process(Reset,Clk)
begin
if (Reset=‘0’) then
cpuwr_r1 《= ‘0’;
cpuwr_r2 《= ‘0’;
ProtectPara 《= x“7530”; --默认30000;
ProtectPara_BackUp《= x“7530”; --默认30000;
ProtectParaUpper 《= (others=》‘0’);
ProtectParaLow 《= (others=》‘0’);
ADDataBuff1《=(others=》‘0’);
ADDataBuff2《=(others=》‘0’);
ADDataBuff3《=(others=》‘0’);
ELSIF RISING_EDGE(Clk) THEN
--------------------------CPU写信号两次同步----------------
cpuwr_r1 《= CpuWr;
cpuwr_r2 《= cpuwr_r1;
ProtectPara_BackUp《= x“7530”; --默认30000;
--------------------------数据处理-----------------------
if ((CPUCS=‘1’) and (cpuwr_r2=‘1’) and (cpuwr_r1=‘0’)) then
ProtectPara 《= SIGNED(CpuData); --获取保护值
end if;
if((ProtectPara 《 32500)and(ProtectPara 》 10))then
ProtectParaUpper 《= SIGNED(ProtectPara);
ProtectParaLow 《= 0 - SIGNED(ProtectPara);
else
ProtectParaUpper 《= SIGNED(ProtectPara_BackUp);
ProtectParaLow 《= 0 - SIGNED(ProtectPara_BackUp);
end if;
--------------------------读取AD数据-----------------------
if(AD1Data = x“7FFF”) then
ADDataBuff1 《= ADDataBuff1;
else
ADDataBuff1 《= SIGNED(AD1Data);
end if;
if(AD2Data = x“7FFF”) then
ADDataBuff2 《= ADDataBuff2;
else
ADDataBuff2 《= SIGNED(AD2Data);
end if;
if(AD3Data = x“7FFF”) then
ADDataBuff3 《= ADDataBuff3;
else
ADDataBuff3 《= SIGNED(AD3Data);
end if;
--ADDataBuff2 《= SIGNED(AD2Data);
--ADDataBuff3 《= SIGNED(AD3Data);
end if;
end process;
----------------------------------------------------------------------
-- 保护处理
-- -------------------------------------------------------------------
ERR_DELAY_PROC
《img smilie border=“0” al》
ROCESS(Clk,Reset)
BEGIN
IF Reset=‘0’ THEN
A_Err_Cnt《=(others=》‘0’);
A_Err_Flag_Buff 《= ‘0’;
B_Err_Cnt《=(others=》‘0’);
B_Err_Flag_Buff 《= ‘0’;
C_Err_Cnt《=(others=》‘0’);
C_Err_Flag_Buff 《= ‘0’;
ELSIF RISING_EDGE(Clk) THEN
if(( ADDataBuff1 》= ProtectParaUpper ) or ( ADDataBuff1 《= ProtectParaLow )) then --如果瞬时值大于门限值
A_Err_Cnt 《= A_Err_Cnt + 1;
if( A_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
A_Err_Flag_Buff 《= ‘1’; --故障置1
A_Err_Cnt 《= (others=》‘0’);
end if;
else
A_Err_Cnt 《= (others=》‘0’);
A_Err_Flag_Buff 《= ‘0’;
end if;
if(( ADDataBuff2 》= ProtectParaUpper ) or ( ADDataBuff2 《= ProtectParaLow )) then --如果瞬时值大于门限值
B_Err_Cnt 《= B_Err_Cnt + 1;
if( B_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
B_Err_Flag_Buff 《= ‘1’; --故障置1
B_Err_Cnt 《= (others=》‘0’);
end if;
else
B_Err_Cnt 《= (others=》‘0’);
B_Err_Flag_Buff 《= ‘0’;
end if;
if(( ADDataBuff3 》= ProtectParaUpper ) or ( ADDataBuff3 《= ProtectParaLow )) then --如果瞬时值大于门限值
C_Err_Cnt 《= C_Err_Cnt + 1;
if( C_Err_Cnt 》= 1500) then --共计1500 + 120 = 20us,前面检查用掉200
C_Err_Flag_Buff 《= ‘1’; --故障置1
C_Err_Cnt 《= (others=》‘0’);
end if;
else
C_Err_Cnt 《= (others=》‘0’);
C_Err_Flag_Buff 《= ‘0’;
end if;
END IF;
END PROCESS;
A_Fault_Flag 《= A_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
B_Fault_Flag 《= B_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
C_Fault_Flag 《= C_Err_Flag_Buff; -- 故障标志位,1表示发生了故障
END behave;
举报