Basys 3 现场可编程门阵列上的七段显示的澳门在线代码

上次,我写了完整的FPGA教程,内容涉及如何在Basys 3 现场可编程门阵列上控制4位7段显示器。一种 完整的Verilog代码,用于在7段显示器上显示4位十进制计数 还提供了。

这个 甚高密度脂蛋白项目 将呈现完整 甚高密度脂蛋白 七段显示器的代码 Basys 3 现场可编程门阵列。的 七段显示 Basys 3上的FPGA将用于显示4位十六进制数字,该数字每1秒递增一次。 

Basys 3 现场可编程门阵列上的七段显示的澳门在线代码

Basys 3 现场可编程门阵列上BCD至7段显示的真值表

甚高密度脂蛋白代码 对于 BCD到7段显示解码器:

-- fpga4student: 现场可编程门阵列 projects, Verilog projects, 甚高密度脂蛋白项目
-- Example 甚高密度脂蛋白代码 对于 BCD to Basys 3 现场可编程门阵列上的七段显示器
process(LED_BCD)
begin
    case LED_BCD is
    when "0000" => LED_out <= "0000001"; -- "0"     
    when "0001" => LED_out <= "1001111"; -- "1" 
    when "0010" => LED_out <= "0010010"; -- "2" 
    when "0011" => LED_out <= "0000110"; -- "3" 
    when "0100" => LED_out <= "1001100"; -- "4" 
    when "0101" => LED_out <= "0100100"; -- "5" 
    when "0110" => LED_out <= "0100000"; -- "6" 
    when "0111" => LED_out <= "0001111"; -- "7" 
    when "1000" => LED_out <= "0000000"; -- "8"     
    when "1001" => LED_out <= "0000100"; -- "9" 
    when "1010" => LED_out <= "0000010"; -- a
    when "1011" => LED_out <= "1100000"; -- b
    when "1100" => LED_out <= "0110001"; -- C
    when "1101" => LED_out <= "1000010"; -- d
    when "1110" => LED_out <= "0110000"; -- E
    when "1111" => LED_out <= "0111000"; -- F
    end case;
end process;

接下来,正如我在 本教程,必须使用七段显示控制器来控制Basys 3 现场可编程门阵列上的4位七段显示。

下面是刷新Basys 3 现场可编程门阵列上4位七段显示器的时序图:
4位七段显示器的时序图
刷新 4位七段显示器所需的速率是1ms至16ms。让我们选择10.5ms作为刷新周期。下面是一个例子 甚高密度脂蛋白代码 用于在Basys 3 现场可编程门阵列上为4位七段显示器创建刷新率和阳极信号:
-- 7-segment display controller
-- generate refresh period of 10。5ms
process(clock_100Mhz,reset)
begin 
    if(reset='1') then
        refresh_counter <= (others => '0');
    elsif(rising_edge(clock_100Mhz)) then
        refresh_counter <= refresh_counter + 1;
    end if;
end process;
 LED_activating_counter <= refresh_counter(19 downto 18);
-- 4-to-1 MUX to generate anode activating signals 对于 4 LEDs 
process(LED_activating_counter)
begin
    case LED_activating_counter is
    when "00" =>
        Anode_Activate <= "0111"; 
        -- activate LED1 and Deactivate LED2, LED3, LED4
        LED_BCD <= displayed_number(15 downto 12);
        -- the first hex digit of the 16-bit number
    when "01" =>
        Anode_Activate <= "1011"; 
        -- activate LED2 and Deactivate LED1, LED3, LED4
        LED_BCD <= displayed_number(11 downto 8);
        -- the second hex digit of the 16-bit number
    when "10" =>
        Anode_Activate <= "1101"; 
        -- activate LED3 and Deactivate LED2, LED1, LED4
        LED_BCD <= displayed_number(7 downto 4);
        -- the third hex digit of the 16-bit number
    when "11" =>
        Anode_Activate <= "1110"; 
        -- activate LED4 and Deactivate LED2, LED3, LED1
        LED_BCD <= displayed_number(3 downto 0);
        -- the fourth hex digit of the 16-bit number    
    end case;
end process;

现在,让我们用它来显示正在计数的十六进制数 Basys 3 现场可编程门阵列上的4位七段显示器.

Bays 3 现场可编程门阵列上用于七段显示器的澳门在线代码:

-- fpga4student.com: 现场可编程门阵列 projects, Verilog projects, 甚高密度脂蛋白项目
-- 甚高密度脂蛋白代码 对于 Basys 3 现场可编程门阵列上的七段显示器
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_unsigned.all;
entity seven_segment_display_澳门在线 is
    Port ( clock_100Mhz : in STD_LOGIC;-- 100Mhz clock on Basys 3 现场可编程门阵列 board
           reset : in STD_LOGIC; -- reset
           Anode_Activate : out STD_LOGIC_VECTOR (3 downto 0);-- 4 Anode signals
           LED_out : out STD_LOGIC_VECTOR (6 downto 0));-- Cathode patterns of 7-segment display
end seven_segment_display_澳门在线;

architecture Behavioral of seven_segment_display_澳门在线 is
signal one_second_counter: STD_LOGIC_VECTOR (27 downto 0);
-- counter 对于 generating 1-second clock enable
signal one_second_enable: std_logic;
-- one second enable 对于 counting numbers
signal displayed_number: STD_LOGIC_VECTOR (15 downto 0);
-- counting decimal number to be displayed on 4-digit 7-segment display
signal LED_BCD: STD_LOGIC_VECTOR (3 downto 0);
signal refresh_counter: STD_LOGIC_VECTOR (19 downto 0);
-- creating 10。5ms refresh period
signal LED_activating_counter: std_logic_vector(1 downto 0);
-- the other 2-bit 对于 creating 4 LED-activating signals
-- count         0    ->  1  ->  2  ->  3
-- activates    LED1    LED2   LED3   LED4
-- and repeat
begin
-- 甚高密度脂蛋白代码 对于 BCD to 7-segment decoder
-- Cathode patterns of the 7-segment LED display 
process(LED_BCD)
begin
    case LED_BCD is
    when "0000" => LED_out <= "0000001"; -- "0"     
    when "0001" => LED_out <= "1001111"; -- "1" 
    when "0010" => LED_out <= "0010010"; -- "2" 
    when "0011" => LED_out <= "0000110"; -- "3" 
    when "0100" => LED_out <= "1001100"; -- "4" 
    when "0101" => LED_out <= "0100100"; -- "5" 
    when "0110" => LED_out <= "0100000"; -- "6" 
    when "0111" => LED_out <= "0001111"; -- "7" 
    when "1000" => LED_out <= "0000000"; -- "8"     
    when "1001" => LED_out <= "0000100"; -- "9" 
    when "1010" => LED_out <= "0000010"; -- a
    when "1011" => LED_out <= "1100000"; -- b
    when "1100" => LED_out <= "0110001"; -- C
    when "1101" => LED_out <= "1000010"; -- d
    when "1110" => LED_out <= "0110000"; -- E
    when "1111" => LED_out <= "0111000"; -- F
    end case;
end process;
-- 7-segment display controller
-- generate refresh period of 10。5ms
process(clock_100Mhz,reset)
begin 
    if(reset='1') then
        refresh_counter <= (others => '0');
    elsif(rising_edge(clock_100Mhz)) then
        refresh_counter <= refresh_counter + 1;
    end if;
end process;
 LED_activating_counter <= refresh_counter(19 downto 18);
-- 4-to-1 MUX to generate anode activating signals 对于 4 LEDs 
process(LED_activating_counter)
begin
    case LED_activating_counter is
    when "00" =>
        Anode_Activate <= "0111"; 
        -- activate LED1 and Deactivate LED2, LED3, LED4
        LED_BCD <= displayed_number(15 downto 12);
        -- the first hex digit of the 16-bit number
    when "01" =>
        Anode_Activate <= "1011"; 
        -- activate LED2 and Deactivate LED1, LED3, LED4
        LED_BCD <= displayed_number(11 downto 8);
        -- the second hex digit of the 16-bit number
    when "10" =>
        Anode_Activate <= "1101"; 
        -- activate LED3 and Deactivate LED2, LED1, LED4
        LED_BCD <= displayed_number(7 downto 4);
        -- the third hex digit of the 16-bit number
    when "11" =>
        Anode_Activate <= "1110"; 
        -- activate LED4 and Deactivate LED2, LED3, LED1
        LED_BCD <= displayed_number(3 downto 0);
        -- the fourth hex digit of the 16-bit number    
    end case;
end process;
-- Counting the number to be displayed on 4-digit 7-segment Display 
-- on Basys 3 现场可编程门阵列 board
process(clock_100Mhz, reset)
begin
        if(reset='1') then
            one_second_counter <= (others => '0');
        elsif(rising_edge(clock_100Mhz)) then
            if(one_second_counter>=x"5F5E0FF") then
                one_second_counter <= (others => '0');
            else
                one_second_counter <= one_second_counter + "0000001";
            end if;
        end if;
end process;
one_second_enable <= '1' when one_second_counter=x"5F5E0FF" else '0';
process(clock_100Mhz, reset)
begin
        if(reset='1') then
            displayed_number <= (others => '0');
        elsif(rising_edge(clock_100Mhz)) then
             if(one_second_enable='1') then
                displayed_number <= displayed_number + x"0001";
             end if;
        end if;
end process;
end Behavioral;

Basys 3 现场可编程门阵列上4位七段显示器的引脚分配约束文件:

# Clock signal
set_property PACKAGE_PIN W5 [get_ports clock_100Mhz]       
 set_property IOSTANDARD LVCMOS33 [get_ports clock_100Mhz]
set_property PACKAGE_PIN R2 [get_ports reset]     
        set_property IOSTANDARD LVCMOS33 [get_ports reset]
#seven-segment LED display
        set_property PACKAGE_PIN W7 [get_ports {LED_out[6]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[6]}]
        set_property PACKAGE_PIN W6 [get_ports {LED_out[5]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[5]}]
        set_property PACKAGE_PIN U8 [get_ports {LED_out[4]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[4]}]
        set_property PACKAGE_PIN V8 [get_ports {LED_out[3]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[3]}]
        set_property PACKAGE_PIN U5 [get_ports {LED_out[2]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[2]}]
        set_property PACKAGE_PIN V5 [get_ports {LED_out[1]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[1]}]
        set_property PACKAGE_PIN U7 [get_ports {LED_out[0]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {LED_out[0]}]
        set_property PACKAGE_PIN U2 [get_ports {Anode_Activate[0]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[0]}]
        set_property PACKAGE_PIN U4 [get_ports {Anode_Activate[1]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[1]}]
        set_property PACKAGE_PIN V4 [get_ports {Anode_Activate[2]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[2]}]
        set_property PACKAGE_PIN W4 [get_ports {Anode_Activate[3]}]                    
            set_property IOSTANDARD LVCMOS33 [get_ports {Anode_Activate[3]}]
使用 甚高密度脂蛋白来源 文件和约束文件,在Vivado中创建一个项目,并在Basys 3上运行澳门在线代码 现场可编程门阵列。以下是有关 Basys 3 现场可编程门阵列上的七段显示器:
推荐的 甚高密度脂蛋白项目:
1. 什么是FPGA? 甚高密度脂蛋白如何在FPGA上工作
2. FIFO存储器的澳门在线代码
3. FIR滤波器的澳门在线代码
4. 8位微控制器的澳门在线代码
5. 矩阵乘法的澳门在线代码
6. 开关尾环计数器的澳门在线代码
7. 现场可编程门阵列上数字闹钟的澳门在线代码
8. 8位比较器的澳门在线代码
9. 如何使用澳门在线将文本文件加载到FPGA中
10。 D触发器的澳门在线代码
11。 完整加法器的澳门在线代码
12 具有可变占空比的澳门在线中的PWM发生器
13 ALU的澳门在线代码
14。 带测试平台的计数器的澳门在线代码
15 16位ALU的澳门在线代码
16。 甚高密度脂蛋白中的移位器设计
17。 甚高密度脂蛋白中的非线性查找表实现
18岁 甚高密度脂蛋白中的密码协处理器设计
现场可编程门阵列 Verilog 甚高密度脂蛋白课程

11条评论:

  1. 如何为此项目创建测试平台?任何帮助,将不胜感激。

    回复删除
    回覆
    1. 只需生成时钟并在测试台中复位,然后观察仿真波形即可。那's it.

      删除
    2. 不,不起作用。您唯一看到的就是时钟和重置。当您添加其他对象时,它们的值是"U" or "XXXXX"
      请上传您的测试平台。

      删除
  2. 回覆
    1. 只需从display_number更改<=显示编号+ x"0001"至display_number<=显示编号-x"0001";

      删除
  3. 您好,我想知道如何更改频率和刷新率?
    像1秒时钟到100Hz一样,为10.5ms稍微快一点。
    谢谢。

    回复删除
  4. 如何使用结构模型编写相同的代码?

    回复删除
  5. 请告诉我如何使用结构建模编写相同的代码

    回复删除

热门FPGA项目