RTL Studio Open IDE

Control & Timers

Bang-Bang Thermostat 8-bit

An 8-bit bang-bang thermostat controller with hysteresis for heating control.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Bang-Bang Thermostat 8-bit is a Verilog reference block in the Control & Timers catalog. FSMs, timers, watchdogs, and control/state sequencing blocks. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements a robust bang-bang thermostat controller with 8-bit temperature inputs.

It utilizes hysteresis to prevent rapid switching (oscillation) near threshold boundaries, ensuring stable thermal regulation in embedded systems.

The module asserts heat_out when the input temperature drops below a configurable lower bound and deasserts it when the temperature rises above an upper bound.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Bang-Bang Thermostat 8-bit.
  2. Read the Verilog module in the editor. The catalog line for this block: An 8-bit bang-bang thermostat controller with hysteresis for heating control.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Features

  • 8-bit Temperature Comparison: Supports unsigned temperature inputs (0-255).
  • Configurable Hysteresis: Independent lower (temp_lo) and upper (temp_hi) thresholds define the dead band.
  • Oscillation Prevention: Hysteresis logic ensures the output does not toggle rapidly when temperature fluctuates near thresholds.
  • Synchronous Control: Fully synchronous design with active-low reset for clean initialization.
  • Verified: Comprehensive testbench covering boundary conditions, hold states, and reset scenarios.

Ports

Port NameDirectionWidthDescription
clkInput1System clock input
rst_nInput1Active-low synchronous reset
temp_inInput8Current temperature reading
temp_loInput8Lower threshold for heating activation
temp_hiInput8Upper threshold for heating deactivation
heat_outOutput1Heating control signal (1=ON, 0=OFF)

Verification

The provided testbench (tb_bang_bang_thermostat_8bit.v) verifies the following scenarios:

Test CaseDescriptionExpected Result
TC1Initial state after resetheat_out = 0
TC2Temperature below lower boundheat_out = 1
TC3Hold state from heatheat_out remains 1
TC4Temperature above upper boundheat_out = 0
TC5Hold state from offheat_out remains 0
TC6Rapid transition to heatheat_out transitions to 1
TC7Boundary condition (temp == lo)heat_out = 1
TC8Boundary condition (temp == hi)heat_out = 1 (Hysteresis hold)
TC9Inverted check sensitivityheat_out = 1

All 9 test cases passed successfully in Icarus Verilog simulation.

More in Control & Timers

All Control & Timers blocks