VHDL时钟序列Q3

VHDL时钟序列Q3,vhdl,clock,led,Vhdl,Clock,Led,我必须创建一个VHDL序列,它只需要一个时钟输入,输出一个5LED序列 我是否正确地认为,使用std_逻辑_向量,我可以将每个向量输出连接到一个LED,以创建该序列,或者我没有解释std_逻辑_向量的使用 我使用的代码是 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

我必须创建一个VHDL序列,它只需要一个时钟输入,输出一个5LED序列 我是否正确地认为,使用std_逻辑_向量,我可以将每个向量输出连接到一个LED,以创建该序列,或者我没有解释std_逻辑_向量的使用

我使用的代码是

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; 
ieee库;
使用ieee.std_logic_1164.all;
使用ieee.std_logic_unsigned.all;
使用ieee.numeric_std.all;——我使用这个包作为我的CLK-CNT信号计数的整数格式,而不是二进制格式,我正在执行CLK_CNT的加法和
实体注册指示灯为
端口(时钟:在标准逻辑中--CLK输入
LED:输出标准逻辑向量(从4到0));--初始化输出
末端标记LED;
REG_LED的架构
信号时钟:整数范围0到9:=0;--用于计数时钟脉冲的初始比较信号。
--程序将使用该信号识别程序在序列中的位置,从而确定序列所需的下一个状态。
开始
CLK_进程:进程(CLK)——开始CLK_CNT进程
开始
如果上升沿(CLK),则
如果CLK_CNT=8,则

CLK_CNT您的代码看起来很好,如果您的模拟表明它按照您的需要运行,那么您几乎可以开始了

一个
std\u逻辑\u向量
实际上是一组导线(总线)。你必须考虑它的物理意义,因为这是当你编程一个FPGA时真正发生的事情。所以,是的,你可以把巴士分成几条线。可以这样做:

signal LED_LINE_0 : std_logic;
signal LED_LINE_1 : std_logic;
LED_LINE_0 <= LEDS(0);
LED_LINE_1 <= LEDS(1);
信号LED\u线\u 0:std\u逻辑;
信号LED_线_1:标准逻辑;

LED_LINE_0如果将一个LED连接到端口的每一位,它将驱动5个LED。感谢您的反馈,这是我的学位课程,因此我实际上不会为此编程fpga,但我想展示正确的步骤。我将把代码放在哪里来拆分总线?在实体声明中还是在模型的体系结构主体中?我的讲师在这门课上对我们帮助不大,只是给了我们一本书,并说了一些关于实体和架构功能的基本想法。vhdl文件指定了一个“框”,其中实体部分告诉您框内和框外的内容(以及框内使用的内容),而体系结构部分指定框内的体系结构(事物如何连接)。
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);