New Hardware Git

This commit is contained in:
e2hang
2025-12-31 19:35:06 +08:00
commit aca5a8aab8
621 changed files with 254727 additions and 0 deletions

22
Verilog/test/test.v Normal file
View File

@@ -0,0 +1,22 @@
module pwm (
input wire clk, // 时钟输入
input wire rst, // 异步复位
input wire [7:0] duty, // 占空比0~255
output reg pwm_out // 输出信号
);
reg [7:0] counter = 0; // 8位计数器周期为 256
always @(posedge clk or posedge rst) begin
if (rst) begin
counter <= 0;
pwm_out <= 0;
end else begin
counter <= counter + 1;
// 比较占空比设置
if (counter < duty)
pwm_out <= 1;
else
pwm_out <= 0;
end
end
endmodule