em viết chương trình điều khiển DC bước bằng VHDL, nhưng thầy nói lý luận chưa chặt chẽ nên không chạy được, mong các anh góp ý dùm em với
[SIZE="2"]
entity QUAYT_N is
Port ( CLK : in STD_LOGIC;
STAR : in STD_LOGIC;
STOP : in STD_LOGIC;
DAO : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (3 downto 0));
end QUAYT_N;
architecture Behavioral of QUAYT_N is
SIGNAL QT:STD_LOGIC_VECTOR (3 downto 0);
begin
PROCESS (STAR,STOP,CLK,DAO)
VARIABLE DEM:INTEGER RANGE 0 TO 8;
BEGIN
IF STOP='1' THEN QT<="0011";
ELSIF CLK='1' AND CLK'EVENT THEN
IF STAR='1' THEN QT<= QT(2 DOWNTO 0) & QT(3);DEM:=DEM+1;
IF DEM =1 THEN QT<= "0011";
ELSIF DAO='1' THEN QT<= QT(0) & QT(3 DOWNTO 1);DEM:=DEM+1;
IF DEM=0 THEN QT<="0011";
END IF;
END IF;
END IF;
Q<=QT;
END IF;
END PROCESS;
end Behavioral;[/SIZE]
[SIZE="2"]
entity QUAYT_N is
Port ( CLK : in STD_LOGIC;
STAR : in STD_LOGIC;
STOP : in STD_LOGIC;
DAO : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (3 downto 0));
end QUAYT_N;
architecture Behavioral of QUAYT_N is
SIGNAL QT:STD_LOGIC_VECTOR (3 downto 0);
begin
PROCESS (STAR,STOP,CLK,DAO)
VARIABLE DEM:INTEGER RANGE 0 TO 8;
BEGIN
IF STOP='1' THEN QT<="0011";
ELSIF CLK='1' AND CLK'EVENT THEN
IF STAR='1' THEN QT<= QT(2 DOWNTO 0) & QT(3);DEM:=DEM+1;
IF DEM =1 THEN QT<= "0011";
ELSIF DAO='1' THEN QT<= QT(0) & QT(3 DOWNTO 1);DEM:=DEM+1;
IF DEM=0 THEN QT<="0011";
END IF;
END IF;
END IF;
Q<=QT;
END IF;
END PROCESS;
end Behavioral;[/SIZE]
Comment