【问题标题】:VHDL - Scrolling Text on 7 segment DisplayVHDL - 在 7 段显示器上滚动文本
【发布时间】:2012-12-13 21:39:52
【问题描述】:

我的项目即将结束,但在某个时候卡住了。我无法解决问题

在确定 VHDL 很难移动数组的索引后,我决定更改我的移位器模块。现在它可以正确编译,RTL 原理图似乎是正确的,但不幸的是,我使用了一种相当非创新的方式来移动扫描码。

我定义了一个 64 位 std_logic_vector,它最多可以容纳 8 个扫描码,然后解析该向量的 4 个 MSBmost 字节,并将它们定向到七段控制器,该控制器对输入进行多路复用并决定将启用哪七段。我在想我的时钟有问题,但在显示屏上看不到任何东西让我认为设备的某些部分出现故障。我确信我的键盘控制器工作正常,因为我单独尝试过,移位器看起来也很好(我也在 FPGA 上尝试过这个,但没有减慢时钟,但是我仍然能够看到我输入的最后一个扫描码),我还没有想过尝试 7 段控制器的任何方式/方法,但这似乎也很好。我不知道问题是什么,文本没有滚动:(

Shifter.vhd

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.numeric_std.all;

entity my_shifter is
        port(clk      : in  std_logic;
                Scan_Dav : in  std_logic;
                Data_in  : in  std_logic_vector (7 downto 0);
                O1 : out std_logic_vector(7 downto 0);
                O2 : out std_logic_vector(7 downto 0);
                O3 : out std_logic_vector(7 downto 0);
                O4 : out std_logic_vector(7 downto 0)
                );
end my_shifter;

architecture bhv of my_shifter is

signal bytes : std_logic_vector(63 downto 0);
begin
    process (clk) begin
        if rising_edge(clk) then
                if Scan_Dav = '1' then
                    bytes <= bytes (bytes'high-8 downto 0) & Data_in;
                end if;
          end if;
    end process;
     O1 <= bytes(63 downto 56);
     O2 <= bytes(55 downto 48);
     O3 <= bytes(47 downto 40);
     O4 <= bytes(39 downto 32);
end bhv;

clkdivide.vhd

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

entity clkdivide is
    Port (clkin: in std_logic;
            clkout:out std_logic );
end clkdivide;

architecture Behavioral of clkdivide is
    signal int_clock:std_logic;
    begin
        clkout<=int_clock;
    process(clkin)
        variable var:integer range 0 to 12500 :=0;
        begin
            if (clkin'event and clkin = '1') then
                if var = 12500 then
                    int_clock <= not int_clock; 
                    var:=0;
                else 
                    var:=var+1;
                end if;
            end if;
    end process;
end Behavioral;

SevenSegmentControl.vhd:

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

entity SevenSegmentController is
    port (
        CLK: in std_logic;
        DEC1, DEC2, DEC3, DEC4: in std_logic_vector(7 downto 0);
        SEGMENTS: out std_logic_vector(6 downto 0);
        ANODES: out std_logic_vector(3 downto 0)
    );
end SevenSegmentController;

architecture Behavioral of SevenSegmentController is
   signal DecoderInput: std_logic_vector(7 downto 0);
    signal CurrentDisplay: std_logic_vector(1 downto 0) := "00";
    signal Prescaler: std_logic_vector(15 downto 0) := (others => '0');
begin

    Multiplex: process(CLK)
    begin
        if rising_edge(CLK) then
            if Prescaler(15) = '0' then
                Prescaler <= Prescaler + 1;
            else
                CurrentDisplay <= CurrentDisplay + 1;
                Prescaler <= (others => '0');
            end if;
        end if;
    end process Multiplex;

    SevenSegmentDecoder: entity work.SevenSegment_Decoder(Behavioral)
        generic map ( INVERT_OUTPUT => '1' )
        port map ( number => DecoderInput, segment => SEGMENTS );   

    DecoderInput <= DEC1 when CurrentDisplay = "00" else
                        DEC2 when CurrentDisplay = "01" else
                         DEC3 when CurrentDisplay = "10" else
                         DEC4 when CurrentDisplay = "11";

   ANODES <= "0111" when CurrentDisplay = "00" else
                 "1011" when CurrentDisplay = "01" else
                 "1101" when CurrentDisplay = "10" else
                 "1110" when CurrentDisplay = "11";              

end Behavioral;

【问题讨论】:

  • 您在物理显示器或模拟显示器上看不到数字?您是否单独测试了显示器?什么是 SevenSegment_Decoder?
  • 七段解码器是将扫描码转换为 g_to_a(SEGMENTS) 的组件。实际上,我在物理显示器(BASYS2 FPGA)上看到了数字,它也在移动,但我看不到它们在一起,我按下的最后一个键显示在显示器上。我想我最终遇到了时钟问题......

标签: text scroll vhdl shift segment


【解决方案1】:

我们不知道SevenSegment_Decoder 的接口协议,但是你只有两个输入,但没有时钟,这看起来确实很有趣。解码器如何知道何时解释信号?

【讨论】:

  • 7 段解码器通常是 FPGA 中的组合(和/或数组)或 ROMS 或 LUTS,不需要时钟。
  • 解码器不是错误的来源,相信我。我解决了一些错误。现在我确实在 7 段显示器上看到了文字,但是例如当我按 P 和 O 时,我看到的文字是这样的:“PPPOO ..”我真的无法在这里进一步发展。我的一个想法是 shifter 模块中的 if 语句。我开始认为它们不适合我的使用,但也想不出更好的解决方案..
  • 关于“错误”移位的另一件需要注意的重要事情是,它似乎与时钟优化有关,尽管我也几乎可以肯定所有时钟都适合它们各自的模块。键盘控制使用板时钟,50 mHz 并将其在模块内部划分为它的 1/8。 Shifter用的是clkdivide输出,7SegmentController用的是2kHz,足以让我们不区分每个显示单元
  • 如果您在每次按下按钮时看到多个数字,您是否正在消除按钮的抖动?此外,如果你在不同的时钟下运行电路的不同部分,你会为自己存储更多的问题。使用单个时钟,并在您希望部分电路运行得更慢的地方添加时钟使能。
  • 我在键盘接口模块中去抖是的,当我单独尝试时,无论我按多长时间,我都只能得到1个扫描码。至于时钟,我有一个移位器模块的分频器(我必须有一个,以调整移位速度对吗?),FPGA(50 MHz)时钟直接进入键盘控制,因为它可以单独与该时钟一起工作,我还将 FPGA 的时钟定向到 SevenSegmentController(内部有一个预分频器),以便能够以不同的方式显示每个数字。
【解决方案2】:

“我还没有想到任何尝试 7 段控制器的方式/方法”

除非您使用的是非常旧的 ISE 版本,当然比 ISE10 更早,否则它内置了相当不错的模拟器 (ISIM)。(ISIM 比 ISE10 更早,但它并没有真正可用,甚至是 ISIM 10有它的问题...)

如果您编写一个简单的测试平台并在进行过程中对这些模块进行单元测试,您将节省大量时间。

【讨论】:

  • 我正在使用 ISE 12.4 并且也了解测试平台,但随着我的进步,我手动测试了这些模块。我没有抽出时间测试七段控制器的原因是我在另一个项目中也使用过它,所以我确信它没有故障。
猜你喜欢
  • 1970-01-01
  • 2014-12-21
  • 1970-01-01
  • 2018-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多