2013-06-06 6 views
0

이것은 내가 사용하고 있지만 열과 행이 어떻게 변하는지를보기 위해 시계를 늦추는 데 필요한 코드입니다.누군가가 5x7 도트 매트릭스 디스플레이에 대한 간단한 VHDL 코드 charachter "R"을 도울 수 있습니까?

library IEEE; 
use IEEE.STD_LOGIC_1164.all; 
use IEEE.STD_LOGIC_ARITH.all; 
use IEEE.STD_LOGIC_UNSIGNED.all; 

-- Uncomment the following library declaration if using 
-- arithmetic functions with Signed or Unsigned values 
--use IEEE.NUMERIC_STD.ALL; 

-- Uncomment the following library declaration if instantiating 
-- any Xilinx primitives in this code. 
--library UNISIM; 
--use UNISIM.VComponents.all; 

entity dot_matrix is 

    port (main_clk, en : in std_logic; 


     switches : in std_logic_vector (3 downto 0); 
     rows  : inout std_logic_vector (6 downto 0); 
     col  : inout std_logic_vector (4 downto 0)); 

end dot_matrix; 

architecture Behavioral of dot_matrix is 

    signal row_count : std_logic_vector(2 downto 0); 
    signal counter : integer range 0 to 25000000 := 0; -- to divide the clock down 
    signal slow_clock : std_logic     := '0'; 

begin 

    clockdiv1 : process(main_clk) 
    begin 
    if main_clk'event and main_clk = '1' then 
     if counter = 24999999 then 
     counter <= 0; 
     slow_clock <= not slow_clock; 
     else 
     counter <= counter + 1; 
     end if; 
    end if; 
    end process clockdiv1; 

    SM : process (slow_clock) 
    begin 
    if (slow_clock'event and slow_clock = '1') then 
     if (en = '1') then 
     if (row_count = "100") then 
      row_count <= "000"; 
     else 
      row_count <= row_count + 1; 
     end if; 
     else 
     row_count <= "000"; 
     end if; 
    end if; 
    end process SM; 



    DIS : process (row_count) 
    begin 

    if row_count = "000" then   --1st clock count 
     col <= "01111";     --selecting 1st column 
     rows <= "1111111";    -- putting the data on the 1st column 

    elsif row_count = "001" then  -- 2nd clock count 
     col <= "10111";     -- selecting 2nd column 
     rows <= "1001000"; 

     row_count = "010" then   -- 3rd clock count 
     col <= "11011";    -- selecting 3rd column 
     rows <= "1001100"; 

     elsif row_count = "011" then  -- 4th clock count 
     col <= "11101";    -- selecting 4th column 
     rows <= "1001010"; 

     elsif row_count = "100" then  -- 5th clock count 
     col <= "11110";    -- selecting 5th column 
     rows <= "0110001"; 

     -- 1 1 1 1 0 

     -- 1 0 0 0 1 

     -- 1 0 0 0 1 

     -- 1 1 1 1 0 

     -- 1 0 1 0 0 

     -- 1 0 0 1 0 

     -- 1 0 0 0 1 

     end if; 
    end process DIS; 

end Behavioral; 

편집 : 코드의 들여 쓰기를 수정 한 후 텍스트를 추가하는 데 필요한 내 클러킹에 대한 몇 가지 문제가있다 생각합니다. 이미 문제를 해결

row_count = "010" then 

어쩌면 라인에서 누락 된 "ELSIF는"이

답변

0

.

0

느린 시계에 초기 값 '0'을 사용하고 있습니다. 신디사이저 및 타겟 기술이 이것을 지원하는지 확인해야합니다. 일부 FPGA는 그렇지 않습니다. 또는 재설정 신호를 추가하고 재설정이 활성화 된 경우 값을 설정할 수 있습니다.

기타 의견 : youR.Fate으로

  • 는 말한다 : 당신은 당신의 코드에서 중간 elsif이 필요합니다.
  • IEEE.STD_LOGIC_ARITH 및 IEEE.STD_LOGIC_UNSIGNED는 사용하지 마십시오. 표준이 아닙니다. 대신 ieee.numeric_std를 사용하십시오. 더 많은 정보 : http://www.sigasi.com/content/deprecated-ieee-libraries
+0

elsif가 없어도 컴파일 될까요? 나는 그렇게 생각하지 않는다. 또한, umid_uz는 코드에서 작동하지 않는 것을 결코 언급하지 않았습니다. –

+0

아니요, 누락 된 elsif로 컴파일되지 않습니다. – Philippe