pwm_counter.v

来自「基于ATEREAL EPM1270T144C5N CPLD 压力传感器数据采集源」· Verilog 代码 · 共 32 行

V
32
字号
module pwm_counter(clk,pwm_in,rst,sign,clr,pwm_out);
input	     clk;
input        pwm_in;
input        rst;
input        sign;
input        clr;
output[31:0] pwm_out;
reg[31:0]    pwm_out1;
reg[31:0]    pwm_out;

always @(posedge clk or negedge rst)
begin
if(!rst)
pwm_out<=32'h00000000;
else
pwm_out<=pwm_out1;
end

always @(posedge pwm_in or negedge clr)
begin
if(!clr)
pwm_out1<=32'h00000000;
else
begin
if(sign==1'b0)
pwm_out1<=pwm_out1+32'h00000001;
else
pwm_out1<=pwm_out1-32'h00000001;
end
end

endmodule

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?