The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Design Languages >> Verilog-AMS >> MATLAB to Cadence https://designers-guide.org/forum/YaBB.pl?num=1273839104 Message started by e.fisher on May 14th, 2010, 5:11am |
Title: MATLAB to Cadence Post by e.fisher on May 14th, 2010, 5:11am Hello. I have a pulse train of events in time saved to an ASCII file. I wish to use Verilog or Verilog-A to produce a block that will give a logical '1' when the simulator time matches values in the ASCII file. My ASCII file looks like this: 5.062e-06 8.687e-06 1.376e-05 1.649e-05 2.190e-05 2.195e-05 3.462e-05 5.112e-05 (... etc) I have the following code but get syntax errors on lines I'm sure are right (as per the 2008 version of the Verilog manual): module Matlab_Ctrl_In(Vp); output Vp; voltage Vp; parameter string FILEPATH = "/home/s0458323/matlab/SPAD_Comms_Models_2/FullSystemSimData/ToCadence/"; parameter string FILENAME = "ArrivalTrainOutMAT_tT_100_14-05-2010_123609.txt"; parameter real ModFreq = 1e2; parameter real SampleRatio = 100; parameter real Fs = ModFreq*SampleRatio*2; parameter real DeltaT = 1/Fs; parameter string T_pulse = "0.000"; integer fd; real code = 0; fd = $fopen({FILEPATH,FILENAME}, "r"); analog begin code = %gets(T_pulse,fd) T_now = $abstime; @(timer(T_now, T_step)) begin if (T_pulse >= T_now && T_pulse <= T_now+T_step) begin V(Vp) <+ 1; end end end endmodule The code is to be used with a model of a diode that breaks down at specific times, as controlled by a MATLAB model that simulates Poisson inter-arrival times, and various other effects. It should be a simple matter of reading the next line of the ASCII file and checking to see if it has occurred, along with a fast repetition rate to ensure all events are timed correctly. Any help would be a massive massive help. Ed Fisher |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 14th, 2010, 7:37am I don't think the %gets() is correct Verilog - it surely isn't correct Verilog-A. Marq |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 14th, 2010, 7:42am Setting the T_now to $abstime and then using T_now immediately in a timer event is not helping either: the timer event will trigger at each time step, and most likely the T_now gets updated before the first T_step is ever reached. This is not a syntax error, however, it just makes your code behave badly or not at all... The line with code = %gets() also misses a semicolon at the end. Marq |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 14th, 2010, 7:44am The $fopen outside the analog block isn't allowed Verilog/Verilog-A syntax either... Sorry, but your code seems to be riddled with basic syntax errors. I'm not sure what simulator you are using but I would pay attention to the error messages it produces. Marq |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 14th, 2010, 7:58am Just another try: assuming the data in the file are strictly monotonous the following code will read each line in order and not start reading the next line until the current line has been matched. It assumes that the time values in the data file are all at least T_step apart. Code:
Marq |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 14th, 2010, 8:00am Sorry, copied too much of the original code without checking. T_pulse should not be a parameter and not be a string. It should be a real variable. T_step is not defined either, but I presume it is equal to DeltaT. Marq |
Title: Re: MATLAB to Cadence Post by e.fisher on May 14th, 2010, 8:03am Ok so first things first. I have changed the MATLAB to output hex values to make getting the data into verilog easier. First I need a string parameter set to a default value, that can be changed from the cds window like a parameter real vdd etc. module Matlab_Ctrl_In(Vp); output Vp; voltage Vp; parameter real VDD = 1.2; parameter string default_name = "John Smith"; endmodule This gives a syntax error for the string but this is actually directly taken from the manual. Any help before i move onto getting hex data to memory . Thanks. |
Title: Re: MATLAB to Cadence Post by e.fisher on May 14th, 2010, 8:05am Ok thanks will give that a try. Thanks. |
Title: Re: MATLAB to Cadence Post by e.fisher on May 14th, 2010, 8:18am I just don't get verilog-a. Just put the above in and compiled it, the line parameter string FILEPATH, gives me an error straight away. Why would it do that, is it the compiler? Cadence is using SpectreHDL compiler. I've used verilog-a before but not file i/o, strings or time based events. Cheers. Ed |
Title: Re: MATLAB to Cadence Post by Marq Kole on May 17th, 2010, 2:37am Hi Ed, Which version of Spectre are you using? You will need to use a recent version from the MMSIM stream, for instance 7.1 or later. Spectre 6.1 is still palatable, but earlier versions lack a lot of recent features such as string parameter support. Cheers, Marq |
Title: Re: MATLAB to Cadence Post by e.fisher on May 17th, 2010, 2:47am Looks like version 5.10.41. Thanks for your help, if the department doesn't support it, there isn't much I can do. Thanks. Ed |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |