永发信息网

用VHDL语言设计一个具有清零,使能,置数的4位二进制加减法计数器的源程序,谢谢

答案:2  悬赏:60  手机版
解决时间 2021-02-27 13:03
用VHDL语言设计一个具有清零,使能,置数的4位二进制加减法计数器的源程序,谢谢
最佳答案
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter4 is
port
(
clk : in std_logic;
load : in std_logic;
clr : in std_logic;
up_down: in std_logic;
DIN : in std_logic_vector(3 downto 0);
DOUT : out std_logic_vector(3 downto 0);
c : out std_logic
);
end counter4;

architecture rt1 of counter4 is
signal clk_1Hz:std_logic;
signal data_r:std_logic_vector(3 downto 0);
component frediv
port
(
clk :in std_logic;
clkout:out std_logic
);
end component;

begin
U1:frediv port map(clk,clk_1Hz);

DOUT <= data_r;
process(clk_1Hz,load,clr,up_down,DIN)
begin
if clr = '1' then
data_r <= "0000";
elsif load = '1' then
data_r <= DIN;
else if clk_1Hz'event and clk_1Hz = '1' then
if up_down = '1' then
if data_r = "1111" then
c <= '0';
data_r <= "0000";
else
data_r <= data_r + 1;
c<= '1';
end if;
else
if data_r = "0000" then
c <= '0';
data_r <= "1111";
else
data_r <= data_r - 1;
c<= '1';
end if;
end if;
end if;
end if;
end process;
end rt1;追问不对哦,有错误,看图追答LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter4 is
port
(
clk : in std_logic;
load : in std_logic;
clr : in std_logic;
up_down: in std_logic;
DIN : in std_logic_vector(3 downto 0);
DOUT : out std_logic_vector(3 downto 0);
c : out std_logic
);
end counter4;

architecture rt1 of counter4 is

signal data_r:std_logic_vector(3 downto 0);

begin

DOUT <= data_r;
process(clk,load,clr,up_down,DIN)
begin
if clr = '1' then
data_r <= "0000";
elsif load = '1' then
data_r <= DIN;
else if clk'event and clk = '1' then
if up_down = '1' then
if data_r = "1111" then
c <= '0';
data_r <= "0000";
else
data_r <= data_r + 1;
c<= '1';
end if;
else
if data_r = "0000" then
c <= '0';
data_r <= "1111";
else
data_r <= data_r - 1;
c<= '1';
end if;
end if;
end if;
end if;
end process;
end rt1;

之前写的,中间调用了一个子程序,忘了删了,现在好了。
全部回答
ffff
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
谁能教我说白话…我一点也不会…好想学到…一
曾经震惊世界的日本水俣病是由于人吃了被甲基
会计从业资格证取消有何意义
1.53 +46.8÷7.2,的梯等式计算
如何修改CAD捕捉系统变量osmode?
枣庄华润纸业有限公司地址在哪,我要去那里办
二氧化碳反流什么意思
多选题,下列属于销售费用的是( )A销售原材料
昨天买了一台长城s2219G液晶显示器,使用二个
哈尔滨哪有看胃病看的非常好的中医医院
朝天门哪个交易区在批发毛巾?
汽车启动马达都在什么位置
sr4-63005属于哪个国家的车牌
唱歌找不准点怎么办?就是唱歌听背景音完全对
解压游戏就会出现“循环冗余检查”请问怎么办
推荐资讯
西安长安东大到小寨公交路线?
我的酷派大神F2无法进入recover模式,有什么办
兔骑猴猴骑羊羊骑象的塑像是佛教的吗?寓意是
如何完全卸载删除360蓝屏修复补丁?
2017年学什么技术好
hfdy 是什么意思?????????
供养油灯是起酥油好还是香油好
请问是这什么电影?
海尔洗衣机xqb65-68出现e3 故障怎么修?
vivo手机怎样把歌曲传给好友
植物细胞中最常见的二糖和多糖分别是①乳糖和
新高一暑假学习计划表(详细但不要啰嗦)
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?