求助 三分频程序出错

2019-07-16 01:58发布

初学FPGA,自己编写了一个三分频程序,有错,代码如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity divclk3 is
    port(inclk : in std_logic;
         outclk : out std_logic);
end divclk3;

architecture one of divclk3 is
    signal tmp : std_logic;
    signal rise_cnt : std_logic_vector(1 downto 0) := "00";
    signal down_cnt : std_logic_vector(1 downto 0) := "00";
    signal cnt : std_logic_vector(1 downto 0) := "00";
begin

    process(inclk)
    begin
        if(inclk'event and inclk = '1') then
            rise_cnt <= rise_cnt + 1;
        end if;
    end process;
   
    process(inclk)
    begin
        if(inclk'event and inclk = '0') then
            down_cnt <= down_cnt + 1;
        end if;
    end process;
   
    process(rise_cnt, down_cnt)
    begin
        cnt <= rise_cnt + down_cnt;
        if(cnt="11") then
            tmp <= not tmp;
            rise_cnt <= "00";
            down_cnt <= "00";
        end if;
    end process;
    outclk <= tmp;
end one;

编译出错,提示为:
Error (10028): Can't resolve multiple constant drivers for net "rise_cnt[1]" at divclk3.vhd(19)
Error (10029): Constant driver at divclk3.vhd(31)
Error (10028): Can't resolve multiple constant drivers for net "rise_cnt[0]" at divclk3.vhd(19)
Error (10028): Can't resolve multiple constant drivers for net "down_cnt[1]" at divclk3.vhd(26)
Error (10028): Can't resolve multiple constant drivers for net "down_cnt[0]" at divclk3.vhd(26)
Error: Can't elaborate user hierarchy "divclk3:inst6"
Error: Quartus II Analysis & Synthesis was unsuccessful. 6 errors, 9 warnings
Error: Peak virtual memory: 240 megabytes
Error: Processing ended: Thu Nov 29 22:37:56 2012
Error: Elapsed time: 00:00:05
Error: Total CPU time (on all processors): 00:00:02
Error: Quartus II Full Compilation was unsuccessful. 8 errors, 9 warnings

自己想了半天,实在是不知问题所在,望各位指点,感激不尽!


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
ytphrx
1楼-- · 2019-07-16 06:21
本帖最后由 ytphrx 于 2012-12-4 15:09 编辑

這個程序如果能跑,輸出的結果大概也是二分頻。或者試驗一下把計數器數據類型進行強制轉化為整數,因為好象VHDL規定加法操作符必的操作數必須是整數的啊。
ytphrx
2楼-- · 2019-07-16 08:22
本帖最后由 ytphrx 于 2012-12-4 15:08 编辑

奇數分頻
ytphrx
3楼-- · 2019-07-16 11:28
+法重载操作符好象只能是同一类型的相加,down_cnt + 1;表示一个是std_logic_vector类型,1这个数字却是整数类型.

一周热门 更多>