Creating a Verilog model cellview in Cadence for a device using a lookup table is a quick and straightforward method to characterize any physical component.
Physical devices model are often required to simulate a full system or part of it in Cadence (or any other EDA). In my case, a solar cell model was crucial to simulate my solar energy harvester block.
In this article, I will explain with a practical example of how to create a functional cellviews of a solar cell model derived from real laboratory measurements in Cadence.
Contents
2 possibilities to Model…
You know the equations of the model
The easiest way to create a model is to obtain or calculate the equations that control the behavior of the device. Having established the mathematical model, it is straightforward to implement a Verilog model.
Using this method, I implement the model of a solar cell using an arctan function (inverse of the tangent). I explained how I created the mathematical model of the solar cell in detail in this other article.
You don’t know the equations
What happen if I don’t know the equations, I am not able to calculate them, or they are quite complex?
The solution is to measure the behavior of the block considering it as a black box. Afterwards, a lookup table with the measured results can be implemented. The Verilog code will automatically interpolate between the given points.
The Verilog model is built using the function $table_model. Of course, the more accurate measurements of the behavior with different inputs, the better the model will work.
The table with all the measured data can be stored on an external file as a matrix.
For me, the easiest and comfortable way to work is saving the model measurement data in an extra text file. By this way, the information can be updated or exchanged it in the future without modifying the Verilog model. Moreover, it is much straightforward to write or edit a file than enter the data via a hard-coded matrix inside the Verilog code.
How to create a Text File with the Measurements for the Model
The measurements data can be saved into a *.tbl file format, which stores structured data in tabular form. For example: my_data.tbl
To modify and create this tabular text files, I consider 2 easy golden rules:
- # is used for comments.
- The columns should be separated by tabs or spaces indiscriminately. For me, tabs are more visual.
In the following example, it can be seen clearly how a tabular file is constructed for a 2D matrix (x and f(x) ):
Multidimensional Matrixes
Three or more dimensions data matrix can also be implemented in the structured file. In the previous example, the measured data has only one output variable, one input x, and one output f(x). Multiple inputs are possible: 2 inputs x, y and one output f(x,y).
Note that to have a 2-D matrix, for each x point you need at least 2 values of y. If not the compiler could not interpolate (or extrapolate) and it gives you an error.
In this other file example, a 3-Dimensional matrix can be seen. Voltave (V), Light intensity and Current (I).
The interpolation in multiple input tables is a bit cumbersome. It can be possible that you can not interpolate between all the columns. You must have at least 2 cases for each point. You would have an error like that:
Found only sample points ‘y=300.000000’ when ‘x=0.000000’ for table model data of form output = F(x,y). Provide at least one more point with different ‘y’ value when ‘x=0.000000’ and try again.
You can solve this by setting the control string ‘D’ to select the closest point instead of interpolating or include more points.
Step by Step: Create a new Cell View in Cadence
The first step is to create a new cell in Cadence. I usually make a copy of a similar block, because it is faster to modify an already existing cell view than create a new from scratch.
- Create a new veriloga cell view, then copy and paste the code.
- Store the structured table with measurements into a text file *.tbl and save it into the library path of the cellview.
- Compile the code. After Cadence’s compilation with no error, Cadence will ask you to create a symbol with the pins. Say yes and create the symbol.
- Create an iconic symbol.
Then you have your fully functionally veriloga model.
The text file must be stored in the same path of the cell (inside the library) in the folder \veriloga
Note (as it is mentioned in the Verilog Language Reference page 84), the data file is not refreshed after a change. A workaround if you want to modify the data file, you can rename the file to force an update.
General Considerations
- You don’t need to sort out the table. The compiler will do it for you
- # start a commented line (and ignored by the compiler)
- If you modify the table data file, you must change the name of the file to force the compiler to read the new file again. If not it will use an old precompiled version of the table.
- Stay away from text editors like Libre Office to manipulate the *.tbl file, because it creates unreadable files for Cadence. It took me a long night straight to figure out this…
- The values of each column must be separated by spaces or tabs (or both). It does not matter.
- Blank lines are ignored too.
- The sample points of the table are real or integers.
- Namely, you can use the letters f, p, n, m, k, M … as usual in Cadence to refer to femto, pico, nano, etc. For example, ‘500m’ expression is equivalent to 0.5, ‘5M’ for 5000000 or 5E3 for 5000.
Example: Full Verilog Code of the Model
In the following example, a solar cell model is implemented based on the measurements under 5 light intensities. I added an enable signal (with active high), but I’ve never used it on the example.
For simplicity, the model is built with 2D matrixes stored in different files for each light intensity. So, the extrapolation is more intuitive and each light intensity can be updated independently.
Here is the full verilogams code:
/////////////////////////////////////////////////////////////////////////// // Engineer: Alberto Lopez // // Description: Verilog model of the solar cell photodiode // // Change history: 11/Sept/2019 // ///////////////////////////////////////////////////////////////////////////// `include "constants.vams" `include "disciplines.vams" module SolarCell_Table( EN, Vsolar, GND); input EN; electrical EN; output Vsolar; electrical Vsolar; output GND; electrical GND; //Curve parameters parameter real light =1; parameter real vthreshold = 0.6; real Vcp; real iout, itemp; real i1,i2, i3, i4, i5; integer en; analog begin @(initial_step) begin en = 0; end //Enable function @(cross(V(EN) -vthreshold,1)) begin if(V(EN)>=vthreshold) en = 1; else en = 0; end Vcp = V(Vsolar,GND)*1000; i1 = -$table_model (Vcp, "ph4_1.tbl", "1C")/1000000; i2 = -$table_model (Vcp, "ph4_2.tbl", "1C")/1000000; i3 = -$table_model (Vcp, "ph4_3.tbl", "1C")/1000000; i4 = -$table_model (Vcp, "ph4_4.tbl", "1C")/1000000; i5 = -$table_model (Vcp, "ph4_5.tbl", "1C")/1000000; // if(itemp <0 ) iout = itemp; // else iout = 0; case (light) 1: iout = i1; 2: iout = i2; 3: iout = i3; 4: iout = i4; 5: iout = i5; default: iout = 0; endcase if(en== 0) iout = 0; I(Vsolar,GND) <+ iout; end //analog endmodule
Simulation and Test bench
In the test bench, I like to include all the information as a comment to explain the functionality of the model.
The variable light can be modified in the properties’ menu of the instantiated cell. However, I included it as a simulation parameter (light = li) in Cadence for simplicity.
A transient simulation with a ramp sweep at the output (Vsolar) provide the behavior of the solar cell and the I-V curve. Note that the sign of the current is flipped and it saturates once it excesses the open-circuit voltage (around 410mV).
Conclusions
- Modeling physical devices accurately is essential for simulating and testing blocks or full systems.
- Using measurement data is particularly helpful when dealing with a complex or unknown mathematical model of the device.
- It is straightforward to create realistic veriloga models based on measurement data.
Documentation Sources
You can find a simple documentation example in the VerilogA reference, or you can see a more in deep explanation in the document “VAMS-LRM-2-4.pdf” in the section 9.21.
Hello Alberto,
I liked your approach of using tables in verilog. I am new to Cadence.
I have circuit designed in Cadence and I need to simulate it for my custom dataset. Is it possible to use verilog table approach to simulate the circuit the with custom data set?
Thanks
Hello Alberto,
how do you get ph4_1.tbl & ph4_2.tbl ??
and in cadence how did you add these tables?
kindly describe the steps.
Hi!
I wrote the files by myself based on lab measurements
Regards!