3

关于投票
FPGA的一个VHDL实现1秒LED闪烁一次的程序。
程序思路很简单,就是利用50MHz的外部时钟输入,经过2次分频得到1秒的精确定时,给LED取反。


LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
--USE IEEE.STD_LOGIC_ARITH.ALL;
--USE IEEE.STD_LOGIC_UNSIGNED.ALL;

entity led is
    port(led1,led2,led3,led4:out bit;clk:in bit);
end led;

architecture led_blink of led is

begin
    process(clk)
    variable s1:integer:=0;
    variable s2:integer:=0;
    begin
        i1:if (clk'event and clk='1') then
            s1:=s1+1;
            
            if(s1>20000) then
                s2:=s2+1;
               
                if(s2>2500 and s2<5000) then
                    led1<='1';
                    led2<='0';
                    led3<='1';
                    led4<='0';   
                elsif(s2>=5000) then
                    led1<='0';
                    led2<='1';
                    led3<='0';
                    led4<='1';
                    s2:=0;
                end if;   
                s1:=0;
            end if;

        end if i1;
       
    end process;
end led_blink; 
系统分类: CPLD/FPGA
用户分类: FPGA
标签: FPGA VHDL LED 1秒定时
来源: 原创
发表评论 阅读全文(1660) | 回复(6)

0

关于投票
帖一个用VHDL实现4位MUX的简单程序.

VHDL 4位MUX的实现,很简单,调试玩玩.

 

entity mux is
 port(a,b,c,d,sel_0,sel_1:in bit;out_1:out bit);
end mux;

architecture example of mux is
 begin
  process(a,b,c,d,sel_0,sel_1)
   begin
    case bit_vector'(sel_0 & sel_1) is
     when "00" => out_1<=a;
     when "01" => out_1<=b;
     when "10" => out_1<=c;
     when "11" => out_1<=d;
    end case;
  end process;
end example;

系统分类: 汽车电子
用户分类: FPGA
标签: VHDL MUX 多路复用
来源: 原创
发表评论 阅读全文(367) | 回复(0)

0

关于投票
增加FPGA分类,并贴上一个简明教程和VHDL例子程序。
2-4译码器的程序作为初步调试使用。
library IEEE;
use IEEE.Std_logic_1164.ALL;
entity pro1 is
    port(A1,B1,G1BAR,A0,B0,G0BAR:in std_logic;
        Y20,Y21,Y22,Y23,Y10,Y11,Y12,Y13:out std_logic);
end pro1;

architecture pro1_arch of pro1 is
    begin
        Y10<='0' when(B0='0') and ((A0='0') and (G0BAR='0')) else '1';
        Y11<='0' when(B0='0') and ((A0='1') and (G0BAR='0')) else '1';
        Y12<='0' when(B0='1') and ((A0='0') and (G0BAR='0')) else '1';
        Y13<='0' when(B0='1') and ((A0='1') and (G0BAR='0')) else '1';
        Y20<='0' when(B1='0') and ((A1='0') and (G1BAR='0')) else '1';
        Y21<='0' when(B1='0') and ((A1='1') and (G1BAR='0')) else '1';
        Y22<='0' when(B1='1') and ((A1='0') and (G1BAR='0')) else '1';
        Y23<='0' when(B1='1') and ((A1='1') and (G1BAR='0')) else '1';
end pro1_arch;
文档不是自己写的,来自网络,文档里面有出处和广告,我这里就不注明了。
rar

系统分类: CPLD/FPGA
用户分类: FPGA
标签: FPGA VHDL
来源: 原创
发表评论 阅读全文(646) | 回复(0)
总共 , 当前 /