Preprint
Brief Report

This version is not peer-reviewed.

An RV32IMC Processor with a Tightly Coupled Linear Classifier Accelerator for Edge AI Inference

Submitted:

29 October 2026

Posted:

29 October 2026

You are already at the latest version

Abstract
Edge AI inference on resource-constrained devices demands low latency, minimal memory footprint, and tight power budgets---requirements that cloud-based inference cannot satisfy due to network latency, bandwidth, and privacy costs. This paper presents the design of an RV32IMC processor tightly coupled with a custom ISA-extended linear-classifier accelerator, described in synthesizable SystemVerilog RTL and evaluated through cycle-accurate simulation. The processor implements the RISC-V RV32I base integer set, the M extension for hardware multiply/divide, and a partial C extension for 16-bit compressed instructions. A 4×4 weight-stationary systolic array is integrated directly into the execute stage of a five-stage pipeline via four custom instructions encoded in the reserved custom-0 opcode space (0x0B). Cycle-accurate RTL simulation on Vivado xsim shows that the hardware accelerator completes a 4-class linear-classification inference in 19 cycles, a 4.2× speedup over an RV32IM software baseline (79 cycles) and a 40.1× speedup over a realistic RV32I general-purpose software baseline (761 cycles). The C extension delivers a 24.24% code-size reduction (528 B → 400 B) with zero performance penalty, via a purely combinational decompressor in the fetch stage. These results indicate that tightly coupled, domain-specific ISA extensions on a compact RISC-V core can deliver meaningful inference acceleration for edge deployment while preserving the modularity of the RISC-V ecosystem. FPGA synthesis and on-hardware characterization were not performed in this work and are identified as future work.
Keywords: 
;  ;  ;  ;  ;  ;  ;  ;  

1. Introduction

Edge devices in domains such as wearable health monitors, industrial sensor networks, and autonomous micro-robots face strict power, memory, and real-time constraints. Cloud-based inference avoids these limits but introduces network latency, bandwidth cost, and privacy risk, motivating local inference on lightweight processors.
The RISC-V ISA [1] is well suited to this role: a minimal base integer set (RV32I) can be augmented with standard extensions (M, C) and, critically, with custom instructions in reserved opcode space, letting designers embed application-specific accelerators directly in the pipeline without modifying the base ISA or breaking toolchain compatibility.
This paper addresses the following research question: Can a lightweight RISC-V processor with a tightly coupled, domain-specific AI accelerator provide meaningful inference speedup for resource-constrained edge devices while maintaining a compact ISA implementation and minimal hardware overhead?
This paper makes the following contributions:
  • An RV32IMC processor architecture for edge AI inference, with a five-stage pipeline, hazard forwarding, CSR support, and dynamic branch prediction.
  • A custom RISC-V ISA extension of four instructions (lc.load_weight, lc.load_input, lc.start, lc.read) for hardware-accelerated linear classification, encoded in custom-0.
  • A tightly coupled 4 × 4 weight-stationary systolic array integrated directly into the execute stage, giving fixed-latency, data-independent inference.
  • A hardware/software co-design methodology that lets programmers invoke the accelerator from standard RISC-V assembly via .insn directives, with no toolchain modifications.
  • A quantitative evaluation covering inference speedup ( 4.2 – 40.1 × ), code-density improvement ( 24.24 % ), and cycle-accurate RTL measurements.
Section II reviews related work; Sections III–VII cover background, the proposed architecture, the software interface, the experimental setup, and results; Section VIII discusses the findings, and Section IX concludes.

3. Background

3.1. RISC-V ISA

RISC-V [1] is a modular, open ISA. The RV32I base provides 37 instructions for arithmetic/logic, load/store, control flow, and system operations. The M extension adds hardware multiply/divide; the C extension defines 16-bit compressed encodings for common instruction patterns, shrinking code size without changing program semantics. Four opcode ranges (custom-0–custom-3) are reserved for implementation-specific extensions and are encodable via the standard .insn assembler directive.

3.2. Custom Instructions

The custom-0 opcode (0x0B, 0001011) is an R-type 32-bit format with funct3 (3 b), funct7 (7 b), and three register specifiers, supporting up to 8 distinct instructions via funct3 alone. Our design uses four of the eight slots, leaving four for future extensions. The privileged specification [9] further provides the mcycle CSR, which increments every clock edge and gives cycle-accurate performance measurement with no instrumentation overhead—the basis of our benchmarking methodology.

3.3. Edge AI Inference

Edge inference workloads are dominated by multiply-accumulate (MAC) operations. A linear classifier y = Wx for an N-class, D-feature problem needs N × D multiplications and N × ( D − 1 ) additions plus an argmax. For our 4-class, 4-feature configuration this is 16 multiplications and 12 additions—small enough to map onto a compact systolic array, yet representative of the matrix-vector primitives underlying larger network layers.

4. Proposed Architecture

The system couples an RV32IMC core with a 4 × 4 weight-stationary systolic-array linear-classifier accelerator. Decode logic recognizes custom-0 instructions and routes operands directly to the accelerator’s register files and control FSM; accelerator results are multiplexed back into the execute-to-memory pipeline register. This avoids the latency of memory-mapped I/O or coprocessor bus protocols, enabling single-cycle operand delivery and result capture.

4.1. RV32IMC Core Overview

The base core implements the full RV32I set, sufficient to run bare-metal software. The M extension is justified by the ML workload’s computational profile: without hardware multiply, each product decomposes into a multi-cycle shift-and-add loop, increasing latency by up to 9.6 × (Section VII). The C extension reduces code size for flash/SRAM-constrained edge devices, quantified in Section VII-C.

4.2. Pipeline

The core is a classical five-stage pipeline:
  • Fetch (IF): reads instructions, manages PC with stall/flush control; a combinational decoder expands 16-bit RVC instructions to 32-bit form within the same cycle.
  • Decode (ID): decodes opcode, reads the register file, sign-extends immediates, and identifies custom-0 instructions for operand forwarding.
  • Execute (EX): houses the ALU, M-extension multiplier/divider, and the custom-instruction interface. For lc.read (funct3=011), accelerator output replaces the ALU result; for write-type LC instructions (funct3=000,001,010), operands are routed to the accelerator’s register files/FSM.
  • Memory (MEM): data memory access and CSR interfacing.
  • Writeback (WB): 4-to-1 mux selects ALU result, memory data, PC+4, or CSR data.
Figure 1 shows the datapath realizing this pipeline. Full forwarding from MEM/WB to EX resolves RAW hazards without stalls; load-use hazards cause a one-cycle stall; branches/jumps flush the pipeline, mitigated by a dynamic branch predictor (BHT + BTB).

4.3. Control and Status Registers (CSR)

The CSR unit implements M-mode (mstatus, mtvec, mepc, mcause, mscratch, mcycle/mcycleh) and S-mode (sstatus, stvec, sepc, scause) registers per [9]. mcycle increments every rising edge and is read/written via csrr/csrw; all Section VII measurements use it as the timing reference.

4.4. Custom Linear Classifier (LC) Instruction Set

Figure 2 shows the accelerator’s top-level architecture. Four instructions are defined under opcode 0x0B (R-type), differentiated by funct3, as summarized below. A linear classifier was chosen as the accelerated workload because it is mathematically simple ( y = Wx , argmax) and easy to verify, representative of the matrix-vector primitive underlying fully connected layers and attention/embedding lookups, and it exercises the full ISA-extension methodology—custom decode, operand routing, result writeback—while remaining extensible to future GEMM/CNN accelerators via the four unused funct3 slots.
Instruction funct3 Semantics / operands
lc.load_weight 000 Write signed 8-bit weight to [row,col]; rs1[7:0]=data, rs2[3:2]=row, rs2[1:0]=col
lc.load_input 001 Write signed 8-bit feature to [addr]; rs1[7:0]=data, rs2[1:0]=addr
lc.start 010 Trigger FSM: load → compute → capture → done; no operands
lc.read 011 Read output into rd; rs1[2:0] selects 0=done, 1=class, 2–5=scores[0–3]

4.5. Systolic Array Accelerator

The accelerator core is a 4 × 4 weight-stationary systolic array (systolic_4x4), shown as the Computation Core block in Figure 2. Each PE holds an 8-bit signed weight register (loaded once via lc.load_weight) and a MAC unit computing psum_out = psum_in + (act_in×weight) every cycle, plus a registered activation output that passes act_in to the next PE in the row after one cycle. Activations enter from the left of each row; partial sums flow top-to-bottom (initialized to zero); after full propagation the bottom row holds scores [ j ] = ∑ i x [ i ] · W [ i ] [ j ] .
A controller FSM sequences five states, shown in Figure 3 and summarized below, for a total FSM latency of 10 cycles ( 1 + 7 + 1 + 1 , plus the initial IDLE wait). Combined with CPU pipeline overhead for lc.start, the poll loop, and the csrr readback, the measured end-to-end latency is 19 cycles. A purely combinational argmax block then selects the predicted class from the captured scores.
State Duration Action
IDLE — Wait for lc.start pulse
LOAD_WEIGHTS 1 cycle Latch weight registers into PEs
COMPUTE 2 N − 1 = 7 cyc. Systolic pipeline flush (N rows + N − 1 column propagation)
CAPTURE 1 cycle Latch bottom-row scores into output registers
DONE 1 cycle Assert done; combinational argmax selects class

5. Software Interface

5.1. ISA Encoding

All four LC instructions use the R-type format with opcode 0x0B (bits [6:0] = 0001011):
funct7 rs2 rs1 funct3 rd opcode
[31:25] [24:20] [19:15] [14:12] [11:7] [6:0]
The operand mapping for each instruction is given below; funct7 is 0000000 throughout.
Instr. funct3 rd rs1 rs2
lc.load_weight 000 x0 data index
lc.load_input 001 x0 data address
lc.start 010 x0 x0 x0
lc.read 011 dest. selector x0

5.2. Assembly Programming Model

All custom instructions are encoded with the standard GNU assembler .insn r directive, requiring no custom toolchain modifications. An abbreviated excerpt (full sequence loads 16 weights and 4 inputs):
# load one weight: W[0][0] = 3
li x11, 3 ; li x12, 0
.insn r 0x0b,0,0,x0,x11,x12  # lc.load_weight
# ... (16 weights, 4 inputs total) ...
csrw mcycle, x0              # zero cycle counter
.insn r 0x0b,2,0,x0,x0,x0    # lc.start
poll:
  li x12, 0
  .insn r 0x0b,3,0,x14,x12,x0  # x14=done
  beqz x14, poll
csrr t5, mcycle               # capture cycles
li x12, 1
.insn r 0x0b,3,0,x21,x12,x0  # x21=class

6. Experimental Setup

6.1. Target Platform and Simulation Environment

The processor and accelerator are described entirely in synthesizable SystemVerilog RTL, targeting the Xilinx 7-series FPGA family as the intended eventual deployment platform. All results in this paper are obtained through RTL simulation in Xilinx Vivado 2018.2 (xsim); FPGA synthesis, place-and-route, and on-hardware deployment were not performed as part of this work. Consequently, no post-synthesis resource-utilization or timing (Fmax) figures are reported; this is identified as a direction for future work in Section IX.

6.2. Toolchain

Tool Ver. Purpose
Xilinx Vivado 2018.2 RTL simulation (xsim) only; no synthesis performed
riscv-none-elf-gcc 15.2.0 Cross-compilation, assembly
riscv-none-elf-ld — Linking (custom linker script)
riscv-none-elf-objdump — Disassembly, binary inspection
RV32IM builds use -march=rv32im_zicsr -mabi=ilp32 -ffreestanding -nostdlib; RV32IMC builds substitute rv32imc_zicsr.

6.3. Testbench

Correctness is verified through: (1) RTL simulation in Vivado xsim with SystemVerilog testbenches comparing register outputs against golden values; (2) firmware self-verification, where each benchmark checks its own outputs and writes 0xFEEDDEED on success or a 0xDEADxxxx pattern on mismatch to x31; and (3) cross-implementation validation, where all four implementations below compute identical inputs/outputs for direct comparison.

6.4. Benchmarks

The workload is a 4-class linear classification y = Wx with INT8 weight matrix
W = 3 5 − 4 7 − 5 4 6 − 3 4 − 6 3 5 − 3 7 − 5 4 , x = [ 5 , 7 , 4 , 6 ] ,
giving expected scores y = [ − 22 , 71 , 4 , 58 ] and predicted class 1 (max score 71). Four implementations of this workload are compared: (1) HW accelerator (custom instructions, mcycle spans lc.start→done→csrr); (2) RV32IM software, using hardware mul; (3) RV32I hardcoded, using compile-time-known shift-and-add decompositions; and (4) RV32I general (sw_mul), a runtime shift-and-add subroutine handling arbitrary operands—the only variant compatible with arbitrary, trained (runtime-determined) weights. Measurement is identical across variants: csrw mcycle,x0 before the first computation instruction, csrr t5,mcycle immediately after the result is ready.

7. Results

7.1. Cycle Measurements

Cycle counts for all four implementations were measured via mcycle directly inside Vivado xsim RTL simulation on the benchmark of Section VI-D; no estimation was used, and all four programs passed correctness self-checks (x31 = 0xFEEDDEED). The hardware accelerator’s 19-cycle latency is completely independent of input and weight values: the FSM’s 10 fixed cycles (Section IV-E) plus 9 cycles of CPU pipeline overhead (lc.start traversal, poll-loop iterations, csrr readback). The RV32IM baseline (79 cycles) executes 15 arithmetic instructions per score (4×(li+li+mul)+3×add) across 4 scores plus argmax/CSR overhead. The RV32I hardcoded baseline (82 cycles) decomposes each weight into a compile-time shift-and-add sequence—an upper-bound reference that assumes weights are known at compile time, unrealistic for deployed inference. The RV32I general baseline (761 cycles) instead discovers each multiplier’s bit pattern at runtime (2 cyc. setup, 2 cyc. call overhead, 8 cyc. sign-extraction, ∼22 cyc. loop body, 4 cyc. sign check/return per call, over 16 calls), representing the realistic cost of a base core without the M extension. Repeating the measurement with a second, simpler weight matrix (containing a zero weight) reproduced exactly 19 cycles on the hardware path, while software baselines shifted slightly (RV32IM: 75 vs. 79; RV32I hardcoded: 60 vs. 82) due to zero-skip effects—confirming that only the hardware path offers deterministic, data-independent latency.

7.2. Speedup

Speedup is computed as Software Cycles / Hardware Cycles, with the RV32IMC+LC accelerator as the hardware baseline (Table 1). RV32I (general sw_mul) is used as the representative “software, no M” baseline because it is the only software implementation compatible with arbitrary, trained weights—the standard operating mode for a deployed classifier.
For reference, the compile-time-optimized RV32I hardcoded variant measured 82 cycles ( 4.32 × )—essentially matching RV32IM, but only under the unrealistic assumption that all weights are compile-time constants. The gap between the RV32I-general and RV32IM rows ( 761 / 79 = 9.63 × ) separately quantifies the cost of lacking a hardware multiplier for this benchmark’s weight range ( { 3 . . 9 } , up to 3 shift-and-add iterations); this ratio would be expected to grow to roughly 20– 25 × across the full INT8 weight range typical of trained quantized classifiers.

7.3. Code Density

The same general-multiplication program (lc_b2_rvi_gen.s) was compiled twice from identical source, with and without the C extension (-march=rv32i_zicsr vs. rv32ic_zicsr, both -mabi=ilp32 -ffreestanding -nostdlib), isolating the C-extension effect alone rather than comparing RV32IM against RV32IMC—since M and C are orthogonal optimizations (Section VIII). Results are measured from the .text section of the linked ELF binary.
Table 2. Code Density: RV32I vs. RV32IC *
Table 2. Code Density: RV32I vs. RV32IC *
Metric RV32I RV32IC
Instruction count 132 128
Binary size (bytes) 528 400
Code-size reduction — 24.24%
* Isolates the C-extension effect; M and C are orthogonal, so the reduction applies equally regardless of which other extensions are enabled.
The 24.24% reduction ( − 128  B) comes from 56 compressed 16-bit instructions (43.75% of the binary), predominantly C.LI (38, weight/input arguments and argmax constants), C.ADD (13, score accumulation), C.MV (4, initial score capture), and one each of C.SLLI/C.SRLI. This falls short of the theoretical 25– 40 % RVC ratio because the decoder implements a subset of RVC, missing C.JAL (16 instances, 32 B), C.BEQZ/C.BNEZ (3, 6 B), C.JR (1, 2 B), and C.J (3, 6 B)—46 B of additional potential savings that would raise the ratio to ≈ 32.9 % . Because the decompressor is a purely combinational block in the fetch stage, both variants measured identical execution latency (761 cycles): the code-density and performance optimizations compose with zero interference.

7.4. Correctness Verification

All four implementations produced bit-identical outputs (predicted class and all four scores), confirmed by both RTL register inspection and firmware self-checks (x31 = 0xFEEDDEED on every run).

8. Discussion

The results reveal three insights about the performance/code-density trade-offs of tightly coupled ISA-extended accelerators; a full area/performance trade-off analysis is left to future work pending FPGA synthesis and implementation (Section IX).
1) Fixed-latency acceleration eliminates data-dependent variability. The accelerator’s 19-cycle latency is invariant to input and weight values, giving deterministic worst-case execution time—a critical property for real-time edge applications. The RV32I general software baseline, by contrast, has data-dependent timing proportional to operand bit-width.
2) The realistic speedup is 40 × , not 4 × . The 4.2 × figure reflects the best-case software scenario (hardware multiplier present, hand-optimized code); the 40.1 × figure reflects the realistic scenario for a base core without the M extension—the configuration most relevant to ultra-low-cost edge devices, and the only one compatible with arbitrary, trained weights.
3) Code compression and inference acceleration are orthogonal. The C extension’s 24.24% reduction applies to the whole program’s instruction-memory footprint independent of whether inference runs in hardware or software, so the two optimizations compose without interference.
Limitations. The most significant limitation is evaluative scope: this work reports RTL-simulation results only. The design has not been synthesized, placed, or routed on physical FPGA hardware, so resource utilization, maximum operating frequency, timing closure, and power consumption remain unmeasured, and the speedup/code-density results should be read as behavioral, cycle-accurate figures rather than post-implementation ones. On the architectural side, the accelerator is restricted to 4 × 4 linear classification; larger matrices or multi-layer networks would need DMA-based weight/activation streaming, larger arrays, or tiling. The INT8 datapath may need mixed-precision support (INT8 in, INT16/INT32 accumulate) for deeper networks. Polling wastes CPU cycles that an interrupt-driven completion signal would reclaim. The partial RVC decoder leaves ∼9 percentage points of compression on the table; completing it (C.J, C.JAL, C.BEQZ, C.BNEZ, C.JR) would close this gap.

9. Conclusion and Future Work

This paper presented an RV32IMC processor with a tightly coupled linear-classifier accelerator, showing via cycle-accurate RTL simulation that custom ISA extensions on a compact RISC-V core can deliver 40.1× inference speedup over a realistic software baseline and 4.2× over an optimized M-extension software implementation, while the C extension gives a 24.24% code-size reduction at zero performance penalty. The accelerator’s fixed 19-cycle latency, independent of input data, provides deterministic timing suitable for real-time edge use. These results are based entirely on behavioral RTL simulation; the design has not yet been synthesized or validated on physical FPGA hardware. The RTL, testbenches, and benchmark sources are available at https://github.com/abdoAhmed704/RISCV-MicroKernel-Architecture.
Future work: FPGA synthesis, implementation, and on-hardware validation, to obtain resource-utilization, maximum-frequency, and power figures and confirm the simulation-based speedup and code-density results on real silicon; larger systolic arrays (8×8, 16×16) for higher-dimensional classifiers and FC layers; CNN/convolution support via activation-function hardware and feature-map buffering; a general GEMM engine extending beyond linear classification via tiling; DMA support for weight/activation transfer, removing per-element register-write overhead; interrupt-driven completion in place of polling; quantization support (INT4/INT8 mixed precision); SIMD/vector integration for data-parallel preprocessing; multi-core integration with shared accelerator access; and a complete RVC decoder to reach the full theoretical ∼33% compression ratio.

Acknowledgments

The authors thank the Electrical Engineering Department at Beni-Suef University for supporting this graduation project and providing access to FPGA development tools and simulation infrastructure.

References

  1. A. Waterman and K. Asanović, Eds., “The RISC-V Instruction Set Manual, Volume I: Unprivileged ISA,” Document Version 20191213, RISC-V International, Dec. 2019. [Online]. Available: https://riscv.org/specifications/.
  2. E. Flamand et al., “GAP-8: A RISC-V SoC for AI at the Edge of the IoT,” in Proc. IEEE Int. Conf. Application-specific Systems, Architectures and Processors (ASAP), 2018, pp. 1–4. [CrossRef]
  3. D. Lee et al., “Custom RISC-V Instructions for Lightweight Post-Quantum Cryptography,” IEEE Trans. Very Large Scale Integration (VLSI) Systems, vol. 31, no. 10, pp. 1573–1586, 2023.
  4. N. P. Jouppi et al., “In-Datacenter Performance Analysis of a Tensor Processing Unit,” in Proc. Int. Symp. Computer Architecture (ISCA), 2017, pp. 1–12.
  5. ARM Ltd., “Arm Ethos-U55 and Ethos-U65 Micro NPU Technical Reference Manual,” 2021. [Online]. Available: https://developer.arm.com/.
  6. B. Moons et al., “DIANA: An End-to-End Energy-Efficient Digital and ANAlog Hybrid Neural Network SoC,” in Proc. IEEE Int. Solid-State Circuits Conf. (ISSCC), 2023, pp. 412–414.
  7. H. T. Kung and C. E. Leiserson, “Systolic arrays (for VLSI),” in Sparse Matrix Proc., 1978, pp. 256–282.
  8. N. P. Jouppi et al., “Ten Lessons From Three Generations of Tensor Processing Units,” in Proc. Int. Symp. Computer Architecture (ISCA), 2023, pp. 1–14.
  9. A. Waterman and K. Asanović, Eds., “The RISC-V Instruction Set Manual, Volume II: Privileged Architecture,” Document Version 20211203, RISC-V International, Dec. 2021. [Online]. Available: https://riscv.org/specifications/.
Figure 1. Datapath of the base RV32I five-stage pipeline, showing the IF/ID/EX/MEM/WB pipeline registers, register file, ALU, control unit, and hazard unit. The M-extension multiplier/divider, C-extension decompressor, and the custom-0 accelerator interface described above extend this datapath in the fetch and execute stages and are omitted here for clarity.
Figure 1. Datapath of the base RV32I five-stage pipeline, showing the IF/ID/EX/MEM/WB pipeline registers, register file, ALU, control unit, and hazard unit. The M-extension multiplier/divider, C-extension decompressor, and the custom-0 accelerator interface described above extend this datapath in the fetch and execute stages and are omitted here for clarity.
Preprints 241159 g001
Figure 2. Top-level architecture of the linear-classifier accelerator. The Memory & Buffers block (weight/input register files) is driven by the lc.load_weight/lc.load_input instructions of Section IV-D; the Control & Sequencing and Computation Core blocks (controller FSM, systolic array, output capture register, argmax logic) are detailed in Section IV-E.
Figure 2. Top-level architecture of the linear-classifier accelerator. The Memory & Buffers block (weight/input register files) is driven by the lc.load_weight/lc.load_input instructions of Section IV-D; the Control & Sequencing and Computation Core blocks (controller FSM, systolic array, output capture register, argmax logic) are detailed in Section IV-E.
Preprints 241159 g002
Figure 3. Controller FSM state diagram. S_COMPUTE self-loops while cycle_cnt  < 7 , implementing the systolic pipeline flush; state durations and per-state actions are summarized in the table below.
Figure 3. Controller FSM state diagram. S_COMPUTE self-loops while cycle_cnt  < 7 , implementing the systolic pipeline flush; state durations and per-state actions are summarized in the table below.
Preprints 241159 g003
Table 1. Cycle Counts and Speedup
Table 1. Cycle Counts and Speedup
Configuration Cycles Speedup (×)
RV32I (software, no M) 761 40.1×
RV32IM (software) 79 4.16×
RV32IMC + LC accelerator (hw) 19 —
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.