看上面有发呼吸灯的,我也发个Verilog 查表法的呼吸灯
//ISE环境,12M时钟module Notify_light(
inputCLK,
inputnRst,
inputenable,
output reg pwm_out
);
reg PWM_Tab;
reg PWM_Tab_index;
wire PWM_Value = PWM_Tab;
`define init_2(b0,b1) PWM_Tab=b0; PWM_Tab=b1; i=i+2
`define init_4(b0,b1,b2,b3) `init_2(b0, b1); `init_2(b2,b3)
`define init_8(b0,b1,b2,b3,b4,b5,b6,b7) `init_4(b0,b1,b2,b3); `init_4(b4,b5,b6,b7)
integer i;
initial begin
i = 0;
`init_8(1, 5, 11 , 15 , 20 , 25 , 30 , 36);
`init_8(43 , 49 , 56 , 64 , 72 , 88 , 97 , 105);
`init_8(114, 132, 141, 150, 158, 167, 183, 206);
`init_8(212, 225, 230, 235, 240, 245, 250, 254);
`init_8(250, 244, 240, 235, 225, 219, 212, 206);
`init_8(191, 183, 175, 167, 150, 141, 132, 123);
`init_8(114, 105, 97 , 88 , 72 , 64 , 56 , 49);
`init_8(36 , 30 , 25 , 20 , 15 , 11 , 5, 0);
end
//=========================================================
reg pwm_count;
reg tick;
reg divider;
`define DIV_TOP 12'd2400
always @(posedge CLK or negedge nRst) begin
if (!nRst) begin
PWM_Tab_index <= 0;
pwm_count <= 0;
tick <= 0;
divider <= 0;
end else begin
if(enable) begin
tick <= tick + 1;
if (&tick) begin
pwm_count <= pwm_count +1;
if(&pwm_count)begin
pwm_out <= 1'b0;
end else if(pwm_count == PWM_Value) begin
pwm_out <= 1'b1;
end
if(divider == `DIV_TOP) begin
divider <= 0;
PWM_Tab_index <= PWM_Tab_index + 1;
end else begin
divider <= divider + 1;
end
end
end else begin
pwm_out <= 0;
end
end
end
endmodule 不错,支持原创 看着比前一个简单多了,支持!! 相当不错,抽个时间去验证一下。 mark!呼吸灯!!!! mark一下 谢谢分享,学习一下。 顶一下楼主 第一次看到initial这样用,initial不是不能综合吗? 好牛啊! dongyanbo 发表于 2014-9-22 00:39
第一次看到initial这样用,initial不是不能综合吗?
xilinx的综合器是可以的,XST的说明书有讲:
Block and distributed RAM initial contents can be specified by initialization of the signal
describing the memory array in your HDL code. Do this directly in your HDL code,or
specify a file containing the initialization data. 能找个呼吸灯最佳曲线就好了,, 楼主研究的真仔细,那PWM_Tab会自动综合成Block and distributed RAM了? LinuxTux.China 发表于 2014-9-22 09:59
能找个呼吸灯最佳曲线就好了,,
这个数据表的曲线是从icufflinks的源码里改过来的,icufflinks 的数据表是反向破解了苹电MAC的呼吸灯的曲线得到的。
所这个应该算比较好的曲线了。 楼主好厉害,,拿去在EasyFPGA060上去试试 学习 hell-prototypes 发表于 2014-9-22 10:22
这个数据表的曲线是从icufflinks的源码里改过来的,icufflinks 的数据表是反向破解了苹电MAC的呼吸灯的曲 ...
奥,有这样的渊源啊,呵呵, 学习了,简洁 学习一下 楼主,CLK是多少啊? 这个有用,收藏先 不错 学习了 学习了,有空试一下,谢谢楼主 分析下呼吸灯怎么才能感觉平顺 学习了 学习了,在EPM240上试了下,最近在学这个
页:
[1]