test bench for digitAL PI controller

OP #5329354
Rate this post
• ▲ useful
▼ not useful
Hello, i am trying to build a test bench for a PI conntroller based on 
the attached article.

whole code is playing with coefficient for the  last line.
how do you recooment to represent the coefficients in the testbench?

Thanks
1
always #((t0-vctl*kphi)/2) vco<=~vco;

1
module loop_filter(t0,clk,integral,proportional,filt_i,filt_p,vtcl,kptl,vtcl,vco);
2

3
input t0,smpclk,integral,proportional,filt_i,filt_p,vtcl,kptl,vtcl;
4
output vco;
5

6
reg integral=4'b0;
7
reg proportional=4'b0;
8

9
always @(posedge smpclk)
10
begin
11
if (pdup==1'b1) begin
12
  integral=integral+filt_i;
13
  proportional=filt_p;
14
  end
15
  else if (pdup==1'b0)
16
  begin
17
  integral=integral-filt_i;  
18
  proportional=-filt_p;
19
  end
20
  else begin
21
         proportional=0;
22
  end
23
  
24
always #((t0-vctl*kphi)/2) vco<=~vco;
25
end
26
endmodule
Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.