Daha fazla vaktim olsaydı aşağıdaki kodu seve anlatmayı isterdim ancak biraz acelem var
Umarım birilerinin ve gelecekteki benin işine yarar. Kolay gele!
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.std_logic_arith.all; use ieee.std_logic_signed.all; entity substractor is port(x, y: in std_logic_vector(3 downto 0); segments: out std_logic_vector(7 downto 0); DNout: out std_logic_vector(3 downto 0)); end substractor; architecture Behavioral of substractor is signal temp: std_logic_vector(3 downto 0); begin process(x, y) begin DNout <= "0111"; temp <= x - y; if(temp="0000") then segments <= "00000011"; elsif(temp="0001") then segments <= "10011111"; elsif(temp="0010") then segments <= "00100101"; elsif(temp="0011") then segments <= "00001101"; elsif(temp="0100") then segments <= "10011001"; elsif(temp="0101") then segments <= "01001001"; elsif(temp="0110") then segments <= "11000001"; elsif(temp="0111") then segments <= "00011111"; elsif(temp="1000") then segments <= "00000001"; elsif(temp="1001") then segments <= "00011001"; elsif(temp="1010") then segments <= "00010001"; elsif(temp="1011") then segments <= "11000001"; elsif(temp="1100") then segments <= "01100011"; elsif(temp="1101") then segments <= "10000101"; elsif(temp="1110") then segments <= "01100001"; elsif(temp="1111") then segments <= "01110001"; else segments <= "11111111"; end if; end process; end Behavioral;
Bu da .ucf dosyası.
#Pin assignment for slide switches NET "x(3)" LOC = "n3"; NET "x(2)" LOC = "e2"; NET "x(1)" LOC = "f3"; NET "x(0)" LOC = "g3"; NET "y(3)" LOC = "b4"; NET "y(2)" LOC = "k3"; NET "y(1)" LOC = "l3"; NET "y(0)" LOC = "p11"; #it seems m4 on the board but the correct one is p11. #Pin assignment for 7-segment displays NET "segments(7)" LOC = "l14" ; NET "segments(6)" LOC = "h12" ; NET "segments(5)" LOC = "n14" ; NET "segments(4)" LOC = "n11" ; NET "segments(3)" LOC = "p12" ; NET "segments(2)" LOC = "l13" ; NET "segments(1)" LOC = "m12" ; NET "segments(0)" LOC = "n13" ; NET "DNout(3)" LOC = "f12"; NET "DNout(2)" LOC = "j12"; NET "DNout(1)" LOC = "m13"; NET "DNout(0)" LOC = "k14";