在一本书上看到这样一段代码:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY Manchester_encoder IS
PORT(D:IN STD_LOGIC;
Q:OUT STD_LOGIC;
CLK:IN STD_LOGIC);
END Manchester_encoder;
ARCHITECTURE basic OF Manchester_encoder IS
SIGNAL lastd : STD_LOGIC :='0';
BEGIN
P1ROCESS(CLK)
BEGIN
IF RISING_EDGE(CLK) THEN
IF (D='0') THEN
Q<='1';
lastd<='1';
ELSIF(D='1') THEN
Q<='0';
lastd<='1';
ELSE
Q<='X';
lastd<='X';
END IF;
ELSIF FALLING_EDGE(CLK) THEN
IF(lastd='0') THEN
Q<='0';
ELSIF(lastd='1') THEN
Q<='1';
ELSE
Q<='X';
END IF;
END IF;
END PROCESS;
END basic;
自己就在Qutuas 上编译了一下,但是通不过,显示
Error (10818): Can't infer register for "Q" at Manchester_encoder.vhd(13) because it does not hold its value outside the clock edge 请问有没有解决的方法,就是同时检测CLK的上升沿和下降沿并在这两种情况下对Q赋值?先谢谢大家。