BTP, memristor

CMOS-Memristor Hybrid Circuit for Edge Detection using NI Multisim and MATLAB

Hello, In this post, we will have a look at the following:

  • Setting up 180nm/100nm MOSFET Models in Multisim
  • Setting up a memristor model in NI MULTISIM
  • A CMOS-Memristor hybrid circuit for edge detection
  • Using MATLAB for image analysis

NI Multisim is an excellent tool for simulation of both analog and digital circuits. One reason I like it over LTSpice or PSpice is the ease with which one can simulate mixed-signal circuitry. Using Multisim along with MATLAB allows conversion of image(pixel by pixel) to its a corresponding discrete voltage signal and vice versa.

We can import PSPICE models to multisim using its component wizard. I’ll elaborate it further:

Setting up 180nm/100nm MOSFET Models in Multisim

Following is the code for NMOS and PMOS using 180nm fabrication technology:

Source: https://user.eng.umd.edu/~newcomb/courses/spring2010/303/tsmc180nmcmos.lib

.MODEL TSMC180nmN NMOS (                                LEVEL   = 7
+VERSION = 3.1            TNOM    = 27             TOX     = 4.1E-9
+XJ      = 1E-7           NCH     = 2.3549E17      VTH0    = 0.354505
+K1      = 0.5733393      K2      = 3.177172E-3    K3      = 27.3563303
+K3B     = -10            W0      = 2.341477E-5    NLX     = 1.906617E-7
+DVT0W   = 0              DVT1W   = 0              DVT2W   = 0
+DVT0    = 1.6751718      DVT1    = 0.4282625      DVT2    = 0.036004
+U0      = 327.3736992    UA      = -4.52726E-11   UB      = 4.46532E-19
+UC      = -4.74051E-11   VSAT    = 8.785346E4     A0      = 1.6897405
+AGS     = 0.2908676      B0      = -8.224961E-9   B1      = -1E-7
+KETA    = 0.021238       A1      = 8.00349E-4     A2      = 1
+RDSW    = 105            PRWG    = 0.5            PRWB    = -0.2
+WR      = 1              WINT    = 0              LINT    = 1.351737E-8
*+XL      = -2E-8          XW      = -1E-8         
+ DWG     = 1.610448E-9
+DWB     = -5.108595E-9   VOFF    = -0.0652968     NFACTOR = 2.4901845
+CIT     = 0              CDSC    = 2.4E-4         CDSCD   = 0
+CDSCB   = 0              ETA0    = 0.0231564      ETAB    = -0.058499
+DSUB    = 0.9467118      PCLM    = 0.8512348      PDIBLC1 = 0.0929526
+PDIBLC2 = 0.01           PDIBLCB = -0.1           DROUT   = 0.5224026
+PSCBE1  = 7.979323E10    PSCBE2  = 1.522921E-9    PVAG    = 0.01
+DELTA   = 0.01           RSH     = 6.8            MOBMOD  = 1
+PRT     = 0              UTE     = -1.5           KT1     = -0.11
+KT1L    = 0              KT2     = 0.022          UA1     = 4.31E-9
+UB1     = -7.61E-18      UC1     = -5.6E-11       AT      = 3.3E4
+WL      = 0              WLN     = 1              WW      = 0
+WWN     = 1              WWL     = 0              LL      = 0
+LLN     = 1              LW      = 0              LWN     = 1
+LWL     = 0              CAPMOD  = 2              XPART   = 0.5
+CGDO    = 7.7E-10        CGSO    = 7.7E-10        CGBO    = 1E-12
+CJ      = 1.010083E-3    PB      = 0.7344298      MJ      = 0.3565066
+CJSW    = 2.441707E-10   PBSW    = 0.8005503      MJSW    = 0.1327842
+CJSWG   = 3.3E-10        PBSWG   = 0.8005503      MJSWG   = 0.1327842
+CF      = 0              PVTH0   = 1.307195E-3    PRDSW   = -5
+PK2     = -1.022757E-3   WKETA   = -4.466285E-4   LKETA   = -9.715157E-3
+PU0     = 12.2704847     PUA     = 4.421816E-11   PUB     = 0
+PVSAT   = 1.707461E3     PETA0   = 1E-4           PKETA   = 2.348777E-3     )
.MODEL TSMC180nmP PMOS (                                LEVEL   = 7
+VERSION = 3.1            TNOM    = 27             TOX     = 4.1E-9
+XJ      = 1E-7           NCH     = 4.1589E17      VTH0    = -0.4120614
+K1      = 0.5590154      K2      = 0.0353896      K3      = 0
+K3B     = 7.3774572      W0      = 1E-6           NLX     = 1.103367E-7
+DVT0W   = 0              DVT1W   = 0              DVT2W   = 0
+DVT0    = 0.4301522      DVT1    = 0.2156888      DVT2    = 0.1
+U0      = 128.7704538    UA      = 1.908676E-9    UB      = 1.686179E-21
+UC      = -9.31329E-11   VSAT    = 1.658944E5     A0      = 1.6076505
+AGS     = 0.3740519      B0      = 1.711294E-6    B1      = 4.946873E-6
+KETA    = 0.0210951      A1      = 0.0244939      A2      = 1
+RDSW    = 127.0442882    PRWG    = 0.5            PRWB    = -0.5
+WR      = 1              WINT    = 5.428484E-10   LINT    = 2.468805E-8
*+XL      = -2E-8          XW      = -1E-8          
+DWG     = -2.453074E-8
+DWB     = 6.408778E-9    VOFF    = -0.0974174     NFACTOR = 1.9740447
+CIT     = 0              CDSC    = 2.4E-4         CDSCD   = 0
+CDSCB   = 0              ETA0    = 0.1847491      ETAB    = -0.2531172
+DSUB    = 1.5            PCLM    = 4.8842961      PDIBLC1 = 0.0156227
+PDIBLC2 = 0.1            PDIBLCB = -1E-3          DROUT   = 0
+PSCBE1  = 1.733878E9     PSCBE2  = 5.002842E-10   PVAG    = 15
+DELTA   = 0.01           RSH     = 7.7            MOBMOD  = 1
+PRT     = 0              UTE     = -1.5           KT1     = -0.11
+KT1L    = 0              KT2     = 0.022          UA1     = 4.31E-9
+UB1     = -7.61E-18      UC1     = -5.6E-11       AT      = 3.3E4
+WL      = 0              WLN     = 1              WW      = 0
+WWN     = 1              WWL     = 0              LL      = 0
+LLN     = 1              LW      = 0              LWN     = 1
+LWL     = 0              CAPMOD  = 2              XPART   = 0.5
+CGDO    = 7.11E-10       CGSO    = 7.11E-10       CGBO    = 1E-12
+CJ      = 1.179334E-3    PB      = 0.8545261      MJ      = 0.4117753
+CJSW    = 2.215877E-10   PBSW    = 0.6162997      MJSW    = 0.2678074
+CJSWG   = 4.22E-10       PBSWG   = 0.6162997      MJSWG   = 0.2678074
+CF      = 0              PVTH0   = 2.283319E-3    PRDSW   = 5.6431992
+PK2     = 2.813503E-3    WKETA   = 2.438158E-3    LKETA   = -0.0116078
+PU0     = -2.2514581     PUA     = -7.62392E-11   PUB     = 4.502298E-24
+PVSAT   = -50            PETA0   = 1E-4           PKETA   = -1.047892E-4    )

for 100nm, the MOSFET SPICE code can be found here.

The above code can be imported using the component wizard.
Note:- For MULTISIM, change the ‘LEVEL’ parameter in the above codes from 7 to 8.

Setting up a memristor model in NI MULTISIM

There are mainly 3 types of memristor models: Linear, Non-Linear, and TEAM. I mostly use a Non-linear model with Prodomakis or Jinxiang window functions. Have a look at my previous post for an overview of all available memristor models and window function.

Below is the Non-linear memristor model with jinxiang window function:

************************************
* Jinxiang non-linear memristor model
* 
* Please acknowledge when used.
* Written by :- Udit agarwal
************************************
.param ron = 100
.param roff = 16000
.param d = 40E-9
.param uv = 10E-15
.param p = 7
.param x0 = 0.076
.param j = 1
.param a = 0.9

Gx 0 x value={I(Emem)*uv*ron/d**2*f(V(x),I(Emem),p)}
Cx x 0 1
Raux x 0 1000000
 
Emem plus aux value={-I(Emem)*V(x)*(roff-ron)}
roff aux minus {roff}
 
Eflux flux 0 value={SDT(V(plus,minus))}
Echarge charge 0 value={SDT(I(Emem))}
 
* window function, according to Jinxiang
.func f(x,i,p)=j*{1-pow((a*pow((x - stp(-i)),(2*p)) + (1 - a)),(p))}

The above model can again be imported in Multisim using Component Wizard.

After importing the model, it can be verified using the following circuit:
Change in memristance concerning time can be seen in the adjoining graph, which thus confirms the working of the model.
Note- While performing transient analysis of the memristor model in Multisim,  change the initial condition setting to ‘User-defined’, otherwise simulation might not converge.

A CMOS-Memristor hybrid circuit for edge detection

  • This circuit is primarily a region segmentation circuit where a memristor can control the intensity of response.
  • It can be used for Edge detection, color extraction from an image, etc.
The output of the above Edge detection circuit, where the image on the right is the input image, and the one on the left is the output one.
Edge detection circuit

The complete circuit consists of 3 parts. First and the last part makes up the variable threshold NOT gate, which is responsible for setting up lower and upper limits between which whenever the input signal lies, output comes in the form of a spike.

Input and output signal of an edge detection circuit

Using MATLAB for image analysis

Here MATLAB is being used to convert an image sequentially(Pixel by Pixel) to an electrical discrete signal, which is then passed through the circuit. Circuit’s output is then converted using another script to the output image.

Below are the MATLAB scripts:

clc;
clear all;
img = imread('C:\Users\udit agarwal\Desktop\Memristor\guassian_sun.jpg');
img = imresize(img,[55 55],'bicubic');

% Convert a RGB to WB
if(size(img,3) == 3) img = rgb2gray(img); end;

img_serial = img(:);
size_1 = size(img_serial,1) - 1;
img_serial = im2uint16(img_serial);
img_serial = [0:1:(size_1) ; img_serial'];
img_serial = double(img_serial');
img_serial(:,2) = img_serial(:,2)./max(img_serial(:,2));
img_serial(:,2) = img_serial(:,2).*1.6;
img_serial(:,1) = img_serial(:,1)./200;

output can be probed from the img_serial variable.

clc;
clear;
a = csvread('C:\Users\udit agarwal\Desktop\Memristor\pixel_guassian_mem.csv');
b = [];
b = horzcat(b,a(:,1));
b = horzcat(b,a(:,2));
b = horzcat(b,a(:,5));
a = [];
for i=1:size(b,1)
if(mod(b(i),0.005) == 0) a = vertcat(a,b(i,:)); end;
end;
out = a(:,2)';
in = a(:,3)';
%Input data
dd_inp = [];
for j=0:(floor(sqrt(size(a,1))) - 1)
dd_inp = vertcat(dd_inp,in(55*j + 1:55*(j+1)));
end;
dd_inp = dd_inp./max(dd_inp(:));
dd_inp = dd_inp*255;
dd_inp = ceil(dd_inp);
%output data
dd_out = [];
for j=0:(floor(sqrt(size(a,1))) - 1)
dd_out = vertcat(dd_out,out(55*j + 1:55*(j+1)));
end;
dd_out = dd_out./max(dd_out(:));
dd_out = dd_out*255;
dd_out = ceil(dd_out);

subplot(1,2,1);
imshow(dd_inp,[0 255])
title('Input image');
subplot(1,2,2);
imshow(dd_out,[0 255])
title('Output image');

The output of the analog signal can be stored in a CSV file(line 3), which is then processed to convert it into an image.

Tagged , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.