-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Carsten Wulff | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
figs: | ||
cat dig_des.dot | dot -Tsvg > ../media/dig_des.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
digraph G{ | ||
|
||
rankdir="LR"; | ||
|
||
node [margin=0.5 color=blue fontcolor=black fontsize=20 width=0.5 shape=box fontname="Helvetica"] | ||
I [label="Idea",shape=egg] | ||
D [label="Digital Design \n SystemVerilog"] | ||
S [label="Digital Simulation \n iverilog/vpp/verilator/gtkwave"] | ||
PNR [label="RTL to GDSII \nOpenRoad"] | ||
TO [label="Tapeout",shape=egg] | ||
|
||
AD [label="Analog Design \nXschem" color=red] | ||
ASV [label="Analog Model \nSystemVerilog" color=blue] | ||
AS [label="Analog Simulation \nngspice" color=red] | ||
AL [label="Analog Layout \nMagic" color=red] | ||
AV [label="LVS\nnetgen" color=red] | ||
LPE [label="Parasitics\nMagic" color=red] | ||
AGDS [label="GDSII"] | ||
|
||
D -> S -> PNR -> TO | ||
PNR -> S -> D | ||
|
||
|
||
AD -> ASV -> D | ||
|
||
I -> AD | ||
I -> D | ||
|
||
AD -> AS -> AL -> AV -> AGDS -> PNR | ||
AV -> LPE -> AS | ||
AL -> AS -> AD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from scipy import constants | ||
pi = constants.pi | ||
h = constants.physical_constants["Planck constant"][0] | ||
alpha = constants.physical_constants["fine-structure constant"][0] | ||
c = constants.physical_constants["speed of light in vacuum"][0] | ||
me = constants.physical_constants["electron mass"][0] | ||
|
||
a0f = 0.528e-10 | ||
a0 = (2*pi*1/alpha * h/c/me) | ||
a1 = (1/alpha * h/c/me) | ||
print("a0f = %g"%a0f) | ||
print("a0 = %g"%a0) | ||
print("a1 = %g"%a1) | ||
print("a1/a0f = %g"%(a1/a0f)) | ||
|
||
|
||
a0m = (1/alpha * h/c/me/(2*pi)) | ||
print(a0m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
#- Create a time vector | ||
N = 2**13 | ||
t = np.linspace(0,N,N) | ||
|
||
#- Create the "continuous time" signal with multiple sinusoidal signals and some noise | ||
f1 = 3023/N | ||
fd = 1/N*119 | ||
x_s = np.sin(2*np.pi*f1*t) + 1/1024*np.random.randn(N) #+ 0.5*np.sin(2*np.pi*(f1-fd)*t) + 0.5*np.sin(2*np.pi*(f1+fd)*t) | ||
|
||
#- Create the sampling vector, and the sampled signal | ||
t_s_unit = [1,1,0,0,0,0,0,0] | ||
t_s = np.tile(t_s_unit,int(N/len(t_s_unit))) | ||
x_sn = x_s*t_s | ||
|
||
#- IIR filter | ||
b = 0.3 | ||
a = 0.25 | ||
z = a + 1j*b | ||
z_abs = np.abs(z) | ||
print("|z| = " + str(z_abs)) | ||
y = np.zeros(N) | ||
y[0] = a | ||
for i in range(1,N): | ||
y[i] = b*x_sn[i-1] + y[i-1] | ||
|
||
|
||
#- Convert to frequency domain with a hanning window to avoid FFT bin | ||
#- energy spread | ||
Hann = True | ||
if(Hann): | ||
w = np.hanning(N+1) | ||
else: | ||
w = np.ones(N+1) | ||
|
||
#X_s = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_s))) | ||
X_sn = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_sn))) | ||
Y = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],y))) | ||
|
||
|
||
plt.subplot(2,2,1) | ||
plt.plot(x_sn) | ||
plt.axis([1000,1400,-1,1]) | ||
plt.ylabel("Time Domain") | ||
plt.subplot(2,2,2) | ||
plt.plot(y) | ||
plt.axis([1000,1400,-1,1]) | ||
plt.subplot(2,2,3) | ||
plt.plot(20*np.log10(np.abs(X_sn))) | ||
plt.xlabel("Sampled") | ||
plt.ylabel("Frequency Domain") | ||
plt.subplot(2,2,4) | ||
plt.plot(20*np.log10(np.abs(Y))) | ||
plt.xlabel("IIR Filter") | ||
|
||
fig = plt.gcf() | ||
fig.set_size_inches(10, 7) | ||
plt.tight_layout() | ||
plt.savefig("l5_iir.svg") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
|
||
#- Create a time vector | ||
N = 2**13 | ||
t = np.linspace(0,N,N) | ||
|
||
#- Create the "continuous time" signal | ||
fbin = 10 | ||
fm1 = 1/N*213 | ||
f1 = 1/64 - 1/N | ||
fd = fm1 | ||
x_s = np.sin(2*np.pi*f1*t) + + 1/2**15*np.random.randn(N) | ||
|
||
#---------------------------------------------- | ||
#- Model an ADC | ||
#---------------------------------------------- | ||
|
||
## Sample | ||
#- Sampling frequency is 1/nfs of the time vector | ||
nfs = 4 | ||
x_sn = x_s[0::nfs] | ||
|
||
def adc(x,bits): | ||
levels = 2**bits | ||
y = np.round(x*levels)/levels | ||
return y | ||
|
||
# To discrete value | ||
bits = 10 | ||
y_sn = adc(x_sn,bits) | ||
|
||
#- Oversample | ||
OSR = 4 | ||
|
||
def oversample(x,OSR): | ||
|
||
N = len(x) | ||
y = np.zeros(N) | ||
|
||
for n in range(0,N): | ||
for k in range(0,OSR): | ||
m = n+k | ||
if(m < N): | ||
y[n] += x[m] | ||
return y | ||
|
||
y_on = oversample(y_sn,OSR) | ||
|
||
#---------------------------------------------- | ||
# Plot spectrum | ||
#---------------------------------------------- | ||
def freqDomain(x): | ||
N = len(x) | ||
# Use hanning window to prevent FFT bin energy spread | ||
w = np.hanning(N+1) | ||
|
||
# Convert to frequency domain | ||
X= np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x))) | ||
|
||
# Normalize to max output power | ||
X = X/np.max(np.abs(X)) | ||
return X | ||
X_s = freqDomain(x_s) | ||
X_sn = freqDomain(x_sn) | ||
Y_sn = freqDomain(y_sn) | ||
Y_on = freqDomain(y_on) | ||
|
||
plt.subplot(1,4,1) | ||
plt.plot(20*np.log10(np.abs(X_s))) | ||
plt.xlabel("Continuous time, continuous value") | ||
plt.ylabel("Frequency Domain") | ||
plt.ylim(-160,0) | ||
plt.subplot(1,4,2) | ||
plt.plot(20*np.log10(np.abs(X_sn))) | ||
plt.xlabel("Discrete time, continuous value") | ||
plt.ylim(-160,0) | ||
plt.subplot(1,4,3) | ||
plt.plot(20*np.log10(np.abs(Y_sn))) | ||
plt.xlabel("Discrete time, Discrete value") | ||
plt.text(np.round((1-1/4)*N/nfs),-10,str(bits) + "-bit") | ||
plt.ylim(-160,0) | ||
plt.subplot(1,4,4) | ||
plt.plot(20*np.log10(np.abs(Y_on))) | ||
plt.xlabel("Oversampled") | ||
plt.text(np.round((1-1/4)*N/nfs),-10,"OSR=" + str(OSR)) | ||
plt.ylim(-160,0) | ||
|
||
fig = plt.gcf() | ||
fig.set_size_inches(12, 7) | ||
plt.tight_layout() | ||
plt.savefig("l6_osr_" + str(OSR) + ".pdf") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
m = 1e-3 | ||
i_load = np.logspace(-5,-3) | ||
i_load = np.linspace(1e-5,1e-3,200) | ||
|
||
i_s = 1e-12 | ||
|
||
i_ph = 1e-3 | ||
|
||
V_T = 1.38e-23*300/1.6e-19 | ||
|
||
V_D = V_T*np.log((i_ph - i_load)/(i_s) + 1) | ||
|
||
P_load = V_D*i_load | ||
|
||
|
||
plt.subplot(2,1,1) | ||
plt.plot(i_load/m,V_D) | ||
|
||
plt.ylabel("Diode voltage [V]") | ||
plt.grid() | ||
plt.subplot(2,1,2) | ||
plt.plot(i_load/m,P_load/m) | ||
plt.xlabel("Current load [mA]") | ||
plt.ylabel("Power Load [mW]") | ||
plt.grid() | ||
plt.savefig("pv.pdf") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
#- Enable hanning window | ||
hann = True | ||
|
||
#- Create a time vector | ||
N = 2**13 | ||
t = np.linspace(0,N,N) | ||
|
||
#- Create the "continuous time" signal | ||
fdivide = 2**6 | ||
f1 = 1/fdivide - 1/N | ||
x_s = np.sin(2*np.pi*f1*t) + + 1/2**15*np.random.randn(N) | ||
|
||
#---------------------------------------------- | ||
#- Model an ADC | ||
#---------------------------------------------- | ||
|
||
## Sample | ||
#- Sampling frequency is 1/nfs of the time vector | ||
nfs = 4 | ||
x_sn = x_s[0::nfs] | ||
|
||
def adc(x,bits): | ||
levels = 2**bits | ||
y = np.round(x*levels)/levels | ||
return y | ||
|
||
# To discrete value | ||
bits = 1 | ||
y_sn = adc(x_sn,bits) | ||
|
||
#---------------------------------------------- | ||
# Plot spectrum | ||
#---------------------------------------------- | ||
def freqDomain(x,hann=True): | ||
N = len(x) | ||
# Use hanning window to prevent FFT bin energy spread | ||
if(hann): | ||
w = np.hanning(N+1) | ||
else: | ||
w = np.ones(N+1) | ||
|
||
# Convert to frequency domain | ||
X= np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x))) | ||
|
||
# Normalize to max output power | ||
X = X/np.max(np.abs(X)) | ||
return X | ||
|
||
|
||
X_s = freqDomain(x_s,hann) | ||
X_sn = freqDomain(x_sn,hann) | ||
Y_sn = freqDomain(y_sn,hann) | ||
|
||
M = len(Y_sn) | ||
f_xs = np.arange(0,N,1) - N/2 | ||
f_xn = np.arange(0,M,1) - M/2 | ||
|
||
plt.subplot(1,3,1) | ||
plt.plot(f_xs,20*np.log10(np.abs(X_s))) | ||
plt.xlabel("Continuous time, continuous value") | ||
plt.ylabel("Frequency Domain") | ||
plt.ylim(-160,0) | ||
plt.subplot(1,3,2) | ||
plt.plot(f_xn,20*np.log10(np.abs(X_sn))) | ||
plt.xlabel("Discrete time, continuous value") | ||
plt.ylim(-160,0) | ||
plt.subplot(1,3,3) | ||
plt.plot(f_xn,20*np.log10(np.abs(Y_sn))) | ||
plt.xlabel("Discrete time, Discrete value") | ||
plt.text(M*1/5,-20,str(bits) + "-bit\nf1 =" + str(int(f1*N)) + "\nf3 =" + str(int(f1*N*3)) + "\nf5 =" + str(int(f1*N*5)) ) | ||
plt.ylim(-160,0) | ||
|
||
fig = plt.gcf() | ||
fig.set_size_inches(12, 7) | ||
plt.tight_layout() | ||
plt.savefig("l6_quant.pdf") | ||
plt.show() |
Oops, something went wrong.