From a43e2acf9d55ade7c0c661b5eb97ec63fa01876a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 31 Oct 2022 21:43:03 +0100
Subject: [PATCH] Move alu_unit to cpu/lib.

---
 hw/Makefile                                | 10 +++++-----
 hw/cpu/.gitignore                          |  1 +
 hw/cpu/Makefile                            | 15 +++++++++++++++
 hw/{alu-unit-tb.vl => cpu/alu_unit-test.v} |  1 -
 hw/{alu-unit.vl => cpu/lib/alu_unit.v}     |  0
 5 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 hw/cpu/.gitignore
 create mode 100644 hw/cpu/Makefile
 rename hw/{alu-unit-tb.vl => cpu/alu_unit-test.v} (99%)
 rename hw/{alu-unit.vl => cpu/lib/alu_unit.v} (100%)

diff --git a/hw/Makefile b/hw/Makefile
index 1f02f3c..d7d8211 100644
--- a/hw/Makefile
+++ b/hw/Makefile
@@ -7,7 +7,7 @@ TARGETS = main
 
 all: $(TARGETS)
 
-TESTS = reg-file-tb reg-file-ice40-tb alu-unit-tb
+TESTS = reg-file-tb reg-file-ice40-tb
 
 check: all $(TESTS)
 	../run-tests $(TESTS)
@@ -23,7 +23,7 @@ clean:
 -include $(TARGETS:=.d) $(TESTS:=.d)
 
 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 \
+	unary-unit.vl shift-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
 	instr-fetch.vl instr-decode.vl \
 	cpu.vl top-ice40-sim.vl \
@@ -40,7 +40,7 @@ random-bram.hex:
 	icebram -g -s 4711 64 1024 > $@T && mv $@T $@
 
 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 \
+	unary-unit.vl shift-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
 	instr-fetch.vl instr-decode.vl \
 	cpu.vl \
@@ -69,7 +69,7 @@ logic-analyzer-example.asc: logic-analyzer-example.json txd.pcf
 
 stats: instr-fetch.stats instr-decode.stats \
 	reg-file.stats reg-file-ice40.stats \
-	alu-unit.stats mem-mux.stats \
+	mem-mux.stats \
 	unary-unit.stats shift-unit.stats mul-unit.stats \
 	reciprocal-unit.stats ram-unit.stats \
 	cpu.stats tty-ice40.stats
@@ -82,7 +82,7 @@ mul-unit.stats: STATS_FLAGS = -top mul_unit
 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 \
+	unary-unit.vl shift-unit.vl \
 	mul-unit.vl reciprocal-unit.vl load-store-unit.vl \
 	instr-fetch.vl instr-decode.vl \
 	cpu.vl ram-unit.vl
diff --git a/hw/cpu/.gitignore b/hw/cpu/.gitignore
new file mode 100644
index 0000000..e2b3c8f
--- /dev/null
+++ b/hw/cpu/.gitignore
@@ -0,0 +1 @@
+/shift_unit-test
diff --git a/hw/cpu/Makefile b/hw/cpu/Makefile
new file mode 100644
index 0000000..a316fa5
--- /dev/null
+++ b/hw/cpu/Makefile
@@ -0,0 +1,15 @@
+TESTS = alu_unit-test shift_unit-test
+
+IVERILOG_FLAGS = -g2005-sv -Wall -y lib -y ../arith/lib -I..
+
+all:
+	true
+
+check: $(TESTS)
+	../../run-tests $(TESTS)
+
+%: %.v
+	iverilog $(IVERILOG_FLAGS) -Mall=$@.dT  -o $@ $<  \
+	&& sed 's,^,$@: ,' < $@.dT > $@.d && rm -f $@.dT
+
+-include $(TESTS:=.d)
diff --git a/hw/alu-unit-tb.vl b/hw/cpu/alu_unit-test.v
similarity index 99%
rename from hw/alu-unit-tb.vl
rename to hw/cpu/alu_unit-test.v
index d62b281..b696693 100644
--- a/hw/alu-unit-tb.vl
+++ b/hw/cpu/alu_unit-test.v
@@ -15,7 +15,6 @@
 */
 
 `include "instr-defines.vl"
-`include "alu-unit.vl"
 
 module main;
    reg [63:0] a;
diff --git a/hw/alu-unit.vl b/hw/cpu/lib/alu_unit.v
similarity index 100%
rename from hw/alu-unit.vl
rename to hw/cpu/lib/alu_unit.v
-- 
GitLab