Learn CHISEL-HDL with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Blink LED Module
import chisel3._
class BlinkLED extends Module {
val io = IO(new Bundle {
val led = Output(Bool())
})
val counter = RegInit(0.U(24.W))
counter := counter + 1.U
io.led := counter(23)
}
object BlinkLED extends App {
chisel3.Driver.execute(args, () => new BlinkLED)
}
Toggle an LED using a simple counter in Chisel.
2
2-bit Counter
import chisel3._
class Counter2Bit extends Module {
val io = IO(new Bundle {
val count = Output(UInt(2.W))
})
val cnt = RegInit(0.U(2.W))
cnt := cnt + 1.U
io.count := cnt
}
object Counter2Bit extends App {
chisel3.Driver.execute(args, () => new Counter2Bit)
}
A simple 2-bit synchronous counter using Chisel.
3
2-input AND Gate
import chisel3._
class AndGate 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
}
object AndGate extends App {
chisel3.Driver.execute(args, () => new AndGate)
}
Implement a 2-input AND gate in Chisel.