
This project implements a Block Processor (BP) from the classic 1988 paper "A Pipeline Architecture for Factoring Large Integers with the Quadratic Sieve Algorithm" by Pomerance, Smith, and Tuler.
The quadratic sieve is one of the fastest known algorithms for factoring large composite numbers. This implementation creates a hardware accelerator for the sieving stage of the algorithm, which is the computational bottleneck.
The quadratic sieve algorithm finds numbers that factor completely over a small "factor base" of primes. The BP performs the following operation repeatedly:
For each prime power q ≤ B and address A ≡ A_q (mod q):
When S[A] exceeds a threshold T, the value at position A likely factors completely over the factor base.
This "sieving" operation is embarrassingly parallel and well-suited to hardware acceleration.
Dedicated Inputs (ui_in[7:0]):
ui_in[1:0]: Mode select (00=IDLE, 01=INIT, 10=SIEVE, 11=REPORT)ui_in[2]: Data valid input signalui_in[7:3]: Command/data input (5 bits)Dedicated Outputs (uo_out[7:0]):
uo_out[0]: Busy signal (1 when processing)uo_out[1]: Valid output (1 when operation complete)uo_out[2]: Report valid (1 when threshold exceeded)uo_out[7:3]: Status/data output (5 bits)Bidirectional I/O (uio[7:0]):
uio[0]: SPI CS (Chip Select) - Outputuio[1]: SPI SCK (Clock) - Outputuio[2]: SPI MOSI (Master Out) - Outputuio[3]: SPI MISO (Master In) - Inputuio[7:4]: Reserved for future useConnect external SPI RAM (see External hardware section)
Initialize the sieve memory:
ui_in[1:0] = 01 (INIT mode)uo_out[0] = 0 (not busy)Perform sieving:
ui_in[1:0] = 10 (SIEVE mode)ui_in[2] = 1 (data valid)ui_in[7:3] = starting addressuo_out[2] for reports (threshold exceeded)Check results:
uo_out[2] = 1, read uo_out[7:3] for addressRun automated tests:
cd test
make
This implementation is based on groundbreaking research from 1988, when the authors predicted that custom hardware could factor 100-digit numbers in less than a month. The paper estimated a custom $50,000 device could factor 100-digit numbers in two weeks, representing an order of magnitude speedup over 1988-era supercomputers.
Pomerance, C., Smith, J.W., and Tuler, R. "A Pipeline Architecture for Factoring Large Integers with the Quadratic Sieve Algorithm." SIAM Journal on Computing, Vol. 17, No. 2, April 1988, pp. 387-403.
Built with Tiny Tapeout
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | in0 | out0 | cs |
| 1 | in1 | out1 | sck |
| 2 | in2 | out2 | mosi |
| 3 | in3 | out3 | miso |
| 4 | in4 | out4 | |
| 5 | in5 | out5 | |
| 6 | in6 | out6 | |
| 7 | in7 | out7 |