RTL Studio Open IDE

Arithmetic & Math

Saturating Multiplier 4x4 — L2 Upgrade

4-bit by 4-bit saturating multiplier with sticky saturation flag and clear capability.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Saturating Multiplier 4x4 — L2 Upgrade is a Verilog reference block in the Arithmetic & Math catalog. Adders, multipliers, dividers, ALUs, and arithmetic datapaths. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements a 4-bit by 4-bit saturating multiplier with a sticky saturation flag.

It computes the unsigned product of two 4-bit operands and clamps the result to the maximum 4-bit value (15) if overflow occurs.

The sat_flag output provides a sticky indication of saturation, remaining asserted until explicitly cleared via clear_sat or reset via rst_n.

  1. Computes the full 8-bit product of inputs a and b.
  2. Checks if the product exceeds 15.
  3. If saturation occurs, result is set to 15 and sat_flag is set to 1.
  4. If no saturation occurs, result is set to the lower 4 bits of the product.
  5. The sat_flag is sticky: once set to 1, it remains 1 until clear_sat is asserted or rst_n is de-asserted.
  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Saturating Multiplier 4x4 — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 4-bit by 4-bit saturating multiplier with sticky saturation flag and clear capability.
  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.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low reset. Clears result to 0 and sat_flag to 0.
clear_satInput1Active-high clear. Resets sat_flag to 0. Does not affect result.
enInput1Enable input. When low, result and sat_flag hold their previous values.
aInput4Multiplicand operand (unsigned)
bInput4Multiplier operand (unsigned)
resultOutput4Saturating product result (0-15)
sat_flagOutput1Sticky saturation indicator. 1 if saturation occurred or was previously set.

Verification

The provided testbench (tb/tb_saturating_mul_4x4_sticky_sat_flag.v) verifies the following scenarios:

Test CaseDescriptionExpected Result
TC1Basic multiplication (3 * 3)result=9, sat_flag=0
TC2Upper bound saturation (4 * 4)result=15, sat_flag=1
TC3Sticky flag retentionresult=4, sat_flag=1 (remains 1)
TC4Clear saturation flagsat_flag=0
TC5Reset clears all stateresult=0, sat_flag=0
TC6Re-saturation after clearresult=15, sat_flag=1
TC7Hold behavior when disabledresult=15, sat_flag=1 (held)

All tests passed successfully in the simulation environment.

More in Arithmetic & Math

All Arithmetic & Math blocks