FPGA程序加法器.doc_第1页
FPGA程序加法器.doc_第2页
FPGA程序加法器.doc_第3页
FPGA程序加法器.doc_第4页
FPGA程序加法器.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

顶层设计程序library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity JIA is PORT(clockin: in std_logic; resetin:in std_logic; kbin : in std_logic_vector(3 downto 0); kbout : out std_logic_vector(2 downto 0); segment_out : out STD_LOGIC_VECTOR(6 downto 0); sweepout : out STD_LOGIC_VECTOR(3 downto 0); end JIA;architecture Behavioral of JIA is COMPONENT keyboard isport(clk,reset : in std_logic; kb_in : in std_logic_vector(3 downto 0); c,d: out std_logic_vector(3 downto 0); seg1,seg2 : out std_logic_vector(6 downto 0); swo,so: out std_logic; kb_out : out std_logic_vector(2 downto 0); END COMPONENT; COMPONENT add isport ( a,b: in std_logic_vector(3 downto 0); s1,s2: in std_logic;s: out std_logic_vector(4 downto 0); END COMPONENT;COMPONENT yima isport(Clock,reset : in std_logic; seg3,seg4 : out std_logic_vector(6 downto 0); sin: in std_logic_vector(4 downto 0); END COMPONENT;signal e,k: STD_LOGIC;signal f,g : std_logic_vector(3 downto 0);signal h : std_logic_vector(4 downto 0);signal segment_out1 : STD_LOGIC_VECTOR(6 downto 0);signal segment_out2 : STD_LOGIC_VECTOR(6 downto 0);signal segment_out3 : STD_LOGIC_VECTOR(6 downto 0);signal segment_out4 : STD_LOGIC_VECTOR(6 downto 0); type state_type is (z0,z1,z2,z3);signal state: state_type;signal div:std_logic_vector(26 downto 0):=(others=0);signal clk:std_logic; BEGIN process(clockin) begin if rising_edge(clockin) then div=79999 then div0);end if;if div=39999 thenclk=1;else clkstatestatestatestateclockin,kb_in=kbin,reset=resetin,c=f,d=g,swo=e,so=k,seg1=segment_out1, kb_out=kbout,seg2=segment_out2); u2: add PORT MAP(a=f,b=g,s=h,s1=k,s2=e); u3: yima PORT MAP(Clock=clockin,sin=h,reset=resetin,seg3=segment_out3,seg4=segment_out4); with state seLectsweepout=1110 when z0, 1101 when z1, 1011 when z2, 0111 when z3; with state seLectsegment_out 0);signal clkdiv:std_logic;signal kb_out_s:std_logic_vector(2 downto 0):=010;signal kb_in_s:std_logic_vector(3 downto 0):=0001;signal m,c1,d1 : std_logic_vector(3 downto 0):=0000;beginkb_out = not kb_out_s;kb_in_s = not kb_in ;c = c1 ;d = d1 ;process(clk) begin if rising_edge(clk) then div=div+1;end if;end process;clkdiv= div(14) ;process(clkdiv)begin if (clkdivevent and clkdiv=1) then kb_out_sm =0000;swo =0;so m =0001;swo =0;so m =0010;swo =0;so m =0011;swo =0;so m =0100;swo =0;so m =0101;swo =0;so m =0110;swo =0;so m =0111;swo =0;so m =1000;swo =0;so m =1001;swo =0;so swo =1; c1 so =1; d1 null; end case; end if; end process;process(clk)begin if(reset=0)then seg1 seg1 seg1 seg1 seg1 seg1 seg1 seg1 seg1 seg1 seg1 null; end case; end if; end process; process(clk)begin if(reset=0)then seg2 seg2 seg2 seg2 seg2 seg2 seg2 seg2 seg2 seg2 seg2 null; end case; end if; end process; end Behavioral;加法实现library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity add isport ( a,b: in std_logic_vector(3 downto 0); s1,s2: in std_logic;s: out std_logic_vector(4 downto 0);end entity;architecture Behavioral of add is signal aa,bb,ss:std_logic_vector(4 downto 0);beginaa=0& a;bb=0& b;process(aa,bb,s1,s2)begin if (s1=1 and s2=1) thenss= aa+bb; end if; s=ss;end process;end Behavioral;译码显示library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity yima isport(Clock,reset : in std_logic; seg3,seg4 : out std_logic_vector(6 downto 0); sin: in std_logic_vector(4 downto 0); end yima;architecture Behavioral of yima is beginprocess(Clock,sin) begin if(reset=0)then seg3 =1000000; seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1000000;seg4 seg3 =1111001;seg4 seg

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论