diff --git a/hw/Makefile b/hw/Makefile
index 046d196b5961ed86d2397039401f88228adaf4cd..27c7f4909200f6e806c784f0e293c2f7dacff9b1 100644
--- a/hw/Makefile
+++ b/hw/Makefile
@@ -10,7 +10,7 @@ all: $(TARGETS)
 TESTS = carry-64-tb carry-only-tb \
 	genmask-tb mul3-stage-tb mul4-stage-tb mul6-stage-tb \
 	mul-3w64-tb mul-4w64-tb mul-6w64-tb srt-reciprocal-tb reciprocal-tb \
-	reg-file-tb reg-file-ice40-tb shift-unit-tb alu-unit-tb popc-tb
+	reg-file-tb reg-file-ice40-tb shift-unit-tb alu-unit-tb
 
 check: all $(TESTS)
 	../run-tests $(TESTS)
@@ -27,7 +27,7 @@ clean:
 top-ice40-sim: top-ice40.vl cpu-all.vl reg-file-ice40.vl mem-mux.vl \
 	alu-unit.vl unary-unit.vl shift-unit.vl cnt-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
-	instr-fetch.vl instr-decode.vl popc.vl srt-reciprocal.vl \
+	instr-fetch.vl instr-decode.vl srt-reciprocal.vl \
 	cpu.vl top-ice40-sim.vl \
 	ram-unit.vl avr109rx.vl avr109tx.vl tty-ice40.vl
 
@@ -44,7 +44,7 @@ random-bram.hex:
 top-ice40.json: top-ice40.vl cpu-all.vl reg-file-ice40.vl mem-mux.vl \
 	alu-unit.vl unary-unit.vl shift-unit.vl cnt-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
-	instr-fetch.vl instr-decode.vl popc.vl srt-reciprocal.vl \
+	instr-fetch.vl instr-decode.vl srt-reciprocal.vl \
 	cpu.vl \
 	ram-unit.vl avr109rx.vl avr109tx.vl tty-ice40.vl random-bram.hex
 	yosys -q -p 'hierarchy -libdir arith/lib ; synth_ice40 -json top-ice40.json' \
@@ -70,7 +70,7 @@ logic-analyzer-example.asc: logic-analyzer-example.json txd.pcf
 	--json $< --pcf txd.pcf --asc $@
 
 stats: mul-3w64.stats mul-4w64.stats \
-	srt-reciprocal.stats popc.stats \
+	srt-reciprocal.stats \
 	instr-fetch.stats instr-decode.stats \
 	reg-file.stats reg-file-ice40.stats \
 	cnt-unit.stats alu-unit.stats mem-mux.stats \
@@ -84,7 +84,6 @@ stats: mul-3w64.stats mul-4w64.stats \
 mul-3w64.stats: mul3-stage.vl
 mul-4w64.stats: mul4-stage.vl
 srt-reciprocal.stats: srt-reciprocal.vl
-cnt-unit.stats: popc.vl
 mul-unit.stats: mul3-stage.vl mul-3w64.vl mul4-stage.vl mul-4w64.vl
 mul-unit.stats: STATS_FLAGS = -top mul_unit
 
@@ -95,6 +94,6 @@ tty-ice40.stats: avr109rx.vl avr109tx.vl
 cpu.stats: cpu-all.vl reg-file-ice40.vl mem-mux.vl \
 	alu-unit.vl unary-unit.vl shift-unit.vl cnt-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
-	instr-fetch.vl instr-decode.vl popc.vl srt-reciprocal.vl \
+	instr-fetch.vl instr-decode.vl srt-reciprocal.vl \
 	cpu.vl ram-unit.vl
 	$(YOSYS_STATS) $< > $@T && mv $@T $@
diff --git a/hw/arith/Makefile b/hw/arith/Makefile
index 6696fab8bca20bfe749ba7ff05d9870716a5570a..01cfdbc784ed0adf9e0b4217c7a4a19285699e22 100644
--- a/hw/arith/Makefile
+++ b/hw/arith/Makefile
@@ -6,7 +6,7 @@ IVERILOG_FLAGS = -g2005-sv -Wall -y lib
 TARGETS = dadda-tree
 
 TESTS = add_ha-test add_fa-test add_bk4-test add_bk8-test add_bk8s-test \
-	add_h64-test add_bk16-test umul4-test umul8-test ctz-test
+	add_h64-test add_bk16-test umul4-test umul8-test ctz-test popc-test
 
 all: $(TARGETS)
 
diff --git a/hw/popc.vl b/hw/arith/lib/popc.v
similarity index 100%
rename from hw/popc.vl
rename to hw/arith/lib/popc.v
diff --git a/hw/popc-tb.vl b/hw/arith/popc-test.v
similarity index 98%
rename from hw/popc-tb.vl
rename to hw/arith/popc-test.v
index 2dddf9f0c05d32d49e738af382aad94928f08a53..f05ac3aa477612b89b7d23294a78394016c64c10 100644
--- a/hw/popc-tb.vl
+++ b/hw/arith/popc-test.v
@@ -14,8 +14,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-`include "popc.vl"
-
 module main;
    reg [63:0] x;
    wire [6:0] cnt;