phaser-ags / chisel /src /nand /Primitives.scala
SNAPKITTYWEST's picture
October 2026 main drop: mirror from GitHub
829b19c verified
Raw History Blame Contribute Delete
2.32 kB
// 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)
}