I am trying to make sense of this example code found here
module LED_PWM(clk, PWM_input, LED);
input clk;
input [3:0] PWM_input; // 16 intensity levels
output LED;
reg [4:0] PWM;
always @(posedge clk) PWM <= PWM[3:0]+PWM_input;
assign LED = PWM[4];
endmodule
To start off, it creates the 4 bit register PWM_input and 5 bit register PWM. It then goes on to set PWM equal to 3 bits of itself plus PWN_input at every clock cycle.
What exactly is happening here? Why are only 4 of the 5 bits of PWM being used and what is the value of PWM_input?
When actually controlling the LED, it is setting the LED to PWM[4]. Is that the same as PWM[4:0]? Or is it a standalone value?