集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1039|回复: 0

程序错误

[复制链接]
冉正国 发表于 2011-10-10 22:10:17 | 显示全部楼层 |阅读模式
大家帮忙看看下面的程序,有错误,帮忙改改,万分感谢
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity mycounter_60 is
    port(clk,clr,en,bcd1wr,bcd10wr:in std_logic;
         din:in std_logic_vector(3 downto 0);
         bcd1: out std_logic_vector(3 downto 0);
         co: out std_logic;
         bcd10: out std_logic_vector(2 downto 0));
end mycounter_60;

architecture art2 of mycounter_60 is
signal bcd1n:std_logic_vector(3 downto 0);
signal bcd10n:std_logic_vector(2 downto 0);
begin
    PROCESS(clk,clr,en,bcd1wr) is
    begin
        if(clr='0') then
            bcd1n<=(others=>'0');
            bcd10n<=(others=>'0');
        elsif(clk'event and clk='1') then
            if(bcd1wr='1' and en='1') then
                bcd1n<=din;
            elsif(en='1') then
                bcd1n<=bcd1n+1;
                if(bcd1n>=9) then
                    bcd1n<="0000";
                end if;
            end if;
        end if;
    end process;
   
    process(bcd10wr,en,bcd1n) is
    begin
        if(bcd10wr='1' and en='1') then
            bcd10n<=din(2 downto 0);
        elsif(bcd1n=9 and en='1') then
            bcd10n<=bcd10n+1;
            if(bcd10n=5) then
                bcd10n<="000";
                co<='1';
            else
                co<='0';
            end if;
        end if;
    end process;
   
    bcd1<=bcd1n;
    bcd10<=bcd10n;
end art2;
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-4-29 11:49 , Processed in 0.064063 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表