From c4f8059d7f99c60ddac86c9339eca7c8454f531d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Sat, 29 Oct 2022 22:02:02 +0200
Subject: [PATCH] Move popc module to arith/lib.

---
 hw/Makefile                          | 11 +++++------
 hw/arith/Makefile                    |  2 +-
 hw/{popc.vl => arith/lib/popc.v}     |  0
 hw/{popc-tb.vl => arith/popc-test.v} |  2 --
 4 files changed, 6 insertions(+), 9 deletions(-)
 rename hw/{popc.vl => arith/lib/popc.v} (100%)
 rename hw/{popc-tb.vl => arith/popc-test.v} (98%)

diff --git a/hw/Makefile b/hw/Makefile
index 046d196..27c7f49 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 6696fab..01cfdbc 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 2dddf9f..f05ac3a 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;
-- 
GitLab