Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Design of a AC power load by a controllable current source

Status
Not open for further replies.

WEH

Newbie level 1
Joined
Jul 26, 2017
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
Hello,
This is my first time to use Verilog A to design a model in Cadence Spectre. I aim to use a controllable current source to model an AC load with given active power P and reactive power Q. At the end of each period, i.e., 1/fc, the current of the current source is updated based on the active power P, reactive power Q, and the voltage amplitude Vamp and phase Vphi during the past period. Below is my verilog A code and it can not pass the compilation when I try to create a symbol from these codes. The error information is also attached. Could anyone help me figure out how to fix these codes? Thank you.


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// VerilogA for power_grid_simulation, load_cpq, veriloga
 
`include "constants.vams"
`include "disciplines.vams"
 
module load_cpq(vin);
input vin;
electrical vin;
parameter real fc=50.0;
parameter real P=0.9;
parameter real Q=0.3;
real Amax= -10**9;
real Amin = 10**9;
real Vamp = 1.0;
real Vphi = 0;
real Iamp = 2*sqrt(P*P+Q*Q)/Vamp;
real Iphi = Vphi-atan(Q/P);
 
real vin_value;
integer sample_per_cycle = 100;
 
always #(1/(sample_per_cycle*fc))
begin
    vin_value=V(vin);
    if ($realtime()%(1/fc))
    begin
        Vamp =(Amax-Amin)/2;
        Vphi = acos(V(vin)/Vamp);
                Iamp = 2*sqrt(P*P+Q*Q)/Vamp;
                Iphi = Vphi-atan(Q/P);
                Amax = -10**9;
        Amin = 10**9;
    end
    else
    begin
        Amax=(vin_value>Amax)?vin_value:Amax;
        Amin=(vin_value<Amin)?vin_value:Amin;
    end
end
 
analog 
begin
I(vin) <+ Iamp*cos(2.0*`M_PI*fc*$realtime()+Iphi);
end
 
endmodule



Warning from spectre during AHDL compile.
WARNING (VACOMP-1086):
"/space3/DRV3/home/whan/power_grid_simulation/load_cpq/veriloga/veriloga.va",
line 23: `always' is not a reserved keyword now but will be one in a
future release. Parsing `always' as an identifier for now.
Error found by spectre during AHDL compile.
ERROR (VACOMP-2163): "always #(1/(sample_per_cycle*fc))<<--? "
"/space3/DRV3/home/whan/power_grid_simulation/load_cpq/veriloga/veriloga.va",
line 23: Encountered ordered parameter override lists. The software
does not support this feature. Use named lists instead.
ERROR (VACOMP-2259): "begin<<--? "
"/space3/DRV3/home/whan/power_grid_simulation/load_cpq/veriloga/veriloga.va",
line 24: syntax error.
ERROR (VACOMP-1814): Maximum allowable errors exceeded. Exiting AHDL
compilation....
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top