1. Home
  2. /
  3. Myhdl
  4. /
  5. Blink LED

Blink LED - Myhdl Typing CST Test

Loading…

Blink LED — Myhdl Code

Toggle an LED using a clocked process in MyHDL.

from myhdl import block, always_seq, Signal, intbv

@block
def BlinkLED(clk, led):
	counter = Signal(intbv(0)[24:])

	@always_seq(clk.posedge, reset=None)
	def logic():
		counter.next = counter + 1
		led.next = counter[23]

	return logic

Myhdl Language Guide

MyHDL is a Python-based hardware description language (HDL) that allows designing, simulating, and verifying digital hardware using Python syntax. It enables hardware designers to leverage Python’s flexibility for modeling digital circuits and generating synthesizable VHDL or Verilog code.

Primary Use Cases

  • ▸Modeling combinational and sequential logic in Python
  • ▸Simulating hardware designs using Python testbenches
  • ▸Generating synthesizable VHDL or Verilog code
  • ▸Rapid prototyping for FPGA development
  • ▸Automated verification of digital designs

Notable Features

  • ▸Hardware modeling using Python syntax
  • ▸Simulation and testbench integration
  • ▸Automatic conversion to VHDL or Verilog
  • ▸Support for synchronous and asynchronous logic
  • ▸Integration with Python libraries for testing and verification

Origin & Creator

Developed by Jan Decaluwe starting in 2003, MyHDL was created to combine Python’s ease of use with digital hardware design, bridging software and HDL modeling.

Industrial Note

Used in FPGA and ASIC prototyping, hardware verification, digital IP development, and teaching advanced digital design concepts with Python.

More Myhdl Typing Exercises

2-bit Counter2-input AND Gate

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher