The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines. Sep 24th, 2017, 8:55am
  HomeHelpSearchLoginRegisterPM to admin  
 
Pages: 1
Send Topic Print
current measurement through $cds_iprobe (Read 1191 times)
AMS_ei
Community Member
***
Offline



Posts: 66

current measurement through $cds_iprobe
May 26th, 2016, 2:09am
 
Hi, I am trying to measure current flowing through R2 with the help of verilog-AMS.

1. The following is my SPICE netlist file (input.scs):
//*************************************//
simulator lang=spectre
global 0
subckt TEST in out
R2 (in out) resistor r=1K
R1 (out 0) resistor r=1K
R0 (in 0) resistor r=1K
ends TEST

//*******************************************//

2. The following is my top.v file:

//******************************************//
module tb_top();
wire in;
wire out;

TEST test (
    .in(in),
    .out(out)
    );


dc_gen Idc_gen(
             .out(in)
             );

curr_bfm Icurr_bfm (
                  .check_curr1()
                  );  
endmodule

//***********************************************//

3. Following is the dc input voltage generator file which is basically the input voltage to the circuit

//********************************************
`include "disciplines.vams"
`include "constants.vams"
//`timescale 1ns/1ps

module dc_gen(out);
output out;
electrical out;

analog begin
V(out) <+ 5 ;
end
endmodule

//*********************************************//


4. Following is my amscf.scs file;

//************************************************//

***********

include "$TB_ROOT/test/input.scs"
include "$TB_ROOT/test/acf.scs"

amsd {
    portmap subckt=TEST
    config cell=TEST use=spice
    }

//*******************************************//

5. Following the file with which I am trying to measure current through R2.

//***********************************************//
module curr_bfm(check_curr1);
output check_curr1;
electrical check_curr1;
real real_cur;
analog begin
real_cur = $cds_iprobe("tb_top.test.out");
I(check_curr1) <+ real_cur;
end
endmodule

//******************************************************//

6. Following is the probe.tcl file by which I am probing the signals.

//******************************************************//
probe -create -shm -all -analog -flow
run

//*******************************************************//

The above setting I am running with irun. But, there is no value of current showing through R2.

Could you please tell me if there is anything missing to get the value of current?

Thank you.
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline

The Spectre

Posts: 2075
Silicon Valley
Re: current measurement through $cds_iprobe
Reply #1 - May 28th, 2016, 11:15am
 
Well, in your testbench you did not actually pass anything into your current checker:
Code:
curr_bfm Icurr_bfm (
			.check_curr1()   <---- this cannot be right
			);   



Second, you should never use $cds_iprobe unless you know what you are doing. It is inaccurate and when used in a circuit like this causes instabilities. Specifically, if you use $cds_iprobe you must first understand that it is inaccurate and how it is inaccurate so you know whether you can tolerate that inaccuracy. Second, you should never use the output of $cds_iprobe to drive the circuit itself.

Code:
module curr_bfm(check_curr1);
output check_curr1;
electrical check_curr1;
real real_cur;
analog begin
    real_cur = $cds_iprobe("tb_top.test.out");
    I(check_curr1) <+ real_cur;
end
endmodule 



Instead, you should just use the normal mechanism for measuring current in Verilog-A.

Code:
module curr_bfm(check_curr1);
electrical check_curr1;
real real_cur;
analog begin
    real_cur = I(check_curr1);
end
endmodule 



Finally, this collection of models seems overly complicated and hopelessly confused. Perhaps if you described what you wanted to do we could just tell you how to do it. Regardless, you should read Introduction to Verilog-A.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
AMS_ei
Community Member
***
Offline



Posts: 66

Re: current measurement through $cds_iprobe
Reply #2 - Mar 19th, 2017, 10:03am
 
Hi Ken,

Thank you for your valuable inputs.
Actually, I would like to measure current of a SPICE net ( here in this context it is through out) with the help of Verilog-A/MS code.

Thank you.

Kind regards.
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1899
Massachusetts, USA
Re: current measurement through $cds_iprobe
Reply #3 - Mar 20th, 2017, 1:04pm
 
What do you want to do with the current measurement? Do you want to print a message giving its value, or do you want to output a voltage (like a CCVS)?

Also, one can measure the current through a branch. If your "SPICE net" has more than two terminals, it doesn't really make sense to talk about measuring the current of the net.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
AMS_ei
Community Member
***
Offline



Posts: 66

Re: current measurement through $cds_iprobe
Reply #4 - Apr 18th, 2017, 8:44am
 
Thank you Ken and Geoffrey Coram.
I got it now.
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Trouble viewing this site? Copyright © 2002-2014 Designer's Guide Consulting. 'Designer's Guide' is a registered trademark of Designer's Guide LLC. All rights reserved.

Our colleges are not as safe as they seem. Sexual assault is pervasive and the treatment of the victim by the adminstration is often as damaging as the assault: Campus Survivors, Campus Survivors Forum.

Some of our other sites that you might find useful: QuantiPhy.