已知占空比(bili),要求输出矩形波
library std;
use std.standard.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity pwm1 is
generic(delay: time);**************错误处:不支持数据类型
port(clk : in std_logic;
???? bili : in std_logic_vector(7 downto 0);--8位二进制数表示占空比
???? wave : out std_logic);
end pwm1;
architecture behav of pwm1 is
begin
process(clk)
variable a: integer;
variable b,c: real;
constant d: real:=7.988;
begin
a:=conv_integer(bili);--将二进制数转换为整形
b:=real(a);--将整形转换为实数型
c:=b*d;--得出高电平时间
delay:=c ns;--将高电平时间复制给延时**********错误处
if(clk'event and clk='1') then
wave<='1';--先输出高电平
wave<='0' after (delay);--当高电平输出结束,即延时结束输出低电平
end if;
end process;
end behav;
~~~~~~~~~~~~~~~~~~~~~~``
以上是我的程序,其中第二处错误,语句有错误,怎样实现是此功能:把高电平的维持时间送给延时信号。
请帮我改正,谢谢! |