一个入门者的问题(vhdl)
时间:10-02
整理:3721RD
点击:
今天试着做一个计数器/分频器,可代码写出来了,却出来了莫名其妙的错误,请前辈们指点一下!不是胜感激!
代码:
----------------------------------------
PROCESS (clk)
VARIABLE temp :INTEGER RANGE 0 TO 31 := 0;
BEGIN
IF(temp = 7) THEN
q <= '1';
temp := 0;
END IF;
IF(clk'EVENT AND clk = '1') THEN
IF(temp = 1) THEN --q脉冲宽度为一个时钟周期
q <= '0';
END IF;
temp := temp+1;
END IF;
END PROCESS;
------------------------------
Error (10818): Netlist error at tes1.vhd(18): can't infer register for q because it does not hold its value outside the clock edge这里的18行指的是加下划线的那一行。
谢谢了!
代码:
----------------------------------------
PROCESS (clk)
VARIABLE temp :INTEGER RANGE 0 TO 31 := 0;
BEGIN
IF(temp = 7) THEN
q <= '1';
temp := 0;
END IF;
IF(clk'EVENT AND clk = '1') THEN
IF(temp = 1) THEN --q脉冲宽度为一个时钟周期
q <= '0';
END IF;
temp := temp+1;
END IF;
END PROCESS;
------------------------------
Error (10818): Netlist error at tes1.vhd(18): can't infer register for q because it does not hold its value outside the clock edge这里的18行指的是加下划线的那一行。
谢谢了!
我自己解决了!
PROCESS (clk)
VARIABLE temp :INTEGER RANGE 0 TO 31 := 0;
BEGIN
IF(clk'EVENT AND clk = '1') THEN
IF(temp = 7) THEN
q <= '1';
temp := 0;
END IF;
IF(temp = 1) THEN --q脉冲宽度为一个时钟周期
q <= '0';
END IF;
temp := temp+1;
END IF;
END PROCESS;
这个就对啦,因为敏感信号时clk,象先前那样写只要时钟信号变化进程就会调用,也就是下降沿是进程也会执行.