📄 ps2_caculator_vhdl.vhd
字号:
end process; process(clkin) begin if (clkin'event and clkin='1') then if rst='1' then ok1<='0'; ok2<='0'; ok3<='0'; ok4<='0'; else if b="0001" then ok1<='1'; ok2<='0'; ok3<='0'; ok4<='0'; elsif b="0010" then ok1<='0'; ok2<='1'; ok3<='0'; ok4<='0'; elsif b="0100" then ok1<='0'; ok2<='0'; ok3<='1'; ok4<='0'; elsif b="1000" then ok1<='0'; ok2<='0'; ok3<='0'; ok4<='1'; end if; end if; end if; end process; sum_value<=value1+value2+value3+value4; process(clkin) begin if (clkin'event and clkin='1') then if rst='1' then num1<="00010001"; else case res1_std(7 downto 0) is when "00000000"=>num1<="00010001" ; when "00000001"=>num1<="11010111" ; when "00000010"=>num1<="00110010" ; when "00000011"=>num1<="10010010" ; when "00000100"=>num1<="11010100" ; when "00000101"=>num1<="10011000" ; when "00000110"=>num1<="00011000" ; when "00000111"=>num1<="11010011" ; when "00001000"=>num1<="00010000" ; when "00001001"=>num1<="10010000" ; when others =>num1<="00010001"; end case; end if; end if;end process; -- num1<="00010001" when res1_std(7 downto 0)="00000000" else-- "11010111" when res1_std(7 downto 0)="00000001" else-- "00110010" when res1_std(7 downto 0)="00000010" else-- "10010010" when res1_std(7 downto 0)="00000011" else-- "11010100" when res1_std(7 downto 0)="00000100" else-- "10011000" when res1_std(7 downto 0)="00000101" else-- "00011000" when res1_std(7 downto 0)="00000110" else-- "11010011" when res1_std(7 downto 0)="00000111" else-- "00010000" when res1_std(7 downto 0)="00001000" else-- "10010000" when res1_std(7 downto 0)="00001001" else-- "00010001";-- num2<="00010001" when res2_std(7 downto 0)="00000000" else-- "11010111" when res2_std(7 downto 0)="00000001" else-- "00110010" when res2_std(7 downto 0)="00000010" else-- "10010010" when res2_std(7 downto 0)="00000011" else-- "11010100" when res2_std(7 downto 0)="00000100" else-- "10011000" when res2_std(7 downto 0)="00000101" else-- "00011000" when res2_std(7 downto 0)="00000110" else-- "11010011" when res2_std(7 downto 0)="00000111" else-- "00010000" when res2_std(7 downto 0)="00001000" else-- "10010000" when res2_std(7 downto 0)="00001001" else-- "00010001";process(clkin) begin if (clkin'event and clkin='1') then if rst='1' then num2<="00010001"; else case res2_std(7 downto 0) is when "00000000"=>num2<="00010001" ; when "00000001"=>num2<="11010111" ; when "00000010"=>num2<="00110010" ; when "00000011"=>num2<="10010010" ; when "00000100"=>num2<="11010100" ; when "00000101"=>num2<="10011000" ; when "00000110"=>num2<="00011000" ; when "00000111"=>num2<="11010011" ; when "00001000"=>num2<="00010000" ; when "00001001"=>num2<="10010000" ; when others =>num2<="00010001"; end case; end if; end if;end process;-- process(clkin)-- begin-- if (clkin'event and clkin='1') then-- if rst='1' then-- SecSeg1<="00010001";-- -- else-- if m(7 downto 0)= "01010101" or m(7 downto 0)="01001110" or m(7 downto 0)="01010100" or m(7 downto 0)= 01011011 then-- -- SecSeg1<="11111111";-- -- elsif ok='1' then -- --var<="0000000000001010"; -- SecSeg1<=num1; -- -- result_begin_std<=conv_std_logic_vector(result_end,16);-- -- SecSeg1<=conv_std_logic_vector(result_end,8); -- -- SecSeg1<=conv_std_logic_vector(result,8);-- elsif ok1='1' then-- SecSeg1<=num;-- value1<=value;-- end if;-- end if;-- end if;-- end process; process(clkin) begin if (clkin'event and clkin='1') then if rst='1' then SecSeg1<="00010001"; SecSeg2<="00010001"; SecSeg3<="00010001"; SecSeg4<="00010001"; else if m(7 downto 0)= "01010101" or m(7 downto 0)="01001110" or m(7 downto 0)="01010100" or m(7 downto 0)= 01011011 then SecSeg1<="11111111"; SecSeg2<="11111111"; SecSeg3<="11111111"; SecSeg4<="11111111"; elsif ok='1' then SecSeg1<=num1; if result_end>=10 then SecSeg2<=num2; if result_end>=100 then SecSeg3<=num2; if result_end>=1000 then SecSeg4<=num2; else SecSeg4<="00010001"; end if; else SecSeg3<="00010001"; end if; else SecSeg2<="00010001"; end if; result_begin_std<=result_end; elsif ok1='1' then SecSeg1<=num; value1<=value; elsif ok2='1' then SecSeg2<=num; value2<=value * "0000000000001010"; elsif ok3='1' then SecSeg3<=num; value3<=value * "0000000000001010"; elsif ok4='1' then SecSeg4<=num; value4<=value *"0000001111101000"; end if; end if; end if; end process; -- process(clkin)-- begin-- if (clkin'event and clkin='1') then-- if rst='1' then-- SecSeg3<="00010001";-- else-- if m(7 downto 0)= "01010101" or m(7 downto 0)="01001110" or m(7 downto 0)="01010100" or m(7 downto 0)= 01011011 then-- -- SecSeg3<="11111111";---- elsif ok='1' then ---- if result_end>=100 then---- SecSeg3<=num2;---- result_begin_std<=conv_std_logic_vector(result_end,16);---- else---- SecSeg3<="00010001";---- end if;-- elsif ok3='1' then -- -- SecSeg3<=num;-- value3<=value * 100;-- end if;-- end if;-- end if;-- end process;-- -- process(clkin)-- begin-- if (clkin'event and clkin='1') then-- if rst='1' then-- SecSeg4<="00010001";-- else-- if m(7 downto 0)= "01010101" or m(7 downto 0)="01001110" or m(7 downto 0)="01010100" or m(7 downto 0)= 01011011 then-- -- SecSeg4<="11111111";---- elsif ok='1' then---- -- var<="0000001111101000";---- if result_end>=1000 then---- SecSeg4<=num2;---- result_begin_std<=conv_std_logic_vector(result_end,16);---- else---- SecSeg4<="00010001";---- end if;-- -- elsif ok4='1' then-- SecSeg4<=num;-- value4<=value * 1000;-- end if;-- end if;-- end if;-- end process; process(clkin) begin if (clkin'event and clkin='1') then scan<=scan+1; end if; end process; scan_clk<=scan(18 downto 17); process(scan_clk) begin case scan_clk is when "00"=> led<=SecSeg1; var<="0000000000001010"; a<="0001"; when "01"=> var<="0000000000001010"; led<=SecSeg2; a<="0010"; when "10"=> var<="0000000001100100"; led<=SecSeg3; a<="0100"; when others=> var<="0000001111101000"; led<=SecSeg4; a<="1000"; end case; end process; en<='0';end one;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -