The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 4:35pm
Pages: 1 2 
Send Topic Print
how to save the output digital data in a file using Verilog-A (Read 16002 times)
boe
Community Fellow
*****
Offline



Posts: 615

Re: how to save the output digital data in a file using Verilog-A
Reply #15 - Jan 30th, 2012, 5:27am
 
Geoffrey_Coram wrote on Jan 27th, 2012, 6:56am:
As I was translating, I had a few questions:
1) Why is count always 0?
2) Why is t a variable instead of a parameter?

As already mentioned, I would expect
Code:
  @(cross( V(clk) - thres, 1)) begin
    inr = V(in);
    $fstrobe(fptr,"%f \n", inr);
    count=0;
  end 

instead of
Code:
  inr = V(in);
  @(cross( V(clk) - thres, 1)) begin
    $fstrobe(fptr,"%f \n", inr);
    count=0;
  end 


Anyway, neither code should cause internal errors on current Spectre versions.
- B O E
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: how to save the output digital data in a file using Verilog-A
Reply #16 - Feb 1st, 2012, 10:14am
 
boe -
Well, that's an interesting question: is the output supposed to change only on the clock ( inr = V(in) inside the cross event block, as you expect) or always.

Because there's a transition filter, I guess I would tend to agree with you; it's a bad idea to put a transition on a continuous signal, but we don't actually know anything about what's connected to "in"

But this thread is mostly about writing the digital data to a file, so I wasn't paying attention to that.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Forum Administrator
YaBB Administrator
*****
Offline



Posts: 145

Re: how to save the output digital data in a file using Verilog-A
Reply #17 - Feb 1st, 2012, 3:07pm
 
Never ever do the following:
Code:
inr = V(in);
V(out) <- $transition(inr,0,t,t); 


In other words, the first argument to the transition function should never be a continuous function of an electrical signal, even if you believe the electrical signal is constant. In contrast, the following is perfectly fine:
Code:
@(cross( V(clk) - thres, 1))
    inr = V(in);
V(out) <- $transition(inr,0,t,t); 


The difference her is that inr is set in an event block and so cannot vary continuously with V(in).

Many times I have seen code that looks like the following:
Code:
if (...)
    val = 1;
else
    val = 0;
V(out) <+ transition(val*V(vdd), 0, 10n);
 


Such code leads to heartbreak and misery. The problem is that V(vdd) is computed by the simulator, and can change slightly from time point to time point (often time these changes are at the attovolt level). Those changes will activate the transition function, which limits the time steps and slow the simulation. You should instead use:
Code:
if (...)
    val = 1;
else
    val = 0;
V(out) <+ V(vdd)*transition(val, 0, 10n);
 



-Ken
Back to top
 
 
View Profile WWW   IP Logged
afridi
Junior Member
**
Offline



Posts: 24

Re: how to save the output digital data in a file using Verilog-A
Reply #18 - Feb 7th, 2012, 3:11am
 
Thank you everyone for your insight.

The verilog-A code gives error at

Code:
parameter string filename ="default.txt" 



when I remove the word "string" it works. any idea what it is?
Back to top
 
 

The more things you do, the more you can do.(Lucille Ball)
View Profile   IP Logged
afridi
Junior Member
**
Offline



Posts: 24

Re: how to save the output digital data in a file using Verilog-A
Reply #19 - Feb 7th, 2012, 4:26am
 
boe wrote on Jan 30th, 2012, 5:27am:
Geoffrey_Coram wrote on Jan 27th, 2012, 6:56am:
As I was translating, I had a few questions:
1) Why is count always 0?
2) Why is t a variable instead of a parameter?

As already mentioned, I would expect
Code:
  @(cross( V(clk) - thres, 1)) begin
    inr = V(in);
    $fstrobe(fptr,"%f \n", inr);
    count=0;
  end 

instead of
Code:
  inr = V(in);
  @(cross( V(clk) - thres, 1)) begin
    $fstrobe(fptr,"%f \n", inr);
    count=0;
  end 


Anyway, neither code should cause internal errors on current Spectre versions.
- B O E


What I understand is,that the inr in the first case would save the its values after the clock voltage crosses over the threshold, but in the second case it will save the value before the clock voltage?

Then is the second approach completely wrong? or their effect is the same?
Regards
Back to top
 
 

The more things you do, the more you can do.(Lucille Ball)
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: how to save the output digital data in a file using Verilog-A
Reply #20 - Feb 7th, 2012, 10:04am
 
Afridi,
afridi wrote on Feb 7th, 2012, 4:26am:
...
What I understand is,that the inr in the first case would save the its values after the clock voltage crosses over the threshold, but in the second case it will save the value before the clock voltage?
No, in the first case inr changes at every simulator time step, while in the other case it changes only at clock edge. This will effectively cause the output V(out) to be sampled in the second case. See also Geoffrey's comment (reply #16).

Quote:
Then is the second approach completely wrong? or their effect is the same?
The difference is in V(out) and how efficiently the output signal is simulated. See Ken's post for the explanation why. If you remove the contribution statement to V(out), both cases should create the same output file.

afridi wrote on Feb 7th, 2012, 3:11am:
The verilog-A code gives error at
Code:
parameter string filename ="default.txt" 



when I remove the word "string" it works. any idea what it is?
Apparently (your version of)  the simulator does not support this syntax.
- B O E
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: how to save the output digital data in a file using Verilog-A
Reply #21 - Feb 7th, 2012, 12:27pm
 
"string" was not part of Verilog-AMS in the beginning, but some simulators allowed you to specify a string literal (something in "quotes") -- digital Verilog allowed some conversion between characters and 8-bit "reg" data values.  Since "string" wasn't a keyword, you couldn't use it, but Verilog has some automatic parameter type determination, so you could specify a string literal as the default value and this would effectively make the parameter of type string.
Back to top
 
 

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



Posts: 615

Re: how to save the output digital data in a file using Verilog-A
Reply #22 - Feb 8th, 2012, 3:39am
 
Geoffrey,
however, recent versions of the Cadence Verilog-A Language Reference contain this parameter string syntax. So current versions of Spectre should understand this.

- B O E
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: how to save the output digital data in a file using Verilog-A
Reply #23 - Feb 9th, 2012, 8:39am
 
Ah, but in another thread, Afridi admitted to running 5.10 (and was admonished there to get a more recent version).
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1 2 
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.