标题: 用FPGA产生PWM波形? [打印本页]
作者: ljqlxx_1213 时间: 2006-4-24 15:10 标题: 用FPGA产生PWM波形?
毕业设计题目!求各位大侠帮忙!知道的指点一下,大概原理!有原程序最好!跪谢
作者: senber 时间: 2006-4-25 11:43
module pwm(clock,keyin,pwm_out);
input clock;
input [1:0] keyin;
output pwm_out;
reg [20:0] count;
reg [9:0] pwm_count;
reg pwm_reg;
always @(posedge clock)
begin
count=count+1;
if (count[15:6] < pwm_count)
pwm_reg=1;
else
pwm_reg=0;
end
always @(posedge count[15])
begin
if (keyin[0] == 1'b0)
begin
pwm_count=pwm_count+1;
end
else if (keyin[1] == 1'b0)
begin
pwm_count=pwm_count-1;
end
end
assign pwm_out=pwm_reg;
endmodule
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) |
Powered by Discuz! 7.0.0 |