简易计算器eda技术课程设计内容摘要:

keys IS PORT ( clk : IN STD_LOGIC。 rst : IN STD_LOGIC。 row : IN STD_LOGIC_VECTOR(3 downto 0)。 col : OUT STD_LOGIC_VECTOR(3 downto 0)。 scancode : OUT STD_LOGIC_VECTOR(15 downto 0) )。 END keys。 ARCHITECTURE keys_architecture OF keys IS signal current_state,next_state:std_logic_vector(1 downto 0)。 signal enable:std_logic。 BEGIN process(clk,rst,enable) begin if rst=39。 139。 then current_state=00。 . . elsif clk39。 event and clk=39。 139。 and enable=39。 039。 then current_state=next_state。 end if。 end process。 process(rst,current_state,row) begin if rst=39。 139。 then col=1111。 else case current_state is when 00 = col=1110。 next_state=01。 when 01 = col=1101。 next_state=10。 when 10 = col=1011。 next_state=11。 when 11 = col=0111。 next_state=00。 when others=col=1111。 next_state=00。 end case。 end if。 end process。 . . process(current_state,row) begin if rst=39。 139。 then scancode=X0000。 enable=39。 039。 elsif current_state=00 then case row is when 1110=scancode=X0001。 enable=39。 139。 when 1101=scancode=X0002。 enable=39。 139。 when 1011=scancode=X0004。 enable=39。 139。 when 0111=scancode=X0008。 enable=39。 139。 when others=scancode=X0000。 enable=39。 039。 end case。 elsif current_state=01 then case row is when 1110=scancode=X0010。 enable=39。 139。 when 1101=scancode=X0020。 enable=39。 139。 when 1011=scancode=X0040。 enable=39。 139。 when 0111=scancode=X0080。 enable=39。 139。 when others=scancode=X0000。 enable=39。 039。 end case。 elsif current_state=01 then case row is when 1110=scancode=X0100。 enable=39。 139。 when 1101=scancode=X0200。 enable=39。 139。 when 1011=scancode=X0400。 enable=39。 139。 when 0111=scancode=X0800。 enable=39。 139。 . . when others=scancode=X0000。 enable=39。 039。 end case。 else case row is when 1110=scancode=X1000。 enable=39。 139。 when 1101=scancode=X2020。 enable=39。 139。 when 1011=scancode=X4000。 enable=39。 139。 when 0111=scancode=X8000。 enable=39。 139。 when others=scancode=X0000。 enable=39。 039。 end case。 end if。 end process。 END keys_architecture。 去抖模块程序 LIBRARY ieee。 USE。 ENTITY filter IS PORT ( clk : IN STD_LOGIC。 rst : IN STD_LOGIC。 scancode : IN STD_LOGIC_VECTOR(15 downto 0)。 sc : OUT STD_LOGIC_VECTOR(15 downto 0) )。 . . END filter。 ARCHITECTURE filter_architecture OF filter IS signal count: integer range 0 to 100001。 signal temp: STD_LOGIC_VECTOR(15 downto 0)。 constant G1:integer :=100。 BEGIN process(clk,rst,scancode) begin if rst=39。 139。 then count=0。 elsif clk39。 event and clk=39。 139。 then if scancode=X0000 then count=0。 elsif countG1 then count=count+1。 end if。 end if。 end process。 process(rst,count,scancode) begin if rst=39。 139。 then sc=X0000。 temp=X0000。 else case count is when 0= temp=scancode。 . . when G1= if temp = scancode then sc=temp。 else sc=X0000。 end if。 when others=sc=X0000。 end case。 end if。 end process。 END filter_architecture。 ALU 模块程序 LIBRARY ieee。 USE。 USE。 USE。 ENTITY AUL IS PORT ( op1_in : IN STD_LOGIC_VECTOR(27 downto 0)。 op2_in : IN STD_LOGIC_VECTOR(27 downto 0)。 oprand:IN STD_LOGIC_VECTOR(2 downto 0)。 AUL_OUT : OUT STD_LOGIC_VECTOR(27 downto 0) )。 . . END AUL。 ARCHITECTURE AUL_architecture OF AUL IS BEGIN process(oprand,op1_in,op2_in) variable temp,temp1,temp2 : STD_LOGIC_VECTOR(27 downto 0)。 variable t1,t2:integer range 0 to 268435455。 variable t3:integer range 0 to 268435455。 begin case oprand is when 000 = AUL_OUT=op1_in。 when 001 = temp1:=op1_in。 temp2:=op2_in。 temp:=temp1+temp2。 AUL_OUT=temp。 when 010 = t1:=conv_integer(op1_in)。 t2:=conv_integer(op2_in)。 if t2=t1 then t3:=t2t1。 AUL_OUT=conv_STD_LOGIC_VECTOR(t3,28)。 else AUL_OUT=X8888888。 end if。 . . when 011 = t1:=conv_integer(op1_in)。 t2:=conv_integer(op2_in)。 t3:=t1*t2。 if t3=99999999 then AUL_OUT=conv_STD_LOGIC_VECTOR(t3,28)。 else AUL_OUT=X8888888。 end if。 when 100 = t1:=conv_integer(op1_in)。 t2:=conv_integer(op2_in)。 if t2=0 then AUL_OUT=X8888888。 else t3:=t2/t1。 AUL_OUT=conv_STD_LOGIC_VECTOR(t3,28)。 end if。 when others = AUL_OUT=op1_in。 end case。 end process。 END AUL_architecture。 FSM 模块程序 LIBRARY ieee。 USE。 ENTITY FSM IS PORT ( . . clk : IN STD_LOGIC。 rst : IN STD_LOGIC。 sc : IN STD_LOGIC_VECTOR(15 downto 0)。 op1_add : OUT STD_LOGIC。 op1_clear : OUT STD_LOGIC。 op1_load : OUT STD_LOGIC。 op2_load : OUT STD_LOGIC。 oprand : OUT STD_LOGIC_VECTOR(2 downto 0) )。 END FSM。 ARCHITECTURE FSM_architecture OF FSM IS signal current_state,next_state:STD_LOGIC_VECTOR(2 downto 0):=000。 signal key,number:STD_LOGIC。 signal operate:STD_LOGIC:=39。 039。 signal temp0,temp1:STD_LOGIC_VECTOR(2 downto 0):=000。 BEGIN process(sc) begin case sc is when X0000 =key=39。 039。 number=39。 039。 when X0001 =key=39。 139。 number=39。 039。 / when X0002 =key=39。 139。 number=39。 039。 X when X0004 =key=39。 139。 number=39。 039。 . . w。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。