【发布时间】:2023-03-14 14:09:01
【问题描述】:
module PWM_Gen(
input clk, // Clock input
input [7:0]DUTY_CYCLE, // Input Duty Cycle
output PWM_OUT // Output PWM
);
reg [7:0]counter_out; // 8-bit counter
always @(posedge clk)
begin
if (DUTY_CYCLE > counter_out)
PWM_OUT = 1;
else
PWM_OUT = 0;
end
counter counter_inst(
.clk(clk),
.counter_out(counter_out)
)
endmodule
错误是 -
错误 (10170):PWM_Gen.v(51) 附近文本处的 Verilog HDL 语法错误: “端模块”;期待“;”。
第二季度。我不明白时钟输入是如何与占空比相关的以及我如何在代码中实现它? Q3.我不明白我将如何获得 1MHz 的输出?
【问题讨论】:
-
编译问题 --> 请将 counter_out 声明为wire。使用 wire [7:0] counter_out 并在 counter_inst 的右括号后添加分号,即 /*Previous code*/ .counter_out(counter_out) ) ; //这里加分号
-
请用代码解释我,因为我是 vhdl 的新手