The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 1st, 2024, 10:10am
Pages: 1
Send Topic Print
syntax error `include (Read 3670 times)
billtsang
New Member
*
Offline



Posts: 1

syntax error `include
Jan 07th, 2006, 9:34am
 
Hi,
I got syntax error when i " `include "constants.h" ". Can anyone point out the reason.


Error found by spectre during AHDL read-in.
   "th.def", line 10: "`<<--? include "constants.h""
   "th.def", line 10: Error: syntax error
   "th.def", line 14: "electrical <<--? Pin, Nin, Pout, Nout ;"
   "th.def", line 14: Error: invalid module terminal type (*undef*) for
       Pout.
   "th.def", line 14: Error: invalid module terminal type (*undef*) for
       Nout.
   "th.def", line 14: Error: invalid module terminal type (*undef*) for Pin.
   "th.def", line 14: Error: invalid module terminal type (*undef*) for Nin.
   "th.def", line 14: Error: syntax error
   Maximum allowable errors exceeded.  Exiting SpectreHDL compilation....

// Periodic Track & Hold
//
// Works with SpectreRF (has no hidden state)
// Almost ideal ...
//    Has buffered input and output (infinite input Z, zero out Z)
//    Exhibits no offset or distortion errors
//    Only nonideality is finite aperture time and very small amount of droop


`include "constants.h"
`include "disciplines.h"

module th (Pout, Nout, Pin, Nin) (period, delay, aperture, tc)
electrical Pin, Nin, Pout, Nout ;
input Pin, Nin;
output Pout, Nout;
parameter real period=16n from (0:inf);
parameter real delay=0 from (0:inf);
parameter real aperture=period/2 from (0:period/2);
parameter real tc=aperture/10 from (0:aperture);

integer n;
real tstart, tstop;
electrical hold;

   analog begin

// Determine the point where the aperture begins;
     n = ($abstime - delay + aperture) / period + 0.5;
     tstart = n*period + delay - aperture;
     @(timer(tstart));

// Determine the time where the aperture ends;
     n = ($abstime - delay) / period + 0.0;
     tstop = n*period + delay;
     @(timer(tstop));

// Implement switch with effective series resistence of 1 Ohm
     if (($abstime > tstop - aperture) && ($abstime <= tstop))
         I(hold) <+ V(hold) - V(Pin, Nin);
     else
         I(hold) <+ 1.0e-12 * V(hold);

// Implement capacitor with an effective capacitance of tc
     I(hold) <+ tc * ddt(V(hold));

// Buffer output
     V(Pout, Nout) <+ V(hold);

// Control time step tightly during aperture and loosely otherwise
     if (($abstime >= tstop - aperture) && ($abstime < tstop)) begin
         $bound_step(tc);
     end else begin
         $bound_step(period/5);
     end

   end
endmodule

Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

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

Posts: 1742
Bracknell, UK
Re: syntax error `include
Reply #1 - Jan 9th, 2006, 11:38am
 
A few points:

1. Don't give the filename the suffix ".def". This tells the ahdl_include in spectre that the file is spectreHDL, not
   Verilog-A. Your code is (mostly) VerilogA - the bits which aren't is probably a mistake...
2. You list the parameter names on the module line. That's spectreHDL syntax, and shouldn't be there for Verilog-A.
   So the module line should just be:
Code:
module th (Pout, Nout, Pin, Nin); 


3. Put the electrical definition after the port directions. It will work in spectre (with a warning these days), but in other tools they may be more strict and require the port direction before the discipline. For example:
Code:
module th (Pout, Nout, Pin, Nin);
input Pin, Nin;
output Pout, Nout;
electrical Pin, Nin, Pout, Nout ; 


4. delay is a reserved word. I had to change the parameter to something else (I used "del").
Back to top
 
 
View Profile WWW   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

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

Posts: 1742
Bracknell, UK
Re: syntax error `include
Reply #2 - Jan 9th, 2006, 11:39am
 
I meant to say that after all that, it compiles in both spectre and AMS Designer. I didn't check that the code works  8-)

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
jbdavid
Community Fellow
*****
Offline



Posts: 378
Silicon Valley
Re: syntax error `include
Reply #3 - Jan 10th, 2006, 4:41am
 
In verilog - the parameters (if included in the module declaration header ) go BEFORE the pin declarations..
I've never used this feaure of Verilog2001 ..
jbd
Back to top
 
 

jbdavid
Mixed Signal Design Verification
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.