微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 分频程序进展一大半,,只需要一个高人帮我把拨码读近来就可以了

分频程序进展一大半,,只需要一个高人帮我把拨码读近来就可以了

时间:10-02 整理:3721RD 点击:
library ieee;
use ieee.std_logic_1164.all;
entity clk_div is
generic(n:integer:=2);--n的值是要分频的系数,n>=2
    port (clock : in std_logic:='0';
          clk_out : out std_logic);
end clk_div;
architecture sea of clk_div is
signal temp : std_logic:='0';
begin
process(clock,temp)
variable a,a1,a2 : integer range 0 to n;
variable temp1,temp2 : std_logic:='0';
begin
if (n rem 2)=1 then
if rising_edge(clock) then
    if a1=n-1 then a1:=0;temp1:='0';
    elsif a1<((n+1)/2-1) then temp1:='1';a1:=a1+1;
       elsif a1>=((n+1)/2-1) then temp1:='0';a1:=a1+1;
    end if;
end if;
if falling_edge(clock) then
    if a2=n-1 then a2:=0;temp2:='0';
    elsif a2<((n+1)/2-1) then temp2:='1';a2:=a1+1;
       elsif a2>=((n+1)/2-1) then temp2:='0';a2:=a2+1;
    end if;
end if;
temp<=temp1 or temp2;
elsif rising_edge(clock) then
    if a=(n/2-1) then a:=0;temp<=not temp;
    else a:=a+1;
    end if;
end if;
end process;
clk_out<=temp;
end sea;
--程序结束
程序如上,,可以 实现奇数  偶数分频,,现在的generic(n:integer:=2);--n的值是要分频的系数,n>=2   如何对应拨码变化?哪个帮我变化下

generic(n:integer:=d);--n的值是要分频的系数,n>=2
    port (clock : in std_logic:='0';
          d : in  STD_LOGIC_VECTOR (7 downto 0);
          clk_out : out std_logic);
我这样设置参数可以不? d : in  STD_LOGIC_VECTOR (7 downto 0);拨码输入

(n:integer:=d);--n的值是要分频的系数,n>=2
  me每次这样搞就报错误,,如何休整?/如何把d  给  n

如何把d  给  n  有经验的看下,,很简单的,,十万着急

DDDDDDDDDDDD

类属参量传达的是一个静态信息。类似传递一个固定参数。当然不可能把输入信号作为设定值。
要取得拨码开关的值。连续用两个寄存器打一下就ok了。

你还没搞定啊

哪个帮我搞个完整版本好不

wycawyc 具体如何弄把?/十万着急,,要不给我完整下好不?多谢

dddddddddddddddddd

ddddddddddddd

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top