pwm waveform in vhdl code
I have found new codes. I have sımulated it by moudle sımulator. and I get some results but I can nor understand whether they are rıght or not. can you help me to understand this?
module PWMMain(DC,CLK,Q);
input [7:0] DC;
input CLK;
output Q;
wire CLKO;
// synthesis attribute LOC clk "P9"
// synthesis attribute LOC Q "P1"
// synthesis attribute LOC DC "P11","P10","P7","P6","P5","P4","P3","P2"
//clkdiv div(CLK,CLKO);
PWM sev(DC,CLK,Q);
endmodule
module clkdiv(CLKIN,CLKOUT);
input CLKIN;
output CLKOUT;
wire iclk;
parameter BITS=13;
reg [BITS-1:0] COUNT;
initial COUNT=0;
assign CLKOUT=COUNT[BITS-1];
BUFG clkbuf(iclk,CLKIN);
always @(posedge iclk)
begin
COUNT = COUNT + 1;
end
endmodule
module PWM(DC,CLK,Q);
input [7:0] DC; // duty cycle input
input CLK;
output Q;
reg [8:0] acc; // accumulator has one more bit than the duty cycle
assign Q=acc[8]; // output is the 8th bit
initial acc=0; // for simulation only
always @(posedge CLK)
begin
acc=acc[7:0]+DC; // only add with 8 bits.
end
endmodule
testbench is below
module denemee;
reg [7:0] DC;
reg CLK;
// Outputs
wire Q;
// Instantiate the Unit Under Test (UUT)
PWMMain uut (
.DC(DC),
.CLK(CLK),
.Q(Q)
);
always
begin
CLK = 1;
#0.1;
CLK = 0;
#0.1;
end
the ouıtput of thıs stımulus,does it give the right output?
please help me...
thanks