2016-10-26 3 views
1

VHDL 시퀀스를 만들어야합니다. 그저 시계 입력 만 받아 들여 5 개의 LED 시퀀스를 넣으십시오. see picture std_logic_vector를 사용하면 각 벡터 출력을 다음과 같은 단일 LED에 연결할 수 있습니다. 이 시퀀스를 만들거나 std_logic_vector의 사용을 해석하지 못합니까?VHDL CLOCK SEQUENCE Q3

제가 사용한 코드 나 파형 시뮬레이션 한

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.std_logic_unsigned.all; 
use ieee.numeric_std.all; -- i have used this package as my CLK-CNT signal counts in integer format rather than binary and i am performing an ADD sum of the CLK_CNT 


entity REG_LED is 
PORT(CLK:  IN std_logic;    -- CLK input 
    LEDS:  Out std_logic_vector (4 downto 0)); -- initialise output 
End REG_LED; 

ARCHITECTURE behavioral OF REG_LED IS 
SIGNAL CLK_CNT:  integer range 0 to 9:= 0; -- initailise comparison signal used for counting clock pulses. 
-- This signal will be used by the program to recognise where in the sequnce the program is and thus determine the next state required for the sequence. 
BEGIN 

    CLK_Process: PROCESS (CLK) -- begin the CLK_CNT Process 
    BEGIN 

    if rising_edge(CLK) Then 
     if CLK_CNT = 8 then 
      CLK_CNT <= 0; -- this resets the clock pulse count to 0 
     else 
      CLK_CNT <= CLK_CNT + 1 ; -- used to count each clock pulse upto the reset 
     End if; 
-- this process has been kept seperate to the LED output process in order to isolate the event from the output process and limit the possiblities of errors   
    END IF; 

    END PROCESS ; 

    LED_PROCESS: Process (CLK_CNT) -- LED Outputs based on Temp count 

    BEGIN -- begin the output sequence 

     Case CLK_CNT is 
-- i use a case statement to compare the value of the CLK_CNT signal and produce the required LEDS output 
-- this ensures the 
      When 0 => 
       LEDS <= "11111"; -- S0 when clock count is 0 
      When 1 => 
       LEDS <= "00001"; -- S1 when clock count is 1 
      When 2 =>  
       LEDS <= "00001"; -- S2 when clock count is 2 
      When 3 => 
       LEDS <= "11111"; -- S3 when clock count is 3 
      When 4 => 
       LEDS <= "00000"; -- S4 when clock count is 4 
      When 5 => 
       LEDS <= "11111"; -- S5 when clock count is 5 
      When 6 => 
       LEDS <= "00100"; -- S6 when clock count is 6 
      When 7 => 
       LEDS <= "01010"; -- S7 when clock count is 7 
      When 8 => 
       LEDS <= "10001"; -- S8 when clock count is 8 this is the final clock count state 

      When others => 
       LEDS <= "11111"; -- Restart Sequence 

     End Case;    

    End Process; 
END behavioral; 

이며 시퀀스가 ​​필요하지만,이 출력은 5 개 가지 LED를 구동하는 인터럽트하거나 단지 5되는 바와 같이 5 개 개의 출력을 생성 하나의 포트에서 출력되는 비트 워드? VHDL에 새로운 것이므로 아무 도움도 받으실 수 있습니다.

+0

하나의 LED를 포트의 각 비트에 연결하면 5 개의 LED가 켜집니다. –

답변

1

코드가 잘 보이고 시뮬레이션에 필요한 기능에 따라 작동한다고 표시되면 거의 유용합니다.

std_logic_vector은 실제로 많은 수의 버스 (버스)입니다. 물리적으로 무엇을 의미하는지 생각해야합니다. FPGA를 프로그래밍 할 때 실제로 일어나는 일이기 때문입니다. 예, 버스를 개별 라인으로 분리 할 수 ​​있습니다. 이는 다음과 같이 수행 할 수 있습니다.

signal LED_LINE_0 : std_logic; 
signal LED_LINE_1 : std_logic; 
LED_LINE_0 <= LEDS(0); 
LED_LINE_1 <= LEDS(1); 

... 등등. 이것은 한 번에 하나의 전선을 찢어 버립니다. 한 번에 여러 개의 와이어를 추출하여 버스를 더 작은 버스로 분할 할 수도 있습니다. 예 :

signal small_bus_1 : std_logic_vector(1 downto 0); 
signal small_bus_2 : std_logic_vector(1 downto 0); 
signal big_bus : std_logic_vector(3 downto 0); 

small_bus_1 <= big_bus(3 downto 2); 
small_bus_2 <= big_bus(1 downto 0); 

그런 다음 제약 파일에 쓰기 (또는 FPGA 브랜드의 IDE의 GUI를 사용하는) 당신이에 할당 할이 std_logic의 각을하고자하는 FPGA에있는 핀 지정 (드라이브가 있습니다 당신이 필요로하는 LED).

+0

의견을 보내 주셔서 감사합니다, 이것은 내 학위 코스웍을위한 것입니다. 그래서 나는 실제로 올바른 단계를 보여주고 싶지만 프로그래밍을하지는 않을 것입니다. 버스를 나누기 위해 어디에서 코드를 넣을 것입니까? 엔티티 선언 또는 모델의 아키텍처 본문에서? 내 강사 정말이 주제에 우리에게 많은 도움이되지 않았다 그냥 우리에게 책을 준 기본적으로 균열 말했다 –

+0

엔티티 및 아키텍처 기능에 대해 생각하십시오. vhdl 파일은 엔티티 부분이 상자 안팎으로 무엇이 들어가는 지 알려주고 상자에서 사용되는 내용을 알려주는 "상자"를 지정하는 반면 아키텍처 부분은 상자 내부의 구조 (사물이 연결되는 방식)를 지정합니다. – Wizongod