找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3976|回复: 0
打印 上一主题 下一主题
收起左侧

编程和绘制原理图完成数字电路设计

[复制链接]
跳转到指定楼层
楼主
ID:262 发表于 2014-10-17 18:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1.针对开发板晶振频率分频1H在脉冲
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Entity pinlv1Hz is
Port(clk:in std_logic;
     CP:OUT std_logic);
end;
Architecture dd of pinlv1Hz is
signal q:std_logic_vector(24 downto 0);
SIGNAL C:std_logic;
begin
process(clk)
  begin
    if clk'event and clk='1' then q<=q+1;
      if q=9999999 then q<="0000000000000000000000000";C<=not C;
    end if;
end if;
end process;
CP<=C;
end;
综合无误后点file--creat/Update/Creat Symbol files for  current file生成元件符号
2.编辑60s计数器
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Entity court60 is
Port(clk:in std_logic;
     q:out std_logic_vector(6 downto 0));
end;
Architecture dd of court60 is
signal qq:std_logic_vector(6 downto 0);
begin
process(clk)
  begin
    if clk'event and clk='1' then qq<=qq+1;
      if qq=59 then qq<="0000000";
    end if;
end if;
end process;
q<=qq;
end;
综合无误后点file--creat/Update/Creat Symbol files for  current file生成元件符号
3。创造一个除法器宏模块
创造一个除法器宏模块完成60进制分各位十进制,是为6进制
4。编辑一个6位宽和四位宽总线变两个4单根线的程序输出程序
Library ieee;
Use ieee.std_logic_1164.all;
entity zx64 is
Port(q:in std_logic_vector(6 downto 0);
     qq:in std_logic_vector(3 downto 0);
   x0,x1,x2,x3:buffer std_logic;
     y0,y1,y2,y3:out std_logic);
end;
Architecture dd of zx64 is
begin
y0<=q(0);
y1<=q(1);
y2<=q(2);
y3<=q(3);
x0<=qq(0);
x1<=qq(1);
x2<=qq(2);
x3<=qq(3);
end;
综合无误后点file--creat/Update/Creat Symbol files for  current file生成元件符号
5.便两位分时现实程序
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Entity fenshi is
Port(clk,a0,a1,a2,a3,b0,b1,b2,b3:in std_logic;
     y0,y1,y2,y3,w0,w1:out std_logic);
end;
Architecture dd of fenshi is
signal q:std_logic_vector(7 downto 0);
begin
process(clk,a0,a1,a2,a3,b0,b1,b2,b3)
  begin
    if clk'event and clk='1' then q<=q+1;
  if q<128 then
      y0<=a0;y1<=a1;y2<=a2;y3<=a3;w0<='0';w1<='1';
  else
   y0<=b0;y1<=b1;y2<=b2;y3<=b3;w0<='1';w1<='0';
   end if;
   end if;
  end process;
end;
综合无误后点file--creat/Update/Creat Symbol files for  current file生成元件符号
6。编写一个7段显示码程序显示二进制位10进制
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
entity diaplay is
Port(q0,q1,q2,q3:in std_logic;
      y6,y5,y4,y3,y2,y1,y0:out std_logic);
end;
Architecture dzb of diaplay is
signal qq:std_logic_vector(3 downto 0);
signal  Q: std_logic_vector(6 downto 0);
begin
qq<=q3&q2&q1&q0;
----------------------------   
process(qq)
begin   
   case qq is
      when "0000"=>Q<="0000001";     --段码显示开发板共阳极,所以0显示,1不显示。
      when "0001"=>Q<="1001111" ;
      when "0010"=>Q<="0010010" ;
      when "0011"=>Q<="0000110" ;
      when "0100"=>Q<="1001100" ;
      when "0101"=>Q<="0100100" ;
      when "0110"=>Q<="0100000" ;
      when "0111"=>Q<="0001111" ;
      when "1000"=>Q<="0000000" ;
      when "1001"=>Q<="0000100" ;
      when others=>null;
      end case;
     end process;
  y6<=q(6);y5<=q(5);y4<=q(4);y3<=q(3);y2<=q(2);y1<=q(1);y0<=q(0);
end;
综合无误后点file--creat/Update/Creat Symbol files for  current file生成元件符号。
注意:以上编写如果用两位直接组合成四位二进制计数器,则无需用除法器。其他模块也根据个人习惯可以不同。
7.建立原理图文件
画图链接电路,在综合无误后,与开发板管脚对应相连,再综合无误后即可仿真。
注意:硬件仿真时,对于不用的管脚要设置成三态输出。
  


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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