CMOS OPアンプ回路 実務設計の基礎

https://www.amazon.co.jp/CMOS-OP%E3%82%A2%E3%83%B3%E3%83%97%E5%9B%9E%E8%B7%AF%E5%AE%9F%E5%8B%99%E8%A8%AD%E8%A8%88%E3%81%AE%E5%9F%BA%E7%A4%8E%E2%80%95%E3%81%93%E3%82%8C%E3%81%8B%E3%82%89%E3%82%A2%E3%83%8A%E3%83%AD%E3%82%B0IC%E8%A8%AD%E8%A8%88%E3%82%92%E5%AD%A6%E3%81%B6%E4%BA%BA%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE-%E5%8D%8A%E5%B0%8E%E4%BD%93%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA-%E5%90%89%E6%BE%A4-%E6%B5%A9%E5%92%8C/dp/4789830276



P19
単位面積あたりのゲート容量
```
# Constants
epsilon_0 = 8.854e-14  # Permittivity of free space in F/cm
kappa_ox = 3.9         # Relative permittivity of SiO2
t_ox = 10e-7           # Oxide thickness in cm (adjust as needed)

# Calculate the gate capacitance per unit area
Cox = (epsilon_0 * kappa_ox) / t_ox

# Output the result
print(f"Gate capacitance per unit area (Cox): {Cox:.4e} F/cm^2")

```
p25
```
# 定数とパラメータの設定
mu_p = 100e-6  # キャリア移動度 (例: 100e-6 m^2/Vs)
C_ox = 10e-9   # 酸化膜容量 (例: 10e-9 F/m^2)
W = 10e-6      # トランジスタの幅 (例: 10e-6 m)
L = 1e-6       # トランジスタの長さ (例: 1e-6 m)
V_TP = -0.7    # PMOSトランジスタの閾値電圧 (例: -0.7 V)
V_SD = -0.2    # ソース-ドレイン間電圧 (例: -0.2 V)
V_SG = -1.0    # ソース-ゲート間電圧 (例: -1.0 V)

# 非飽和領域のドレイン電流 (1-7式)
def drain_current_linear(mu_p, C_ox, W, L, V_SG, V_TP, V_SD):
    return mu_p * C_ox * (W / L) * ((V_SG - V_TP) * V_SD - 0.5 * V_SD**2)

# 飽和領域のドレイン電流 (1-8式)
def drain_current_saturation(mu_p, C_ox, W, L, V_SG, V_TP):
    return 0.5 * mu_p * C_ox * (W / L) * (V_SG - V_TP)**2

# 非飽和領域のドレイン電流 (PMOS式 1-9)
def drain_current_pmos_linear(mu_p, C_ox, W, L, V_GS, V_TP, V_DS):
    return mu_p * C_ox * (W / L) * ((abs(V_GS) - abs(V_TP)) * abs(V_DS) - 0.5 * abs(V_DS)**2)

# 飽和領域のドレイン電流 (PMOS式 1-10)
def drain_current_pmos_saturation(mu_p, C_ox, W, L, V_GS, V_TP, V_DS):
    return 0.5 * mu_p * C_ox * (W / L) * (abs(V_GS) - abs(V_TP))**2

# ドレイン電流を計算
I_D_linear = drain_current_linear(mu_p, C_ox, W, L, V_SG, V_TP, V_SD)
I_D_saturation = drain_current_saturation(mu_p, C_ox, W, L, V_SG, V_TP)
I_D_pmos_linear = drain_current_pmos_linear(mu_p, C_ox, W, L, V_SG, V_TP, V_SD)
I_D_pmos_saturation = drain_current_pmos_saturation(mu_p, C_ox, W, L, V_SG, V_TP, V_SD)

# 結果の表示
print(f"非飽和領域のドレイン電流 (1-7式) I_D = {I_D_linear:.6e} A")
print(f"飽和領域のドレイン電流 (1-8式) I_D = {I_D_saturation:.6e} A")
print(f"PMOS非飽和領域のドレイン電流 (1-9式) I_D = {I_D_pmos_linear:.6e} A")
print(f"PMOS飽和領域のドレイン電流 (1-10式) I_D = {I_D_pmos_saturation:.6e} A")


```
p28
```
# 定数とパラメータの設定
mu = 100e-6  # キャリア移動度 (例: 100e-6 m^2/Vs)
C_ox = 10e-9  # 酸化膜容量 (例: 10e-9 F/m^2)
W = 10e-6     # トランジスタの幅 (例: 10e-6 m)
L = 1e-6      # トランジスタの長さ (例: 1e-6 m)
Delta_L = 0.1e-6  # 空乏層幅 Delta L (例: 0.1e-6 m)
V_GS = 1.2    # ゲート-ソース間電圧 (例: 1.2 V)
V_T = 0.6     # 閾値電圧 V_T (例: 0.6 V)
V_DS = 0.3    # ドレイン-ソース間電圧 (例: 0.3 V)

# (1-12) 式: チャネル長変調を考慮した非飽和領域のドレイン電流
def drain_current_with_channel_modulation(mu, C_ox, W, L, Delta_L, V_GS, V_T):
    return 0.5 * mu * C_ox * (W / (L - Delta_L)) * (V_GS - V_T)**2

# (1-13) 式: チャネル長変調を考慮しない非飽和領域のドレイン電流
def drain_current_without_channel_modulation(mu, C_ox, W, L, V_GS, V_T):
    return 0.5 * mu * C_ox * (W / L) * (V_GS - V_T)**2

# (1-14) 式: ピンチオフ点における電圧の式
def pinch_off_voltage(V_GS, V_T, Delta_L):
    return (V_GS - V_T) / (1 - (Delta_L / L))

# (1-16) 式: チャネルの横方向電界 E の計算
def channel_field(V_DS, L):
    return V_DS / L

# 各式に基づく計算
I_D_with_modulation = drain_current_with_channel_modulation(mu, C_ox, W, L, Delta_L, V_GS, V_T)
I_D_without_modulation = drain_current_without_channel_modulation(mu, C_ox, W, L, V_GS, V_T)
V_pinch_off = pinch_off_voltage(V_GS, V_T, Delta_L)
E_field = channel_field(V_DS, L)

# 結果の表示
print(f"チャネル長変調を考慮したドレイン電流 (1-12式) I_D = {I_D_with_modulation:.6e} A")
print(f"チャネル長変調を考慮しないドレイン電流 (1-13式) I_D = {I_D_without_modulation:.6e} A")
print(f"ピンチオフ点における電圧 (1-14式) V_pinch_off = {V_pinch_off:.6f} V")
print(f"チャネルの横方向電界 (1-16式) E_field = {E_field:.6e} V/m")

```

P30
```

import numpy as np
import matplotlib.pyplot as plt

# Define MOSFET parameters
mu_n = 200e-4  # Electron mobility (cm^2/Vs converted to m^2/Vs)
C_ox = 10e-9  # Oxide capacitance per unit area (F/m^2)
W = 10e-6  # Width of the MOSFET (m)
L = 1e-6   # Length of the MOSFET (m)
V_GS = 1.8  # Gate-source voltage (V)
V_th = 0.2  # Threshold voltage (V)
lambda_param = 0.2  # Channel-length modulation parameter (1/V)

# Calculate process-dependent parameter K
K = (1/2) * mu_n * C_ox * (W / L)

# Create a range of V_DS values
V_DS = np.linspace(0, 5, 500)  # Drain-source voltage range from 0 to 5 V

# Calculate I_D using the saturation region equation with channel-length modulation
I_D = K * (V_GS - V_th)**2 * (1 + lambda_param * V_DS)

# Plot I_D vs V_DS
plt.figure(figsize=(8, 6))
plt.plot(V_DS, I_D, label=f'V_GS = {V_GS} V', color='b')
plt.title('MOSFET Drain Current with Channel-Length Modulation')
plt.xlabel('V_DS (V)')
plt.ylabel('I_D (A)')
plt.grid(True)
plt.legend()
plt.show()

```

P32
```
import numpy as np

# Constants
q = 1.60219e-19  # Elementary charge in C
epsilon_0 = 8.854e-12  # Permittivity of free space in F/m
epsilon_si = 11.7  # Relative permittivity of silicon
N_sub = 1e17  # Substrate doping concentration in m^-3 (example value)
C_ox = 2.3e-3  # Oxide capacitance per unit area in F/m^2 (example value)

# Calculate gamma
gamma = np.sqrt((2 * q * epsilon_0 * epsilon_si * N_sub) / C_ox)

# Parameters for threshold voltage calculation
phi_F = 0.3  # Fermi potential in V (example value)
V_SB = 0.2  # Source-bulk voltage in V (example value)
V_T0 = 0.5  # Threshold voltage without body effect in V (example value)

# NMOS Threshold Voltage with Body Effect
V_TN = V_T0 + gamma * (np.sqrt(2 * phi_F + V_SB) - np.sqrt(2 * phi_F))

# PMOS Threshold Voltage with Body Effect (Assuming same gamma)
V_TP = V_T0 - gamma * (np.sqrt(2 * phi_F - V_SB) - np.sqrt(2 * phi_F))

print(f"Gamma (γ): {gamma:.3f} V^0.5")
print(f"NMOS Threshold Voltage (V_TN): {V_TN:.3f} V")
print(f"PMOS Threshold Voltage (V_TP): {V_TP:.3f} V")
```



P33
抵抗に必ず生じる熱雑音、ホワイトノイズ、MOSトランジスタの熱雑音電圧、フリッカ雑音、熱雑音電流、移動度のゆらぎ
```

import numpy as np

# Constants
k_B = 1.38e-23        # Boltzmann constant in J/K
T = 300               # Temperature in Kelvin
R = 1e3               # Resistance in ohms (adjust as needed)
delta_f = 1e3         # Bandwidth in Hz (adjust as needed)
gamma = 2/3           # Process-dependent constant for MOSFETs (adjust as needed)
g_m = 1e-3            # Transconductance in S (adjust as needed)
W = 1e-6              # Channel width in meters (adjust as needed)
L = 1e-6              # Channel length in meters (adjust as needed)
Cox = 1e-8            # Gate capacitance per unit area in F/cm^2 (adjust as needed)
Kf = 1e-25            # Flicker noise coefficient (adjust as needed)
alpha_H = 2e-3        # Hooge's constant (adjust as needed)
N = 1e21              # Number of charge carriers (adjust as needed)
V = 1.2               # Applied voltage in V (adjust as needed)

# Thermal noise voltage in resistor
v_n_resistor = np.sqrt(4 * k_B * T * R * delta_f)

# Thermal noise voltage in MOSFET
v_n_mosfet = np.sqrt(4 * k_B * T * gamma * (1 / g_m) * delta_f)

# Flicker noise in MOSFET
S_V_flicker = (Kf / (W * L * Cox)) * (1 / delta_f)

# Thermal noise current in MOSFET
i_n_mosfet = np.sqrt(4 * k_B * T * gamma * g_m * delta_f)

# Mobility fluctuations (Hooge's Law)
S_V_mobility = (alpha_H / N) * (V**2 / delta_f)

# Print results
print(f"Thermal noise voltage (Resistor): {v_n_resistor:.4e} V")
print(f"Thermal noise voltage (MOSFET): {v_n_mosfet:.4e} V")
print(f"Flicker noise (MOSFET): {S_V_flicker:.4e} V^2/Hz")
print(f"Thermal noise current (MOSFET): {i_n_mosfet:.4e} A")
print(f"Mobility fluctuations (Hooge's Law): {S_V_mobility:.4e} V^2/Hz")


```




P41

```

import numpy as np

# Constants and parameters
mu = 1e-3  # Mobility in m^2/Vs (example value)
Cox = 1e-8  # Oxide capacitance per unit area in F/m^2 (example value)
W = 10e-6  # Channel width in meters
L = 1e-6  # Channel length in meters
VGS = 1.5  # Gate-source voltage in Volts
VT = 0.7  # Threshold voltage in Volts
lambda_val = 0.02  # Channel length modulation parameter (example value)
VDS = 2.0  # Drain-source voltage in Volts
ID = 1e-3  # Drain current in Amperes (example value)
gamma = 0.4  # Bulk threshold parameter (example value)
phi_F = 0.3  # Surface potential in Volts (example value)
VSB = 0.5  # Source-bulk voltage in Volts

# Transconductance gm (considering lambda VDS)
gm_with_lambda = mu * Cox * (W / L) * (VGS - VT) * (1 + lambda_val * VDS)

# Transconductance gm (ignoring channel length modulation)
gm_without_lambda = mu * Cox * (W / L) * (VGS - VT)

# Transconductance gm using drain current ID
gm_id = np.sqrt(2 * mu * Cox * (W / L) * ID) / np.sqrt(1 + lambda_val * VDS)

# Simplified gm (when lambda VDS is small)
gm_simplified = np.sqrt(2 * mu * Cox * (W / L) * ID)

# Bulk transconductance gmb
gmb = gamma * gm_simplified / np.sqrt(2 * np.abs(phi_F) + VSB)

# Drain conductance gd
gd = (lambda_val * ID) / (1 + lambda_val * VDS)

# Output the calculated values
print(f"gm with lambda: {gm_with_lambda} S")
print(f"gm without lambda: {gm_without_lambda} S")
print(f"gm using ID: {gm_id} S")
print(f"Simplified gm: {gm_simplified} S")
print(f"Bulk transconductance gmb: {gmb} S")
print(f"Drain conductance gd: {gd} S")


```

P42

```
# 定数（例としての値、実際の値に置き換えてください）
mu = 1e-2       # 移動度 (m^2/Vs)
C_OX = 2e-8     # 酸化膜容量 (F/m^2)
W = 10e-6       # チャンネル幅 (m)
L = 2e-6        # チャンネル長 (m)
V_GS = 1.8      # ゲート-ソース電圧 (V)
V_T = 0.7       # 閾値電圧 (V)
gamma = 0.5     # ボディ効果係数
lambda_param = 0.02  # チャンネル長変調パラメータ (V^-1)
I_D = 1e-3      # ドレイン電流 (A)
V_DS = 1.0      # ドレイン-ソース電圧 (V)

# 計算
g_m = mu * C_OX * (W / L) * (V_GS - V_T)
g_mb = gamma * g_m
g_d = lambda_param * I_D / (1 + lambda_param * V_DS)

# 小信号ドレイン電流の計算
v_gs = 0.01  # 小信号入力電圧の例 (V)
v_bs = 0.01
v_ds = 0.01
i_d = g_m * v_gs + g_mb * v_bs + g_d * v_ds

# 結果の出力
print(f"トランスコンダクタンス g_m: {g_m:.5e} S")
print(f"バルク・トランスコンダクタンス g_mb: {g_mb:.5e} S")
print(f"ドレインコンダクタンス g_d: {g_d:.5e} S")
print(f"小信号ドレイン電流 i_d: {i_d:.5e} A")

```

P44
```
import numpy as np
import matplotlib.pyplot as plt

# 定数
I_0 = 1e-6      # プロセスに依存する定数 (A)
W = 10e-6       # チャンネル幅 (m)
L = 2e-6        # チャンネル長 (m)
q = 1.6e-19     # 電子の電荷 (C)
V_T = 0.7       # 閾値電圧 (V)
k = 1.38e-23    # ボルツマン定数 (J/K)
T = 300         # 温度 (K)
V_DS = 1.0      # ドレイン-ソース電圧 (V)
C_d = 1e-12     # 空乏層容量 (F)
C_ox = 2e-8     # ゲート酸化膜容量 (F/m^2)

# スロープ・ファクタの計算
n = 1 + (C_d / C_ox)

# V_GS の範囲を定義
V_GS = np.linspace(0, 1.5, 500)

# ドレイン電流 I_D の計算
I_D = I_0 * (W / L) * np.exp(q * (V_GS - V_T) / (n * k * T)) * (1 - np.exp(-q * V_DS / (k * T)))

# プロット
plt.plot(V_GS, I_D)
plt.xlabel('Gate-Source Voltage V_GS (V)')
plt.ylabel('Drain Current I_D (A)')
plt.title('Drain Current vs. Gate-Source Voltage (Weak Inversion)')
plt.grid(True)
plt.yscale('log')  # I_D が指数関数的に増加するので、y軸を対数スケールに設定
plt.show()

```



P45
S＝2.3n(kT/q)
gm＝(q/(nkT))ID

VGS＝VTh+2n(kT/q)
n＝1.5と T＝300K
```
# Constants
k = 1.38e-23         # Boltzmann constant in J/K
q = 1.6e-19          # Elementary charge in C
n = 1.5              # Subthreshold slope factor
T = 300              # Temperature in Kelvin
ID = 1e-6            # Drain current I_D in A (example value, adjust as needed)
VTh = 0.5            # Threshold voltage V_Th in V (example value, adjust as needed)

# Calculate S
S = 2.3 * n * (k * T / q)

# Calculate gm
gm = (q / (n * k * T)) * ID

# Calculate VGS
VGS = VTh + 2 * n * (k * T / q)

# Output the results
print(f"Thermal Voltage S: {S:.4e} V")
print(f"Transconductance gm: {gm:.4e} S")
print(f"Gate-Source Voltage VGS: {VGS:.4e} V")


```
P59
ポリシリコン抵抗、シート抵抗

```
# Constants
rho = 1e-5          # Resistivity of polysilicon in ohm-meters (example value, adjust as needed)
L = 10e-6           # Length of the resistor in meters (example value, adjust as needed)
W = 2e-6            # Width of the resistor in meters (example value, adjust as needed)
t = 200e-9          # Thickness of the polysilicon film in meters (example value, adjust as needed)

# Calculate the cross-sectional area
A = W * t

# Calculate the resistance R
R = rho * (L / A)

# Calculate the sheet resistance Rs
Rs = rho / t

# Alternatively, calculate R using sheet resistance Rs and L/W ratio
R_alternative = Rs * (L / W)

# Output the results
print(f"Resistance R: {R:.4e} ohms")
print(f"Sheet Resistance Rs: {Rs:.4e} ohms per square")
print(f"Alternative Resistance R (using Rs): {R_alternative:.4e} ohms")

```
P72
```
# 定数の設定
V_DD = 5.0  # 電源電圧 (例: 5V)
V_BIAS = 1.2  # バイアス電圧 (例: 1.2V)
V_TP = -0.7   # PMOSトランジスタの閾値電圧 (例: -0.7V)
V_OUT = 3.0   # 出力電圧 (例: 3V)

# 飽和条件を満たすためのV_SDの計算
def calculate_vsd(V_SG, V_TP):
    return abs(V_SG) - abs(V_TP)

# 最大出力電圧の計算
def calculate_vout_max(V_DD, V_BIAS, V_TP):
    return V_DD - V_BIAS + abs(V_TP)

# 最小出力電圧の計算
def calculate_vout_min(V_DD, V_BIAS, V_TP):
    return V_DD - V_BIAS - abs(V_TP)

# 電流源として使用できる範囲かどうかを判定する関数
def is_within_current_source_range(V_OUT, V_DD, V_BIAS, V_TP):
    V_out_max = calculate_vout_max(V_DD, V_BIAS, V_TP)
    V_out_min = calculate_vout_min(V_DD, V_BIAS, V_TP)
    return V_out_min <= V_OUT <= V_out_max

# 飽和条件の計算例
V_SG = V_BIAS  # 飽和条件を満たすようにソース-ゲート電圧をバイアス電圧とする
V_SD_saturation = calculate_vsd(V_SG, V_TP)
print(f"飽和条件を満たすV_SDの値: {V_SD_saturation} V")

# 最大出力電圧と最小出力電圧の計算
V_out_max = calculate_vout_max(V_DD, V_BIAS, V_TP)
V_out_min = calculate_vout_min(V_DD, V_BIAS, V_TP)

print(f"最大出力電圧 V_OUT(max): {V_out_max} V")
print(f"最小出力電圧 V_OUT(min): {V_out_min} V")

# 出力電圧が電流源として使用できる範囲内かどうかの判定
if is_within_current_source_range(V_OUT, V_DD, V_BIAS, V_TP):
    print(f"出力電圧 V_OUT = {V_OUT} V は電流源として使用できる範囲内です。")
else:
    print(f"出力電圧 V_OUT = {V_OUT} V は電流源として使用できる範囲外です。")
```
P74
```

# Given parameters
gm2 = 1e-3       # Transconductance in S (1 mS)
gmb2 = 200e-6    # Body transconductance in S (200 µS)
gd1 = 10e-6      # Drain conductance in S (10 µS)
gd2 = 10e-6      # Drain conductance in S (10 µS)
ro1 = 100e3      # Output resistance for MOS transistor 1 (100 kΩ)
ro2 = 100e3      # Output resistance for MOS transistor 2 (100 kΩ)

# Calculate rout1
rout1 = (gm2 + gmb2 + gd1 + gd2) / (gd1 * gd2)

# Calculate rout2
rout2 = (gm2 * ro2) * ro1

# Print results
print(f"Output Resistance rout1: {rout1:.4e} Ω")
print(f"Output Resistance rout2: {rout2:.4e} Ω")

# Example of intrinsic gain calculation for different channel lengths
def intrinsic_gain(L):
    if L == 1.2e-6:
        gm = 1e-3   # 1 mS for 1.2 µm
        ro = 100e3  # 100 kΩ for 1.2 µm
    elif L == 0.18e-6:
        gm = 15e-3  # Approx. 15 mS for 0.18 µm
        ro = 10e3   # Approx. 10 kΩ for 0.18 µm
    elif L <= 0.13e-6:
        gm = 10e-3  # Approx. 10 mS for 0.13 µm to 65 nm
        ro = 12e3   # Approx. 12 kΩ for 0.13 µm to 65 nm
    elif L <= 45e-9:
        gm = 6e-3   # Approx. 6 mS for 45 nm
        ro = 6e3    # Approx. 6 kΩ for 45 nm
    else:
        gm = 1e-3   # Default values
        ro = 100e3

    return gm * ro

# Calculate intrinsic gain for different channel lengths
L1 = 1.2e-6  # 1.2 µm
L2 = 0.18e-6 # 0.18 µm
L3 = 65e-9   # 65 nm
L4 = 45e-9   # 45 nm

print(f"Intrinsic Gain for L=1.2 µm: {intrinsic_gain(L1):.4e}")
print(f"Intrinsic Gain for L=0.18 µm: {intrinsic_gain(L2):.4e}")
print(f"Intrinsic Gain for L=65 nm: {intrinsic_gain(L3):.4e}")
print(f"Intrinsic Gain for L=45 nm: {intrinsic_gain(L4):.4e}")

```
P74
```
# Given parameters
gm2 = 1e-3       # Transconductance in S (1 mS)
gmb2 = 200e-6    # Body transconductance in S (200 µS)
gd1 = 10e-6      # Drain conductance in S (10 µS)
gd2 = 10e-6      # Drain conductance in S (10 µS)
ro1 = 100e3      # Output resistance for MOS transistor 1 (100 kΩ)
ro2 = 100e3      # Output resistance for MOS transistor 2 (100 kΩ)

# Calculate rout1
rout1 = (gm2 + gmb2 + gd1 + gd2) / (gd1 * gd2)

# Calculate rout2
rout2 = (gm2 * ro2) * ro1

# Print results
print(f"Output Resistance rout1: {rout1:.4e} Ω")
print(f"Output Resistance rout2: {rout2:.4e} Ω")

# Example of intrinsic gain calculation for different channel lengths
def intrinsic_gain(L):
    if L == 1.2e-6:
        gm = 1e-3   # 1 mS for 1.2 µm
        ro = 100e3  # 100 kΩ for 1.2 µm
    elif L == 0.18e-6:
        gm = 15e-3  # Approx. 15 mS for 0.18 µm
        ro = 10e3   # Approx. 10 kΩ for 0.18 µm
    elif L <= 0.13e-6:
        gm = 10e-3  # Approx. 10 mS for 0.13 µm to 65 nm
        ro = 12e3   # Approx. 12 kΩ for 0.13 µm to 65 nm
    elif L <= 45e-9:
        gm = 6e-3   # Approx. 6 mS for 45 nm
        ro = 6e3    # Approx. 6 kΩ for 45 nm
    else:
        gm = 1e-3   # Default values
        ro = 100e3

    return gm * ro

# Calculate intrinsic gain for different channel lengths
L1 = 1.2e-6  # 1.2 µm
L2 = 0.18e-6 # 0.18 µm
L3 = 65e-9   # 65 nm
L4 = 45e-9   # 45 nm

print(f"Intrinsic Gain for L=1.2 µm: {intrinsic_gain(L1):.4e}")
print(f"Intrinsic Gain for L=0.18 µm: {intrinsic_gain(L2):.4e}")
print(f"Intrinsic Gain for L=65 nm: {intrinsic_gain(L3):.4e}")
print(f"Intrinsic Gain for L=45 nm: {intrinsic_gain(L4):.4e}")

```



P83
```
import math

# 定数とパラメータの設定
I_REF = 100e-6  # 基準電流 (例: 100uA)
mu = 100e-6     # キャリア移動度 (例: 100e-6 m^2/Vs)
C_ox = 10e-9    # 酸化膜容量 (例: 10e-9 F/m^2)
W = 10e-6       # トランジスタの幅 (例: 10e-6 m)
L = 1e-6        # トランジスタの長さ (例: 1e-6 m)
V_TN = 0.7      # 閾値電圧 V_TN (例: 0.7 V)

# (4-16) ゲート-ソース間電圧 V_GS1 の計算
def calculate_vgs1(I_REF, mu, C_ox, W, L, V_TN):
    return math.sqrt((2 * I_REF) / (mu * C_ox * (W / L))) + V_TN

# (4-19) ソース-ドレイン間飽和電圧 V_DSsat1 の計算
def calculate_vdssat1(I_REF, mu, C_ox, W, L):
    return math.sqrt((2 * I_REF) / (mu * C_ox * (W / L)))

# (4-21) 出力電圧の最小値 V_OUT(min) の計算
def calculate_vout_min(V_DSsat1):
    return 2 * V_DSsat1

# 各式に基づく計算
V_GS1 = calculate_vgs1(I_REF, mu, C_ox, W, L, V_TN)
V_DSsat1 = calculate_vdssat1(I_REF, mu, C_ox, W, L)
V_OUT_min = calculate_vout_min(V_DSsat1)

# 結果の表示
print(f"ゲート-ソース間電圧 V_GS1 (4-16式) = {V_GS1:.6f} V")
print(f"ソース-ドレイン間飽和電圧 V_DSsat1 (4-19式) = {V_DSsat1:.6f} V")
print(f"出力電圧の最小値 V_OUT(min) (4-21式) = {V_OUT_min:.6f} V")

```
P84
```
# 定数とパラメータの設定
g_d1 = 0.01   # コンダクタンス g_d1 (例: 0.01 S)
g_d2 = 0.02   # コンダクタンス g_d2 (例: 0.02 S)
g_m2 = 0.005  # トランスコンダクタンス g_m2 (例: 0.005 S)
r_o1 = 10000  # 出力抵抗 r_o1 (例: 10 kΩ)
r_o2 = 5000   # 出力抵抗 r_o2 (例: 5 kΩ)
A = 10        # 増幅度 A (例: 10)

# (4-22)式: 小信号等価回路の電流と電圧の関係式
def calculate_itest(g_d2, v_test, g_m2, v_x, A, g_d1):
    return g_d2 * v_test - g_m2 * v_x * (A + 1) - g_d1 * v_x

# (4-23)式: 出力抵抗 r_out の計算
def calculate_rout(g_d1, g_m2, g_d2, A, r_o1, r_o2):
    return (1 / g_d1) * (g_m2 / g_d2) * A * (g_m2 * r_o2) * r_o1

# 計算例
v_test = 1.0  # テスト電圧 (例: 1V)
v_x = 1.0     # ノード電圧 (例: 1V)

# (4-22) 式に基づくテスト電流の計算
i_test = calculate_itest(g_d2, v_test, g_m2, v_x, A, g_d1)
print(f"テスト電流 i_test (4-22式) = {i_test:.6f} A")

# (4-23) 式に基づく出力抵抗の計算
r_out = calculate_rout(g_d1, g_m2, g_d2, A, r_o1, r_o2)
print(f"出力抵抗 r_out (4-23式) = {r_out:.2f} Ω")

```

P85
rout＝A(gm2×ro2)×ro1

P87とP88
```
# Given parameters
mu = 450e-4         # Mobility of charge carriers in m^2/(V*s) (example value)
Cox = 3.45e-3       # Oxide capacitance per unit area in F/m^2 (example value)
W1 = 10e-6          # Width of MOSFET in meters (example value)
L1 = 1e-6           # Length of MOSFET in meters (example value)
VREF = 1.2          # Reference voltage in Volts (example value)
VTh = 0.6           # Threshold voltage in Volts (example value)
VDD = 3.3           # Supply voltage in Volts (example value)
R = 10e3            # Resistance in Ohms (example value)

# Calculate current I using the MOSFET equation
I_MOSFET = (1/2) * mu * Cox * (W1 / L1) * (VREF - VTh)**2

# Calculate current I using Ohm's law
I_Ohm = (VDD - VREF) / R

# Print results
print(f"Current I (using MOSFET equation): {I_MOSFET:.4e} A")
print(f"Current I (using Ohm's law): {I_Ohm:.4e} A")
```
P92
```
import math

# 定数とパラメータの設定
I_REF = 100e-6   # 基準電流 (例: 100uA)
mu_n = 100e-6    # キャリア移動度 (例: 100e-6 m^2/Vs)
C_ox = 10e-9     # 酸化膜容量 (例: 10e-9 F/m^2)
W_L_5 = 10       # M5トランジスタの幅と長さの比 (W/L)
V_T = 0.7        # 閾値電圧 (例: 0.7V)
R = 10000        # 抵抗 R (例: 10kΩ)
B = 1            # 定数 B

# (5-12)式: 基準電圧 V_GSS の計算
def calculate_vgss(I_REF, mu_n, C_ox, W_L_5, V_T):
    return math.sqrt((2 * I_REF) / (mu_n * C_ox * W_L_5)) + V_T

# (5-13)式: 基準電流 I_REF の計算
def calculate_iref(V_T, R, B):
    term1 = V_T / R
    term2 = (1 / R) * math.sqrt((2 * V_T) / (mu_n * C_ox * (W_L_5 / R)))
    term3 = (2 * V_T) / (B * R)
    term4 = 1 / (B**2 * R**2)
    return term1 + term2 + term3 + term4

# 各式に基づく計算
V_GSS = calculate_vgss(I_REF, mu_n, C_ox, W_L_5, V_T)
I_REF_calculated = calculate_iref(V_T, R, B)

# 結果の表示
print(f"基準電圧 V_GSS (5-12式) = {V_GSS:.6f} V")
print(f"基準電流 I_REF (5-13式) = {I_REF_calculated:.6e} A")

```
P95
```

# Parameters (example values)
I_REF = 1e-3  # Reference current in Amperes
mu_n = 500e-4  # Electron mobility in m^2/Vs (example value)
V_TDI = 0.7  # Threshold voltage in Volts (example value)
dmu_n_dT = -1e-4  # Derivative of mobility with respect to temperature (example value)
dV_TDI_dT = -2e-3  # Derivative of threshold voltage with respect to temperature (example value)

# Partial derivatives
dI_REF_dmu_n = I_REF / mu_n
dI_REF_dV_TDI = -I_REF / V_TDI * (2 / V_TDI)

# Temperature coefficient TC calculation
TC = (1/mu_n) * dmu_n_dT + (2/V_TDI) * dV_TDI_dT

# Output the calculated value
print(f"Temperature Coefficient (TC): {TC} 1/K")


```



P96
```
# Given parameters
mu_n_Cox = 75e-6  # Mobility times oxide capacitance, in A/V^2
V_GS1_VT = 0.2  # V_GS1 - V_T, in V
I_D = 150e-6  # Desired drain current, in A

# Calculate W/L ratio
W_by_L = (2 * I_D) / (mu_n_Cox * V_GS1_VT**2)

# Example calculation for W, given L
L = 1e-6  # Length in meters (example: L = 1 µm)
W = W_by_L * L

print(f"Required W/L ratio: {W_by_L:.2f}")
print(f"Width W for L = {L*1e6:.0f} µm: {W*1e6:.2f} µm")
```
P99

P101

P102

```
# Given parameters
g_m1 = 1e-3   # Transconductance of M1, in S (Siemens)
g_m2 = 1e-3   # Transconductance of M2, in S (Siemens)
g_m3 = 1e-3   # Transconductance of M3, in S (Siemens)
g_d1 = 1e-6   # Drain conductance of M1, in S (Siemens)
g_d2 = 1e-6   # Drain conductance of M2, in S (Siemens)
g_d3 = 1e-6   # Drain conductance of M3, in S (Siemens)
g_d4 = 1e-6   # Drain conductance of M4, in S (Siemens)

# Calculate the voltage gain
numerator = g_m1
denominator = (g_d4 * g_d3 / g_m3) + (g_d1 * g_d2 / g_m2)
voltage_gain = -numerator / denominator

print(f"Voltage Gain (v_out/v_in): {voltage_gain:.2e}")
```

P101
-gm1/(gd1+gd2)

P103

```
# 定数とパラメータの設定
g_m1 = 0.01  # トランスコンダクタンス g_m1 (例: 0.01 S)
g_m2 = 0.015  # トランスコンダクタンス g_m2 (例: 0.015 S)
g_m3 = 0.02   # トランスコンダクタンス g_m3 (例: 0.02 S)
r_o1 = 10000  # 出力抵抗 r_o1 (例: 10 kΩ)
r_o2 = 5000   # 出力抵抗 r_o2 (例: 5 kΩ)
r_o3 = 10000  # 出力抵抗 r_o3 (例: 10 kΩ)
r_o4 = 5000   # 出力抵抗 r_o4 (例: 5 kΩ)
g_m = 0.01    # トランスコンダクタンス g_m (例: 0.01 S)
r_o = 5000    # 出力抵抗 r_o (例: 5 kΩ)

# (6-9)式: r_down と r_up の計算
def calculate_rdown(g_m2, r_o2, r_o1):
    return g_m2 * r_o2 * r_o1

def calculate_rup(g_m3, r_o3, r_o4):
    return g_m3 * r_o3 * r_o4

# (6-9)式: 出力抵抗 r_out の計算
def calculate_rout(r_down, r_up):
    return (r_up * r_down) / (r_up + r_down)

# (6-10)式: 電圧利得の計算
def calculate_voltage_gain(g_m1, r_down, r_up):
    return g_m1 * (1 / r_down + 1 / r_up)

# (6-10)式の特別ケース: 利得の近似計算
def calculate_approx_gain(g_m, r_o):
    return 0.5 * (g_m * r_o) ** 2

# 各式に基づく計算
r_down = calculate_rdown(g_m2, r_o2, r_o1)
r_up = calculate_rup(g_m3, r_o3, r_o4)
r_out = calculate_rout(r_down, r_up)
voltage_gain = calculate_voltage_gain(g_m1, r_down, r_up)
approx_gain = calculate_approx_gain(g_m, r_o)

# 結果の表示
print(f"抵抗成分 r_down (6-9式) = {r_down:.2f} Ω")
print(f"抵抗成分 r_up (6-9式) = {r_up:.2f} Ω")
print(f"出力抵抗 r_out (6-9式) = {r_out:.2f} Ω")
print(f"電圧利得 (6-10式) = {voltage_gain:.6f}")
print(f"電圧利得の近似値 (6-10式の近似) = {approx_gain:.6f}")

```

P107
```
# 定数とパラメータの設定
g_m1 = 0.01  # トランスコンダクタンス g_m1 (例: 0.01 S)
g_m2 = 0.015 # トランスコンダクタンス g_m2 (例: 0.015 S)
g_m3 = 0.02  # トランスコンダクタンス g_m3 (例: 0.02 S)
g_m4 = 0.025 # トランスコンダクタンス g_m4 (例: 0.025 S)
g_d1 = 0.001 # 出力抵抗の逆数 g_d1 (例: 0.001 S)
g_d2 = 0.002 # 出力抵抗の逆数 g_d2 (例: 0.002 S)
g_d4 = 0.003 # 出力抵抗の逆数 g_d4 (例: 0.003 S)
g_a1 = 0.005 # ゲイン g_a1 (例: 0.005 S)
g_a2 = 0.005 # ゲイン g_a2 (例: 0.005 S)
g_a3 = 0.005 # ゲイン g_a3 (例: 0.005 S)

# (6-11) 式: v1, v2, v3, vx の関係
def equation_611(g_m1, g_a1, g_m3, g_a3, v1, v2, v3, vx):
    return g_m1 * v1 + g_a1 * v2 + g_m3 * v3 + g_a3 * vx

# (6-12) 式: v2, v_out, vx の関係
def equation_612(g_m2, g_a2, g_m4, g_d4, v2, v_out, vx):
    return g_m2 * v2 + g_a2 * v_out + g_m4 * vx + g_d4 * v_out

# (6-13) 式: v_out と v_x の関係
def equation_613(g_m1, g_m3, g_a3, g_d1, v1, v_x):
    return v_x - v_out - (g_m1 / (g_m3 + g_a3 + g_d1)) * v1

# (6-14) 式: 電圧利得の計算
def calculate_voltage_gain(g_m1, g_d2, g_d4):
    return g_m1 / (g_d2 + g_d4)

# 計算例の設定
v1 = 1.0   # 入力電圧 v1 (例: 1V)
v2 = 0.5   # 入力電圧 v2 (例: 0.5V)
v3 = 0.8   # 入力電圧 v3 (例: 0.8V)
vx = 0.6   # ノード電圧 vx (例: 0.6V)
v_out = 1.2 # 出力電圧 v_out (例: 1.2V)

# (6-11) 式の計算
result_611 = equation_611(g_m1, g_a1, g_m3, g_a3, v1, v2, v3, vx)
print(f"(6-11 式) 結果 = {result_611:.6f}")

# (6-12) 式の計算
result_612 = equation_612(g_m2, g_a2, g_m4, g_d4, v2, v_out, vx)
print(f"(6-12 式) 結果 = {result_612:.6f}")

# (6-13) 式の計算
result_613 = equation_613(g_m1, g_m3, g_a3, g_d1, v1, vx)
print(f"(6-13 式) 結果 = {result_613:.6f}")

# (6-14) 式の電圧利得の計算
voltage_gain_614 = calculate_voltage_gain(g_m1, g_d2, g_d4)
print(f"電圧利得 (6-14 式) = {voltage_gain_614:.6f}")

```
P108

```

import math

# Given intrinsic gain
gm_ro = 50  # gm * r0 value

# Cascode Common-Source Amplifier Gain
def cascode_gain(gm_ro):
    return -0.5 * (gm_ro) ** 2

# Regulated Cascode Common-Source Amplifier Gain
def regulated_cascode_gain(gm_ro):
    return ((gm_ro) ** 3) / 4

# Convert gain to dB
def gain_to_dB(gain):
    return 20 * math.log10(abs(gain))

# Calculate gains
cascode_amplifier_gain = cascode_gain(gm_ro)
regulated_cascode_amplifier_gain = regulated_cascode_gain(gm_ro)

# Convert gains to dB
cascode_amplifier_gain_dB = gain_to_dB(cascode_amplifier_gain)
regulated_cascode_amplifier_gain_dB = gain_to_dB(regulated_cascode_amplifier_gain)

# Print the results
print(f"Cascode Common-Source Amplifier Gain: {cascode_amplifier_gain}")
print(f"Cascode Common-Source Amplifier Gain in dB: {cascode_amplifier_gain_dB:.2f} dB")
print(f"Regulated Cascode Common-Source Amplifier Gain: {regulated_cascode_amplifier_gain}")
print(f"Regulated Cascode Common-Source Amplifier Gain in dB: {regulated_cascode_amplifier_gain_dB:.2f} dB")

```
P110
```

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

# Constants
gm1 = 1e-3  # Example value for g_m1 in S (adjust as needed)
gm6 = 1e-3  # Example value for g_m6 in S (adjust as needed)
gd2 = 1e-6  # Example value for g_d2 in S (adjust as needed)
gd4 = 1e-6  # Example value for g_d4 in S (adjust as needed)
gd6 = 1e-6  # Example value for g_d6 in S (adjust as needed)
gd7 = 1e-6  # Example value for g_d7 in S (adjust as needed)
C1 = 1e-12  # Example value for C1 in F (adjust as needed)
C2 = 1e-12  # Example value for C2 in F (adjust as needed)

# Resistances
R1 = 1 / (gd2 + gd4)
R2 = 1 / (gd6 + gd7)

# Poles
wp1 = -1 / (R1 * C1)
wp2 = -1 / (R2 * C2)

# Transfer function coefficients
numerator = [gm1 * gm6 * R1 * R2]
denominator = [1, (1/wp1 + 1/wp2), 1/(wp1*wp2)]

# Create transfer function
system = signal.TransferFunction(numerator, denominator)

# Frequency range for Bode plot
w, mag, phase = signal.bode(system)

# Plot Bode magnitude plot
plt.figure()
plt.semilogx(w, mag)
plt.title('Bode Magnitude Plot')
plt.xlabel('Frequency [rad/s]')
plt.ylabel('Magnitude [dB]')
plt.grid(which='both', axis='both')

# Plot Bode phase plot
plt.figure()
plt.semilogx(w, phase)
plt.title('Bode Phase Plot')
plt.xlabel('Frequency [rad/s]')
plt.ylabel('Phase [degrees]')
plt.grid(which='both', axis='both')

plt.show()

```
```
import numpy as np

# 定数の設定（適宜変更してください）
gm1 = 1e-3  # 相互コンダクタンス gm1 (S)
gm6 = 2e-3  # 相互コンダクタンス gm6 (S)
gd2 = 1e-4  # ドレインコンダクタンス gd2 (S)
gd4 = 1e-4  # ドレインコンダクタンス gd4 (S)
gd6 = 1e-4  # ドレインコンダクタンス gd6 (S)
gd7 = 1e-4  # ドレインコンダクタンス gd7 (S)
Cc = 1e-12  # コンデンサ Cc (F)
C2 = 1e-12  # コンデンサ C2 (F)

# R1, R2 の計算
R1 = 1 / (gd2 + gd4)
R2 = 1 / (gd6 + gd7)

# ωp1, ωp2, ωz, ωu の計算
ωp1 = -1 / (gm6 * Cc * R1 * R2)
ωp2 = -gm6 / C2
ωz = gm6 / Cc
ωu = gm1 / Cc

# gm1 × gm6 × R1 × R2 の計算
product1 = gm1 * gm6 * R1 * R2

# gm1 × gm6 × R1 × R2 のデシベル
db_product1 = 20 * np.log10(product1)

# 出力
print(f"R1: {R1:.2e} Ω")
print(f"R2: {R2:.2e} Ω")
print(f"ωp1: {ωp1:.2e} rad/s")
print(f"ωp2: {ωp2:.2e} rad/s")
print(f"ωz: {ωz:.2e} rad/s")
print(f"ωu: {ωu:.2e} rad/s")
print(f"gm1 × gm6 × R1 × R2: {product1:.2e}")
print(f"デシベル (gm1 × gm6 × R1 × R2): {db_product1:.2f} dB")


```

P116

```

# 定数とパラメータの設定
g_m1 = 0.01   # トランスコンダクタンス g_m1 (例: 0.01 S)
g_m6 = 0.015  # トランスコンダクタンス g_m6 (例: 0.015 S)
g_d2 = 0.002  # コンダクタンス g_d2 (例: 0.002 S)
g_d4 = 0.002  # コンダクタンス g_d4 (例: 0.002 S)
g_d6 = 0.003  # コンダクタンス g_d6 (例: 0.003 S)
g_d7 = 0.003  # コンダクタンス g_d7 (例: 0.003 S)
R1 = 1000     # 抵抗 R1 (例: 1kΩ)
R2 = 2000     # 抵抗 R2 (例: 2kΩ)
C_C = 10e-12  # 補償容量 C_C (例: 10pF)
C2 = 20e-12   # 容量 C2 (例: 20pF)

# (7-12) 式: DC利得 A_DC の計算
def calculate_adc(g_m1, g_m6, R1, R2, g_d2, g_d4, g_d6, g_d7):
    return (g_m1 * g_m6 * R1 * R2) / ((g_d2 + g_d4) * (g_d6 + g_d7))

# (7-13) 式: ポール周波数 ω_p1 の計算
def calculate_wp1(g_m6, C_C, R1, R2):
    return -1 / (g_m6 * C_C * R1 * R2)

# (7-14) 式: ポール周波数 ω_p2 の計算
def calculate_wp2(g_m6, C2):
    return -g_m6 / C2

# (7-15) 式: ゼロ周波数 ω_z の計算
def calculate_wz(g_m6, C_C):
    return g_m6 / C_C

# (7-16) 式: ユニティ・ゲイン周波数 ω_u の計算
def calculate_wu(A_DC, wp1):
    return A_DC * abs(wp1)

# 各式に基づく計算
A_DC = calculate_adc(g_m1, g_m6, R1, R2, g_d2, g_d4, g_d6, g_d7)
omega_p1 = calculate_wp1(g_m6, C_C, R1, R2)
omega_p2 = calculate_wp2(g_m6, C2)
omega_z = calculate_wz(g_m6, C_C)
omega_u = calculate_wu(A_DC, omega_p1)

# 結果の表示
print(f"DC利得 A_DC (7-12 式) = {A_DC:.6f}")
print(f"ポール周波数 ω_p1 (7-13 式) = {omega_p1:.6e} rad/s")
print(f"ポール周波数 ω_p2 (7-14 式) = {omega_p2:.6e} rad/s")
print(f"ゼロ周波数 ω_z (7-15 式) = {omega_z:.6e} rad/s")
print(f"ユニティ・ゲイン周波数 ω_u (7-16 式) = {omega_u:.6e} rad/s")

```


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

# Given constants
gm1 = 1e-3  # example value for gm1 in S
gm6 = 1e-3  # example value for gm6 in S
R1 = 1e3    # example value for R1 in ohms
R2 = 1e3    # example value for R2 in ohms
CC = 1e-12  # example value for CC in farads
C1 = 1e-12  # example value for C1 in farads
C2 = 1e-12  # example value for C2 in farads
RC = 1/(gm6) # example value for RC in ohms

# Pole and zero frequencies
wp1 = 1 / (gm6 * CC * R1 * R2)
wp2 = -gm6 / C2
wp3 = -1 / (RC * C1)
wz = gm6 / (CC * (1 - gm6 * RC))

# Transfer function numerator and denominator
num = [gm1 * gm6 * R1 * R2, -gm1 * gm6 * R1 * R2 * wz]
den = [1, -(wp1 + wp2 + wp3), wp1*wp2 + wp2*wp3 + wp3*wp1, -wp1*wp2*wp3]

# Create transfer function
system = signal.TransferFunction(num, den)

# Generate Bode plot
w, mag, phase = signal.bode(system)

# Plot Bode magnitude
plt.figure()
plt.semilogx(w, mag)
plt.title('Bode Plot - Magnitude')
plt.xlabel('Frequency [rad/s]')
plt.ylabel('Magnitude [dB]')
plt.grid(True)

# Plot Bode phase
plt.figure()
plt.semilogx(w, phase)
plt.title('Bode Plot - Phase')
plt.xlabel('Frequency [rad/s]')
plt.ylabel('Phase [degrees]')
plt.grid(True)

plt.show()
```
P122

```
import math

# 定数とパラメータの設定
g_m6 = 0.015  # トランスコンダクタンス g_m6 (例: 0.015 S)
C_C = 10e-12  # 補償容量 C_C (例: 10pF)
C_L = 20e-12  # 負荷容量 C_L (例: 20pF)
C_1 = 15e-12  # 容量 C_1 (例: 15pF)
omega_u = 1e6 # ユニティ・ゲイン周波数 ω_u (例: 1 MHz)
omega_p2 = 5e6 # ポール周波数 ω_p2 (例: 5 MHz)

# (7-20) 式: 位相余裕の計算
def calculate_phase_margin(omega_p2, omega_u):
    return math.degrees(math.atan(abs(omega_p2) / omega_u))

# (7-19) 式: 抵抗 R_C の計算
def calculate_rc(C_L, C_C, g_m6):
    return (1 + (C_L / C_C)) / g_m6

# (7-21) 式: ポール周波数 ω_p3 の計算
def calculate_wp3(R_C, C_1):
    return 1 / (R_C * C_1)

# 各式に基づく計算
phase_margin = calculate_phase_margin(omega_p2, omega_u)
R_C = calculate_rc(C_L, C_C, g_m6)
omega_p3 = calculate_wp3(R_C, C_1)

# 結果の表示
print(f"位相余裕 φ_M (7-20 式) = {phase_margin:.2f} 度")
print(f"抵抗 R_C (7-19 式) = {R_C:.6f} Ω")
print(f"ポール周波数 ω_p3 (7-21 式) = {omega_p3:.2e} rad/s")

```
P127

```
# 定数とパラメータの設定
I_BIAS = 100e-6  # バイアス電流 (例: 100 µA)
W_L_1 = 2        # M1トランジスタの幅と長さの比 (例: 2)
W_L_2 = 2        # M2トランジスタの幅と長さの比 (例: 2)
W_L_6 = 4        # M6トランジスタの幅と長さの比 (例: 4)
W_L_8 = 4        # M8トランジスタの幅と長さの比 (例: 4)
V_DD = 5         # 電源電圧 V_DD (例: 5V)
V_SS = 0         # 基準電圧 V_SS (例: 0V)
V_TN = 0.7       # NMOSの閾値電圧 V_TN (例: 0.7V)
V_TP = -0.7      # PMOSの閾値電圧 V_TP (例: -0.7V)
V_DSsat = 0.2    # 飽和状態のドレイン・ソース間電圧 V_DSsat (例: 0.2V)

# (7-22) 式: プル電流 I_pull の計算
def calculate_ipull(I_BIAS, W_L_2, W_L_6):
    return I_BIAS * (W_L_2 / W_L_6)

# (7-23) 式: プッシュ電流 I_push の計算
def calculate_ipush(I_BIAS, W_L_1, W_L_8):
    return I_BIAS * (W_L_1 / W_L_8)

# (7-24) 式: プル電流とプッシュ電流の関係
def calculate_iq(I_pull, I_push):
    return I_pull if I_pull == I_push else None  # プル電流とプッシュ電流が等しいときのみ静止電流

# (7-26) 式: 出力電圧の最大値 V_outmax の計算
def calculate_voutmax(V_DD, V_DSsat, V_TN):
    return V_DD - 2 * V_DSsat - V_TN

# (7-27) 式: 出力電圧の最小値 V_outmin の計算
def calculate_voutmin(V_SS, V_DSsat, V_TP):
    return V_SS + 2 * V_DSsat + V_TP

# 各式に基づく計算
I_pull = calculate_ipull(I_BIAS, W_L_2, W_L_6)
I_push = calculate_ipush(I_BIAS, W_L_1, W_L_8)
I_Q = calculate_iq(I_pull, I_push)
V_outmax = calculate_voutmax(V_DD, V_DSsat, V_TN)
V_outmin = calculate_voutmin(V_SS, V_DSsat, V_TP)

# 結果の表示
print(f"プル電流 I_pull (7-22 式) = {I_pull:.6f} A")
print(f"プッシュ電流 I_push (7-23 式) = {I_push:.6f} A")
print(f"静止電流 I_Q (7-24 式) = {I_Q:.6f} A" if I_Q is not None else "プル電流とプッシュ電流が等しくありません")
print(f"出力電圧の最大値 V_outmax (7-26 式) = {V_outmax:.2f} V")
print(f"出力電圧の最小値 V_outmin (7-27 式) = {V_outmin:.2f} V")

```

P132
```

# 定数とパラメータの設定
V_SS = 0          # 基準電圧 V_SS (例: 0V)
V_DD = 5          # 電源電圧 V_DD (例: 5V)
V_TN = 0.7        # NMOSの閾値電圧 V_TN (例: 0.7V)
V_TP = -0.7       # PMOSの閾値電圧 V_TP (例: -0.7V)
V_DSsat3 = 0.2    # M3トランジスタの飽和状態のドレイン・ソース間電圧 V_DSsat3 (例: 0.2V)
V_DSsat5 = 0.2    # M5トランジスタの飽和状態のドレイン・ソース間電圧 V_DSsat5 (例: 0.2V)
V_DSsat1 = 0.2    # M1トランジスタの飽和状態のドレイン・ソース間電圧 V_DSsat1 (例: 0.2V)

# (7-36) 式: 同相入力電圧の最小値 V_CMmin の計算
def calculate_vcmmin(V_SS, V_DSsat3, V_TN, V_TP):
    return V_SS + V_DSsat3 + V_TN - V_TP

# (7-37) 式: 同相入力電圧の最大値 V_CMmax の計算
def calculate_vcmmax(V_DD, V_DSsat5, V_DSsat1, V_TP):
    return V_DD - V_DSsat5 - V_DSsat1 - V_TP

# 各式に基づく計算
V_CMmin = calculate_vcmmin(V_SS, V_DSsat3, V_TN, V_TP)
V_CMmax = calculate_vcmmax(V_DD, V_DSsat5, V_DSsat1, V_TP)

# 結果の表示
print(f"同相入力電圧の最小値 V_CMmin (7-36 式) = {V_CMmin:.2f} V")
print(f"同相入力電圧の最大値 V_CMmax (7-37 式) = {V_CMmax:.2f} V")
```





P134

```
# 定数とパラメータの設定
V_SS = 0          # 基準電圧 V_SS (例: 0V)
V_DD = 5          # 電源電圧 V_DD (例: 5V)
V_TN = 0.7        # NMOSの閾値電圧 V_TN (例: 0.7V)
V_TP = -0.7       # PMOSの閾値電圧 V_TP (例: -0.7V)
V_DSsat5 = 0.2    # M5トランジスタの飽和状態のドレイン・ソース間電圧 V_DSsat5 (例: 0.2V)
V_DSsat1 = 0.2    # M1トランジスタの飽和状態のドレイン・ソース間電圧 V_DSsat1 (例: 0.2V)
V_SG3 = 1.0       # M3トランジスタのソース・ゲート間電圧 V_SG3 (例: 1V)

# (7-34) 式: 同相入力電圧の最小値 V_CMmin の計算
def calculate_vcmmin(V_SS, V_DSsat5, V_DSsat1, V_TN):
    return V_SS + V_DSsat5 + V_DSsat1 + V_TN

# (7-39) 式: 同相入力電圧の最大値 V_CMmax の計算
def calculate_vcmmax(V_DD, V_SG3, V_DSsat1, V_TN):
    return V_DD - V_SG3 - V_DSsat1 + V_TN

# 各式に基づく計算
V_CMmin = calculate_vcmmin(V_SS, V_DSsat5, V_DSsat1, V_TN)
V_CMmax = calculate_vcmmax(V_DD, V_SG3, V_DSsat1, V_TN)

# 結果の表示
print(f"同相入力電圧の最小値 V_CMmin (7-34 式) = {V_CMmin:.2f} V")
print(f"同相入力電圧の最大値 V_CMmax (7-39 式) = {V_CMmax:.2f} V")


```
P163

```

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

# Parameters (example values)
G1 = 1.0  # Assuming unit conductance for G1
G2 = 10.0  # Assuming unit conductance for G2
gm1 = 1e-3  # Transconductance of transistor 1
gm6 = 1e-3  # Transconductance of transistor 6
CC = 1e-12  # Compensation capacitance
C1 = 1e-12  # Capacitance C1
C2 = 1e-12  # Capacitance C2

# First transfer function components (numerator and denominator)
num1 = [-gm1 * gm6, gm1 * gm6 * CC]
den1 = [G1 * G2, gm6 * CC + G1 * (C1 + CC) + G2 * (C2 + CC), (C1 + CC) * (C2 + CC) - CC**2]

# Second simplified transfer function components (numerator and denominator)
num2 = [gm1 * gm6, -gm1 * CC]
den2 = [G1 * G2, gm6 * CC, C2 * CC]

# Create transfer functions
tf1 = signal.TransferFunction(num1, den1)
tf2 = signal.TransferFunction(num2, den2)

# Frequency range for Bode plot
frequencies = np.logspace(1, 9, 500)  # From 10 Hz to 1 GHz

# Bode plots
w1, mag1, phase1 = signal.bode(tf1, frequencies)
w2, mag2, phase2 = signal.bode(tf2, frequencies)

# Plotting the magnitude and phase response
plt.figure(figsize=(12, 8))

# Magnitude Plot
plt.subplot(2, 1, 1)
plt.semilogx(w1, mag1, label='Original Transfer Function')
plt.semilogx(w2, mag2, label='Simplified Transfer Function')
plt.title('Bode Plot')
plt.ylabel('Magnitude (dB)')
plt.grid(True)
plt.legend()

# Phase Plot
plt.subplot(2, 1, 2)
plt.semilogx(w1, phase1, label='Original Transfer Function')
plt.semilogx(w2, phase2, label='Simplified Transfer Function')
plt.ylabel('Phase (degrees)')
plt.xlabel('Frequency (Hz)')
plt.grid(True)
plt.legend()

plt.tight_layout()
plt.show()



```




```

import numpy as np

# 固有利得の計算
gm_r0 = 50

# カスコード型ソース増幅回路の固有利得
gain_cascode = -0.5 * (gm_r0 ** 2)

# レギュレーテッドカスコードソース増幅回路の固有利得
gain_regulated_cascode = (gm_r0 ** 3) / 4

# デシベル単位での固有利得の計算
gain_cascode_db = 10 * np.log10(np.abs(gain_cascode))
gain_regulated_cascode_db = 10 * np.log10(np.abs(gain_regulated_cascode))

# 結果の表示
print(f'カスコード型ソース増幅回路の固有利得: {gain_cascode:.2f}')
print(f'カスコード型ソース増幅回路の固有利得 (dB): {gain_cascode_db:.2f} dB')

print(f'レギュレーテッドカスコードソース増幅回路の固有利得: {gain_regulated_cascode:.2f}')
print(f'レギュレーテッドカスコードソース増幅回路の固有利得 (dB): {gain_regulated_cascode_db:.2f} dB')

```



```

# Define the parameters
gm1 = 1e-3   # Transconductance of M1 in Siemens (example value)
gm2 = 1e-3   # Transconductance of M2 in Siemens (example value)
gm3 = 1e-3   # Transconductance of M3 in Siemens (example value)
gd1 = 1e-6   # Drain conductance of M1 in Siemens (example value)
gd2 = 1e-6   # Drain conductance of M2 in Siemens (example value)
gd3 = 1e-6   # Drain conductance of M3 in Siemens (example value)
gd4 = 1e-6   # Drain conductance of M4 in Siemens (example value)
ro1 = 100e3  # Output resistance of M1 in Ohms (example value)
ro2 = 100e3  # Output resistance of M2 in Ohms (example value)
ro3 = 100e3  # Output resistance of M3 in Ohms (example value)
ro4 = 100e3  # Output resistance of M4 in Ohms (example value)

# Calculate the gain
def cascode_gain(gm1, gm2, gm3, gd1, gd2, gd3, gd4, ro1, ro2, ro3, ro4):
    term1 = (gd4 * gd3) / gm3
    term2 = (gd1 * gd2) / gm2
    denominator = term1 + term2
    
    gain = -gm1 / denominator
    
    # Simplified expression using output resistances
    simplified_gain = -gm1 / (1 / (gm3 * ro3 * ro4) + 1 / (gm2 * ro2 * ro1))
    
    return gain, simplified_gain

# Calculate the gains
gain, simplified_gain = cascode_gain(gm1, gm2, gm3, gd1, gd2, gd3, gd4, ro1, ro2, ro3, ro4)

# Print the results
print(f"Cascode Amplifier Gain: {gain}")
print(f"Simplified Cascode Amplifier Gain: {simplified_gain}")





```


```

import math

# Given intrinsic gain
gm_ro = 50  # gm * r0 value

# Cascode Common-Source Amplifier Gain
def cascode_gain(gm_ro):
    return -0.5 * (gm_ro) ** 2

# Regulated Cascode Common-Source Amplifier Gain
def regulated_cascode_gain(gm_ro):
    return ((gm_ro) ** 3) / 4

# Convert gain to dB
def gain_to_dB(gain):
    return 20 * math.log10(abs(gain))

# Calculate gains
cascode_amplifier_gain = cascode_gain(gm_ro)
regulated_cascode_amplifier_gain = regulated_cascode_gain(gm_ro)

# Convert gains to dB
cascode_amplifier_gain_dB = gain_to_dB(cascode_amplifier_gain)
regulated_cascode_amplifier_gain_dB = gain_to_dB(regulated_cascode_amplifier_gain)

# Print the results
print(f"Cascode Common-Source Amplifier Gain: {cascode_amplifier_gain}")
print(f"Cascode Common-Source Amplifier Gain in dB: {cascode_amplifier_gain_dB:.2f} dB")
print(f"Regulated Cascode Common-Source Amplifier Gain: {regulated_cascode_amplifier_gain}")
print(f"Regulated Cascode Common-Source Amplifier Gain in dB: {regulated_cascode_amplifier_gain_dB:.2f} dB")



```