File size: 2,321 Bytes
829b19c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright 2025 Ahmad Ali Parr / SnapKitty β€” https://github.com/SNAPKITTYWEST/phaser-ags
package nand

import chisel3._
import chisel3.util._

// ═══════════════════════════════════════════════════════════════════
// NAND2 β€” Primitive gate, maps 1:1 to the CMOS SPICE circuit
//
// SPICE: 2 PMOS parallel (pull-up) + 2 NMOS series (pull-down)
// Chisel: built-in operator, synthesizer maps to standard cell
// ═══════════════════════════════════════════════════════════════════

class Nand2 extends Module {
  val io = IO(new Bundle {
    val a = Input(Bool())
    val b = Input(Bool())
    val y = Output(Bool())
  })

  io.y := ~(io.a & io.b)
}

// ═══════════════════════════════════════════════════════════════════
// NAND3 β€” 3 PMOS parallel + 3 NMOS series
// Matches nand3_jacobian.sp tridiagonal Jacobian
// ═══════════════════════════════════════════════════════════════════

class Nand3 extends Module {
  val io = IO(new Bundle {
    val a = Input(Bool())
    val b = Input(Bool())
    val c = Input(Bool())
    val y = Output(Bool())
  })

  io.y := ~(io.a & io.b & io.c)
}

// ═══════════════════════════════════════════════════════════════════
// NOR2 β€” Complementary to NAND: 2 PMOS series + 2 NMOS parallel
// ═══════════════════════════════════════════════════════════════════

class Nor2 extends Module {
  val io = IO(new Bundle {
    val a = Input(Bool())
    val b = Input(Bool())
    val y = Output(Bool())
  })

  io.y := ~(io.a | io.b)
}