0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CMOSコード

Last updated at Posted at 2024-09-27
# Define the required constants and input parameters
import numpy as np

# Given constants and parameters
mu_n = 100e-4  # Electron mobility (cm^2/Vs) (Example value)
C_ox = 1e-8    # Oxide capacitance per unit area (F/cm^2) (Example value)
W = 10e-6      # Width of the MOSFET (m)
L = 2e-6       # Length of the MOSFET (m)
V_TN = 0.7     # Threshold voltage (V) (Example value)
V_A = 50       # Early voltage (V) (Example value)
R = 1e3        # Load resistance (Ohms) (Example value)
V_DD = 5       # Supply voltage (V) (Example value)

# Input the value of V_in (Input voltage)
V_in = 1.5     # Input voltage (V) (Example value)

# Calculate the drain current (I_DS)
I_DS = (mu_n * C_ox / 2) * (W / L) * (V_in - V_TN)**2 * (1 + V_DD / V_A)

# Calculate the output voltage (V_out)
V_out = V_DD - R * I_DS

# Print the results
print(f"Drain Current (I_DS): {I_DS:.4e} A")
print(f"Output Voltage (V_out): {V_out:.2f} V")


# Define the required constants and parameters
import numpy as np

# Given constants and parameters
mu_n = 100e-4  # Electron mobility (cm^2/Vs) (Example value)
C_ox = 1e-8    # Oxide capacitance per unit area (F/cm^2) (Example value)
W = 10e-6      # Width of the MOSFET (m)
L = 2e-6       # Length of the MOSFET (m)
R = 1e3        # Load resistance (Ohms) (Example value)
V_A = 50       # Early voltage (V) (Example value)
I_DS = 1e-3    # Drain current (A) (Example value)
V_out = 2.5    # Output voltage (V) (Example value)

# Calculate the voltage gain A_v
numerator = R * np.sqrt(2 * mu_n * C_ox * (W / L) * I_DS * (1 + V_out / V_A))
denominator = 1 + (R * I_DS) / V_A

A_v = -numerator / denominator

# Print the result
print(f"Voltage Gain (A_v): {A_v:.2f}")

# Define the required constants and parameters
import numpy as np

# Given constants and parameters (from the image)
mu_Cox = 224.1e-6     # Mobility * Oxide capacitance (A/V^2)
W_L_ratio = 10        # Width/Length ratio
V_eff = 0.2           # Effective voltage (V)
V_TN = 0.394          # Threshold voltage (V)
V_A = 29.3            # Early voltage (V)
V_GS = 0.9            # Gate-source voltage (V)
V_DS = 0.9            # Drain-source voltage (V)
RL_measured = 18.6e3  # Measured load resistance (Ohms)

# Calculate transconductance (g_m)
g_m = mu_Cox * W_L_ratio * (V_GS - V_TN)

# Calculate drain current (I_DS)
I_DS = (mu_Cox / 2) * W_L_ratio * (V_GS - V_TN)**2 * (1 + V_DS / V_A)

# Calculate drain conductance (g_d)
g_d = (mu_Cox / 2) * W_L_ratio * (V_GS - V_TN)**2 / V_A

# Calculate drain resistance (r_d)
r_d = V_A / I_DS

# Calculate load resistance (R_L)
R_L = 0.9 / g_m

# Print the results
print(f"Transconductance (g_m): {g_m:.4e} S")
print(f"Drain Current (I_DS): {I_DS:.4e} A")
print(f"Drain Conductance (g_d): {g_d:.4e} S")
print(f"Drain Resistance (r_d): {r_d:.2f} Ohms")
print(f"Calculated Load Resistance (R_L): {R_L:.2f} Ohms")
print(f"Measured Load Resistance (R_L_measured): {RL_measured:.2f} Ohms")

# 変数の定義
gm1 = 94.25e-6  # 単位:A/V
gm6 = 942.5e-6  # 単位:A/V
gds2 = 1/20     # 単位:S
gds4 = 1/20     # 単位:S
gds6 = 1/30     # 単位:S
gds7 = 1/30     # 単位:S
I5 = 25e-6      # 単位:A
I6 = 242e-6     # 単位:A

# ゲインの計算
numerator = 2 * gm1 * gm6
denominator = (gds2 + gds4) * I5 * (gds6 + gds7) * I6

Av = numerator / denominator

# ゲインをdBで表す
Av_dB = 20 * (Av)

# 結果の表示
print(f"ゲイン Av: {Av:.2f}")
print(f"ゲイン (dB): {Av_dB:.2f} dB")



# 変数定義(仮の値を使用)
gm1 = 94.25e-6  # A/V
gm6 = 942.5e-6  # A/V
gds2 = 1/20     # S
gds4 = 1/20     # S
gds6 = 1/30     # S
gds7 = 1/30     # S
I5 = 25e-6      # A
I6 = 242e-6     # A
V_A2 = 20       # V
V_A4 = 20       # V
V_A6 = 30       # V
V_A7 = 30       # V
Cc = 2e-12      # F
CL = 4e-12      # F
VDD = 5         # V
VT1 = 0.7       # V
VT3 = 0.7       # V
Vt5 = 0.7       # V
B5 = 0.5

# ゲイン Av1 の計算
Av1 = (-2 * gm1 / (1/V_A2 + 1/V_A4)) * I5
print(f"Av1: {Av1:.2e} (単位なし)")

# ゲイン Av2 の計算
Av2 = (-gm6 / (1/V_A6 + 1/V_A7)) * I6
print(f"Av2: {Av2:.2e} (単位なし)")

# Positive CMR の計算
Vin_max = VDD - Vt5 / B5 - abs(VT3) + VT1
print(f"Positive CMR Vin(max): {Vin_max:.2f} V")

# Negative CMR の計算
Vin_min = VGS = Vt5 / B5 + abs(VT1) + VDD  # 仮定としてVGS = VDDとする
print(f"Negative CMR Vin(min): {Vin_min:.2f} V")

# スルーレート (SR) の計算
SR = I5 / Cc
print(f"スルーレート SR: {SR:.2e} V/s")

# ゲイン帯域幅 (GB) の計算
GB = gm1 / Cc
print(f"ゲイン帯域幅 GB: {GB:.2e} Hz")

# 極 (p1, p2) の計算
p1 = -gds2 / Cc
p2 = gm6 / CL
print(f"極 p1: {p1:.2e} Hz")
print(f"極 p2: {p2:.2e} Hz")

# RHP zero の計算
z1 = gm6 / Cc
print(f"RHP zero z1: {z1:.2e} Hz")




import numpy as np
import matplotlib.pyplot as plt
from scipy import signal

# 変数の定義(仮の値を使用)
gm1 = 1e-3     # トランスコンダクタンス (A/V)
gm2 = 1e-3     # トランスコンダクタンス (A/V)
R1 = 10e3      # 抵抗値 (Ω)
R2 = 10e3      # 抵抗値 (Ω)
Cc = 2e-12     # キャパシタンス (F)
C1 = 1e-12     # キャパシタンス (F)
C2 = 3e-12     # キャパシタンス (F)

# 周波数応答の極とゼロ点の計算
p1 = gm2 / (R1 * R2 * Cc)  # 極 p1 の計算
p2 = -gm2 / (C1 * C2 + C2 * Cc + Cc * C1)  # 極 p2 の計算
z1 = gm2 / Cc  # ゼロ点 z1 の計算

# 伝達関数の分子と分母の係数を設定
numerator = [1, z1]  # 分子:ゼロ点 z1
denominator = [1, p1 + p2, p1 * p2]  # 分母:2つの極 p1 と p2

# 伝達関数の作成
system = signal.TransferFunction(numerator, denominator)

# 周波数応答の計算
w, mag, phase = signal.bode(system)

# ボード線図のプロット
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 6))

# ゲイン(Magnitude)のプロット
ax1.semilogx(w, mag)  # 周波数を対数軸にプロット
ax1.set_title('Bode Plot of the Amplifier')
ax1.set_ylabel('Magnitude (dB)')
ax1.grid(which='both', linestyle='--', linewidth=0.5)

# 位相(Phase)のプロット
ax2.semilogx(w, phase)  # 周波数を対数軸にプロット
ax2.set_xlabel('Frequency (rad/s)')
ax2.set_ylabel('Phase (degrees)')
ax2.grid(which='both', linestyle='--', linewidth=0.5)

# グラフを表示
plt.tight_layout()
plt.show()


import numpy as np
import matplotlib.pyplot as plt

# パラメータ設定
mu_p = 150e-3       # キャリア移動度 (m^2/Vs)
C_ox = 2.5e-3       # 酸化膜容量密度 (F/m^2)
W_L = 10            # トランジスタの幅/長さ比
I_TAIL = 20e-6      # 差動アンプの共通電流 (20 μA)
V_T = 26e-3         # 熱電圧 (26 mV)
n = 1.5             # サブスレッショルドスロープ係数

# 入力電圧範囲の設定 (差動入力電圧)
V_ID = np.linspace(-200e-3, 200e-3, 500)

# 強反転領域における出力電流 I_O の計算
I_O_strong = (mu_p * C_ox * W_L / 2) * (4 * I_TAIL / (mu_p * C_ox * W_L) - V_ID**2)

# 強反転領域における gm の計算
g_m_strong = (mu_p * C_ox * W_L / 2) * (4 * I_TAIL / (mu_p * C_ox * W_L) - 2 * V_ID)

# 弱反転領域における出力電流 I_O の計算
I_O_weak = I_TAIL / (1 + np.exp(-V_ID / (n * V_T))) - I_TAIL / (1 + np.exp(V_ID / (n * V_T)))

# 弱反転領域における gm の計算
g_m_weak = (I_TAIL / (n * V_T)) * (np.exp(-V_ID / (n * V_T)) + np.exp(V_ID / (n * V_T))) / \
           (1 + np.exp(-V_ID / (n * V_T)))**2

# プロット設定
fig, ax1 = plt.subplots(figsize=(10, 6))

# I_O のプロット
ax1.plot(V_ID * 1e3, I_O_strong * 1e6, label='Strong Inversion (I_O)', color='b')
ax1.plot(V_ID * 1e3, I_O_weak * 1e6, label='Weak Inversion (I_O)', color='b', linestyle='--')
ax1.set_xlabel('Differential Input Voltage V_ID (mV)')
ax1.set_ylabel('Output Current I_O (μA)')
ax1.tick_params(axis='y')
ax1.legend(loc='upper left')
ax1.grid(True)

# gm のプロット
ax2 = ax1.twinx()
ax2.plot(V_ID * 1e3, g_m_strong * 1e6, label='Strong Inversion (g_m)', color='r')
ax2.plot(V_ID * 1e3, g_m_weak * 1e6, label='Weak Inversion (g_m)', color='r', linestyle='--')
ax2.set_ylabel('Transconductance g_m (μS)')
ax2.tick_params(axis='y')
ax2.legend(loc='upper right')

plt.title('CMOS Differential Amplifier Characteristics: I_O and g_m')
plt.show()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?