The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 28th, 2024, 10:45pm
Pages: 1
Send Topic Print
Code from Designer's Guide book throwing error (Read 6051 times)
subtr
Community Member
***
Offline

Analog Enthusiast

Posts: 72
India
Code from Designer's Guide book throwing error
Jan 02nd, 2017, 11:15pm
 
Hi,
These are some of the issues, I was finding when I used the DAC vams code from 3rd Chapter Listing 27, Designer's Guide to Verilog AMS.

1) genvar issue for the for loop as exactly mentioned in http://www.edaboard.com/thread290530.html
2)Changing genvar to integer gave this ncelab error : "A non-parameter identifier used when constant expression is expected !"

I have unrolled the loop manually for an 8bit dac and resolved it without using for loop. But this prevents me from creating any N-bit dac. Does anyone know why this is happening and suggest a solution? Embarrassed
Back to top
 
 

Regards
Subtr
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: Code from Designer's Guide book throwing error
Reply #1 - Jan 3rd, 2017, 12:34am
 
If you would like help, you should include the code that is not working and the error messages. All the code.  We are willing to help if you give us something to work with.

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

Analog Enthusiast

Posts: 72
India
Re: Code from Designer's Guide book throwing error
Reply #2 - Jan 3rd, 2017, 12:49am
 
//Verilog-AMS HDL for "tirunels_design", "veri_dac" "verilogams"

`include "constants.vams"
`include "disciplines.vams"

module veri_dac(out,in,clk);

parameter integer bits = 8 from [1:24]; //Default 8 bit
parameter real fullscale = 1.0; // output range is from 0 - 1V
parameter real td = 0p;
parameter real tt =10p;
parameter vdd = 1.0;
parameter real thresh = vdd /2;
parameter integer dir = 1 from [-1:1] exclude 0;

output out;
input clk;
input [0:bits-1]in;
electrical out, clk;
electrical [0:bits-1]in;

real aout;
integer weight;
genvar i;

analog begin

  @(cross(V(clk) - thresh, dir) or initial_step)  
         begin
    aout = 0;
    weight = 2;
       for(i= bits-1;i>=0;i=i-1)
        begin
              if(V(in[i]) > thresh) begin
                 aout = aout + fullscale/weight;
              end
              weight = weight*2;
     
//               if(V(in[6]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[5]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[4]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[3]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[2]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[1]) > thresh) begin
//                  aout = aout + fullscale/weight;
//               end
//               weight = weight*2;
//
//               if(V(in[0]) > thresh) begin
//                  aout = aout + fullscale/weight;
              end
         end



        V(out) <+ transition(aout,td,tt);
      end
endmodule


I get the error :
Error found by spectre.
   Encountered a problem in instance `tb_vams_dac.I95' of module `veri_dac'.
       for(i= bits-1;i>=0;i=i-1)

ncelab: *E,SYERROR ....Encountered an invalid for-loop control statement. The genvar expression must consist of an integer constant or other unrolled genvar variable expression only.
   Encountered a problem in instance `tb_vams_dac.I95' of module `veri_dac'.

Invalid for-loop. Check genvar variables in it.
ncelab: *F,SSIGF: Analog elaboration failed!.


In case I change the variable 'i' to an integer, I get an error :
A non-parameter identifier used when constant expression is expected !

Back to top
 
 

Regards
Subtr
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Code from Designer's Guide book throwing error
Reply #3 - Jan 3rd, 2017, 5:57am
 
Which version of INCISIVE are you using (what does "irun -version" report)? (although I'd be a bit surprised if this is broken even in fairly old versions, unless it's really really old). I just took the code you pasted, and created two other files:

top.vams

Code:
module top;

wire in[7:0];
veri_dac I1(out,in,clk);

endmodule 



and top.scs

Code:
//

tran tran stop=100n 



Yes, I know this won't work because there's no stimulus, nor is there a ground node defined - I just wanted to see if it would compile and elaborate OK. I then ran:

irun veri_dac.vams top.vams top.scs

and it runs with no errors. Maybe the problem is elsewhere in your netlist? (not sure how though) - perhaps bits is defined to be something non-constant?

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
subtr
Community Member
***
Offline

Analog Enthusiast

Posts: 72
India
Re: Code from Designer's Guide book throwing error
Reply #4 - Jan 3rd, 2017, 12:30pm
 
Hi Andrew,

irun -version : TOOL:      irun(64)      08.20-s003

In fact I could not logically find anything wrong with the code. I am using IC615 and mmsim12. I am generating the netlist through "OSS based netlisting with irun". My test bench has this AMS block, VDC and a Vpulse generating a clock.
Back to top
 
 

Regards
Subtr
View Profile   IP Logged
subtr
Community Member
***
Offline

Analog Enthusiast

Posts: 72
India
Re: Code from Designer's Guide book throwing error
Reply #5 - Jan 3rd, 2017, 2:12pm
 
Hi Andrew,

I tried doing the same command line on my working dac code. It gives an error on the top.vams. I removed processes leaving initial_step so that nothing can possibly be wrong in the code. Even then I get this error. In fact this is an ncvlog error.

COMMAND : irun veri_dac.vams top.vams top.scs

OUTPUT :

irun(64): 08.20-s003: (c) Copyright 1995-2008 Cadence Design Systems, Inc.


file: veri_dac.vams
     module worklib.veri_dac:vams
           errors: 0, warnings: 0
file: top.vams
veri_dac I1(out,in,clk);
                |
ncvlog: *E,MEMNDI (top.vams,5|17): Memory or an array reference requires an index [3.8][4.2.2(IEEE)].
     module worklib.top:vams
           errors: 1, warnings: 0
irun: *E,VLGERR: An error occurred during parsing.  Review the log file for errors with the code *E and fix those identified problems to proceed.  Exiting with code (status 1).
Back to top
 
 

Regards
Subtr
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Code from Designer's Guide book throwing error
Reply #6 - Jan 4th, 2017, 4:12am
 
OK, the problem is because you're using a very old version of AMS Designer. IUS8.2 was released in late 2008/early 2009 - so the version  you're using is probably 8 years old. Why do you need to use something so old?

The first problem (with top.vams) can be fixed by changing the wire definition:

wire [7:0]in;

(i.e. put the array before the name rather than after), and then I see the original problem you were having.

If I use INCISIV13.1 (or later INCISIV12.2 releases) then it runs successfully. Even those are 3 or 4 years old.

I looked back and found that there was CCR 380353 which was related to parameters (bits in this case) not being supported in a genvar expression - and that was fixed in MMSIM12.1 timeframe. Note that the version of MMSIM you're using is irrelevant here because the analog solver with AMS comes from the IUS/INCISIVE stream, not the MMSIM (that's only used if you use spectre, APS or UltraSim).

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1
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.