427 4-Input Signed Neuron / Perceptron

427 : 4-Input Signed Neuron / Perceptron

Design render

How it works

The 4-Input Signed Neuron / Perceptron is a compact hardware accelerator that calculates a weighted sum of four signed inputs and applies a ReLU activation function with 8-bit output saturation.

The neuron performs:

y = w0×in0 + w1×in1 + w2×in2 + w3×in3 + bias

The four weights, four inputs, and bias are stored internally as 6-bit two's-complement values. The signed 6-bit range is:

-32 to +31

A single shared 6×6 signed multiplier is reused for all four weight-input multiplications. The four products are calculated sequentially and accumulated in a 16-bit accumulator. After the four multiplications, the stored bias is added.

The result then passes through a ReLU activation and an 8-bit saturation stage:

if result < 0
    output = 0

else if result > 255
    output = 255

else
    output = result

Therefore, the final output is always between 0 and 255.

Register Map

The registers are written through ui_in[5:0]. The register selected by uio_in[3:0] is updated when uio_in[4] (WR_EN) is asserted.

Address Register
0 w0
1 w1
2 w2
3 w3
4 bias
5 in0
6 in1
7 in2
8 in3

All stored values use 6-bit two's-complement representation.

Input and Control Interface

Signal Function
ui_in[5:0] 6-bit register data
ui_in[7:6] Unused
uio_in[3:0] Register address
uio_in[4] WR_EN — write selected register
uio_in[5] START — start computation
uio_in[7:6] Unused

When START is asserted, the accelerator enters its sequential computation:

S_IDLE
   │
   │ START
   ▼
S_MAC0
   │
   ▼
S_MAC1
   │
   ▼
S_MAC2
   │
   ▼
S_MAC3
   │
   ▼
S_BIAS
   │
   ▼
S_ACT
   │
   ▼
S_DONE

The shared multiplier performs:

S_MAC0 → w0 × in0
S_MAC1 → w1 × in1
S_MAC2 → w2 × in2
S_MAC3 → w3 × in3

The S_BIAS state adds the bias. The S_ACT state applies ReLU and saturation, and S_DONE indicates that the result is ready.

Output Interface

The final neuron result is available on uo_out[7:0].

Status signals are provided through uio_out:

Signal Function
uio_out[0] BUSY — computation is in progress
uio_out[1] DONE — computation is complete
uio_out[7:2] 0

The corresponding output-enable signals are:

uio_oe[1:0] = 1
uio_oe[7:2] = 0

How to test

First apply an active-low reset using rst_n and keep ena high.

1. Write the weights, inputs, and bias

For each register:

  1. Place the 6-bit two's-complement value on ui_in[5:0].
  2. Place the register address on uio_in[3:0].
  3. Assert uio_in[4] (WR_EN).
  4. Apply a clock edge.
  5. Deassert WR_EN.

For example, to write w0 = 3:

ui_in[5:0] = 000011
uio_in[3:0] = 0000
uio_in[4] = 1

Negative values are represented using 6-bit two's complement. For example:

-5 = 6'b111011

2. Start the neuron

After all weights, inputs, and bias values have been written, assert:

uio_in[5] = 1

This starts the calculation.

During computation:

uio_out[0] = 1

indicates that the accelerator is busy.

3. Read the result

When computation completes:

uio_out[1] = 1

indicates DONE.

The final ReLU and saturated result can then be read from:

uo_out[7:0]

After START is deasserted, the accelerator returns to the idle state.

Example 1 — Basic Positive MAC

Weights = [1, 2, 3, 4]
Inputs  = [1, 1, 1, 1]
Bias    = 0

Calculation:

1×1 + 2×1 + 3×1 + 4×1 + 0
= 10

Expected output:

10

Example 2 — ReLU

Weights = [-5, -5, -5, -5]
Inputs  = [1, 1, 1, 1]
Bias    = 0

Calculation:

-5×1 + -5×1 + -5×1 + -5×1
= -20

ReLU clamps the negative result to:

0

Expected output:

0

Example 3 — Output Saturation

Weights = [31, 31, 31, 31]
Inputs  = [4, 4, 4, 4]
Bias    = 31

Calculation:

31×4 + 31×4 + 31×4 + 31×4 + 31
= 527

Since the output is saturated to 8 bits:

527 → 255

Expected output:

255

Example 4 — Mixed Signed MAC

Weights = [3, -2, 4, -1]
Inputs  = [10, 5, 2, 3]
Bias    = -5

Calculation:

3×10 + (-2×5) + 4×2 + (-1×3) - 5
= 30 - 10 + 8 - 3 - 5
= 20

Expected output:

20

Example 5 — Minimum Signed Value

The minimum signed 6-bit value is:

-32

For:

Weights = [-32, 0, 0, 0]
Inputs  = [1, 0, 0, 0]
Bias    = 0

the result is:

-32

After ReLU:

0

Expected output:

0

External hardware

No external hardware is required for simulation.

For a physical demonstration, an FPGA, microcontroller, or other digital controller can be used to provide the register address, 6-bit data, write-enable, and start signals.

The uo_out[7:0] output can be connected to a logic analyzer or other digital interface to observe the neuron result.

The uio_out[0] and uio_out[1] signals provide BUSY and DONE status and can be monitored by the external controller.

IO

#InputOutputBidirectional
0DATA[0]RESULT[0]BUSY
1DATA[1]RESULT[1]DONE
2DATA[2]RESULT[2]
3DATA[3]RESULT[3]ADDR[0]
4DATA[4]RESULT[4]ADDR[1]
5DATA[5]RESULT[5]ADDR[2]
6RESULT[6]ADDR[3]
7RESULT[7]

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Analog Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (Tiny Tapeout Factory Test) tt_um_ieee_LDO (LDO) tt_um_chip_ieee_analog (IEEE Bandgap Reference) tt_um_snn_voice_calculator_mauro_ciccone (snn-voice-calculator) tt_um_hx2003_delay (4 Channel - 32 Tap Programmable Delay with Delay Locked Loop Calibration) tt_um_adxl362_test (tt_um_adxl362_test) tt_um_larsnit_cfar (1D CA/GO/SO CFAR radar detector) tt_um_abeccari_swsynth (Sine Wave Synthesizer) tt_um_dpi_adexp (AdExp DPI Neuron ) tt_um_140oo041_fpu130 (FPU-130) tt_um_blonghi_uart (uart) tt_um_directsgg_mini_proceo_8bit (Mini 8-bit Processor) tt_um_umaece1982_lfsr (Low-Power LFSR-Based Test Pattern Generator) tt_um_deploy_timer (launch deployment timer) tt_um_urish_simon (Simon Says memory game) tt_um_nimelli_kinematic_wave_engine (Kinematic Wave Engine) tt_um_multi_seg_monitor (Multi Segment Monitor) tt_um_UART_TX (project) tt_um_crc8_lfsr (CRC-8 Serial LFSR) tt_um_tinynpu4 (TinyNPU4) tt_um_alu_bns (6-bit multi function ALU ( eldawly_V2) ) tt_um_echoworld424_tpv (Timing-Prediction Test Vehicle) tt_um_gyro_lockin (Laser Gyro Lock-in Readout Core) tt_um_josue_olivos_sar_adc (4-Bit Charge-Redistribution SAR ADC Controller) tt_um_flower (VGA Flower) tt_um_vperumal_l1_fabric (Scalable Banked L1 Memory Fabric for Edge AI) tt_um_preinception_top (Preinception: Simple Compute Accelerator) tt_um_italu (iTALU: Interactive Testable Arithmetic Logic Unit) tt_um_neuron (4-Input Signed Neuron / Perceptron) tt_um_4tap_mac (4-Tap Signed MAC Unit) tt_um_mac_engine (DSP MAC Engine) tt_um_crypto_led_demo (QAMER CryptoUART: Encrypted UART with LED Status) tt_um_layernorm (LayerNorm) tt_um_ez130_8t_mystery (EZ130 8T Mystery Circuit) tt_um_sent2spi (SENT Receiver with SPI Interface) tt_um_llr_hepiarisc (Hepiarisc with SPI flash) tt_um_rebeccargb_vga_pride (VGA Pride) tt_um_hasi_ising (Oscillator Ising Machine) tt_um_c061618g2 (Circuitli C061618G2) tt_um_tiny_dram_pim (Tiny Dual-Channel DRAM-PIM Controller + PU) tt_um_Tbilisi_CORDIC_Engine (Tbilisi CORDIC Engine) tt_um_rahulmascarenhas_folded_nn (Frozen ternary backbone + loadable head) tt_um_miniMAC (miniMAC_IHP26b) tt_um_rumcajs (IEEE DOORSH) tt_um_sg13g2_mystery (SG13G2 Mystery Circuit) tt_um_ULSR88 (ULSR demo) tt_um_ez130_7t_mystery (EZ130 7T Mystery Circuit) tt_um_tinyopt4 (ieee_tt_tinyopt4) tt_um_vga_example (IEEE VGA Animated Beach) tt_um_hyphen133_drone_detection (IEEE Acoustic Drone Detector) tt_um_nuatlabs_fifo_pwm (Async FIFO with CDC + PWM Peripheral) tt_um_nuatlabs_uart (8N1 UART Transceiver) tt_um_eeg_threshold_detector (IEEE Digital EEG Threshold Event Detector) tt_um_smart_traffic (Smart Traffic Light Controller) tt_um_94442024_mini_cpu (Mini 8-bit Accumulator CPU) tt_um_wokwi_475369131246576641 (IEEE_UPB_TT_1) tt_um_aion (AION) tt_um_rebeccargb_hardware_utf8 (Hardware UTF Encoder/Decoder) tt_um_rebeccargb_universal_decoder (Universal Binary to Segment Decoder) tt_um_rebeccargb_intercal_alu (INTERCAL ALU) tt_um_flappy_bird (IEEE Flappy Bird VGA Game) tt_um_oryan01_alu (ALU CASS PUCV) tt_um_S4xU4 (S4xU4) tt_um_vga_ca (Space CA) tt_um_llr_simplenpu (simple SPI flash streaming NPU) tt_um_pucv_pspwm (3LFCC PS-PWM Modulator) tt_um_yuri_fpga (Tiny FPGA) tt_um_mikailgedik_inverted_inverters (Inverted inverters) tt_um_esauqch_hamming74 (Hamming(7,4) encoder/decoder (IEEE)) tt_um_hackin7_analog_experiments (TinyAnalogExperiments) tt_um_snake (snake game) tt_um_mini_kraken (Kraken IO Subprocessor) tt_um_fabien_pio (AstraPIO) tt_um_chiplab (ChipLab) tt_um_wokwi_475490677474407425 (Tiny_Divider) tt_um_c061618g2tr (Circuitli C061618G2TR) tt_um_catalinlazar_nanopio (nanoPIO) tt_um_catalinlazar_uart_spi_i2c_bridge (UART-SPI-I2C Bridge) tt_um_enzonappi_sent_i2c (SENT to I2C bridge) tt_um_kush1434_proof (Proof) tt_um_schwallsunk_signal_discriminator (Highspeed voltage discriminator) tt_um_tiarinix_ttihp_verilog_template (8-bit educational SAP-style CPU) tt_um_vga_glyph_mode (BOOTCAMP) tt_um_GiulioGirelli_packet_processor (Configurable Low-Latency Match-Action Packet Processor) tt_um_vga_tictactoe (Tic Tac Toe) tt_um_vga_dvd_player (DVD player) tt_um_clea_katseye_rain (KATSEYE) tt_um_romd_uart_hello (UART Hello World) tt_um_vga_snake (CDM PYTHON GAME) tt_um_vga_slot_machine (tt_um_vga_slot_machine) tt_um_jet_seq8b (SEQ8 Programmable Sequencer) tt_um_kibo_leak_inspect (KIBO Leak-Inspection Target Controller (VGA)) tt_um_endless_runner (Endless Runner) tt_um_omega_infinity_kaoru (OMEGA INFINITY KAORU 3D Metal Grid Processor) tt_um_nikleberg_mixer (Mixer) tt_um_lahnb_sgdma (TinyDMA: A Descriptor-Based Dual-PSRAM Memory Mover) tt_um_gstj_lockin (Digital IQ Lock-in (IEEE)) tt_um_benpayne_ps2_decoder (PS/2 Keyboard Decoder for 68k) tt_um_cass_s_ui_neuron_lif (Neurona LIF con Aprendizaje STDP Dinamico (IEEE)) tt_um_vga_glyph_mode_CDM_Matrix (CDM Matrix) tt_um_qd39l_xor_stream (Fixed-ROM XOR Stream Engine) tt_um_conv3x3 (3x3 Clock Rate Streaming Input Convolution Engine) tt_um_mc14500b_soc_extended (MC14500B Extended 1-bit Microcontroller SoC) tt_um_vga_hypno_spiral (tt_um_vga_hypno_spiral) tt_um_mattizen_morse_tree (Morse Tree LED Decoder) tt_um_CDM (Colegio de Muntinlupa DVD-like Display) tt_um_romd_uart_loader (UART SPI RAM Loader) tt_um_TscherterJunior_stapel_geraet (stapel gerät) tt_um_das2225_dna_accel (DNA_Accel) tt_um_tinysoc (TinySoC) tt_um_barrel_shifter (Barrel Shifter) tt_um_approx_mac_coprocessor (Approximate DSP: Time-Multiplexed MAC Coprocessor) tt_um_joesagents_market_split_oracle (Market-split oracle) tt_um_mgpauly1458_ringmeter (Ring oscillator frequency meter) tt_um_pettit_prism_lite (PRISM with Risc-V (TinyQV) SoC) tt_um_workshop_cpu (IEEE Workshop Simple CPU) tt_um_algofoogle_analog_junk (Simple comparator + 2 DACs analog layout in a 1x1 tile) tt_um_lkhanh_cordic (TinyQV SoC (Dual Memory Backend)) tt_um_4x4npu (4x4NPU: Dual-Lane INT4 Neural Accelerator) tt_um_abiaselli_izh_bridge_3x2 (Izhikevich event bridge (4 contexts)) tt_um_fabulous_ihp_26b (Tiny FABulous FPGA) tt_um_zanderivo_voronoi (Four-Metric VGA Nearest-Prototype Visualizer)