-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (85 loc) · 2.48 KB
/
Makefile
File metadata and controls
102 lines (85 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# =============================================================================
# Makefile for 16-bit ALU RTL Simulation
# Author: RTL Generator
# Date: 2025-01-19
# =============================================================================
# Simulator selection (iverilog, xsim, vsim, vcs)
SIM ?= iverilog
# Directories
RTL_DIR = rtl
TB_DIR = tb
SIM_DIR = sim
# Source files
RTL_SOURCES = \
$(RTL_DIR)/common/alu_pkg.sv \
$(RTL_DIR)/control/alu_control_decoder.sv \
$(RTL_DIR)/arithmetic/alu_arithmetic_unit.sv \
$(RTL_DIR)/logic/alu_logic_unit.sv \
$(RTL_DIR)/shift/alu_shift_unit.sv \
$(RTL_DIR)/mux/alu_result_mux.sv \
$(RTL_DIR)/flags/alu_flag_generator.sv \
$(RTL_DIR)/alu_16bit_top.sv
TB_SOURCES = \
$(TB_DIR)/alu_16bit_tb.sv
# Output files
VCD_FILE = $(SIM_DIR)/alu_16bit.vcd
LOG_FILE = $(SIM_DIR)/simulation.log
# Compilation flags
VLOG_FLAGS = -g2012 -Wall
VVP_FLAGS =
# Default target
all: sim
# Create simulation directory
$(SIM_DIR):
@mkdir -p $(SIM_DIR)
# Compile with Icarus Verilog
compile-iverilog: $(SIM_DIR)
iverilog $(VLOG_FLAGS) -o $(SIM_DIR)/alu_16bit.vvp \
$(RTL_SOURCES) $(TB_SOURCES)
# Run simulation with Icarus Verilog
sim-iverilog: compile-iverilog
cd $(SIM_DIR) && vvp alu_16bit.vvp | tee simulation.log
# View waveforms
wave: $(VCD_FILE)
gtkwave $(VCD_FILE) &
# Clean build artifacts
clean:
rm -rf $(SIM_DIR)
rm -f *.vcd *.log
# Synthesis with Yosys (optional)
synth:
yosys -p "read_verilog -sv $(RTL_SOURCES); \
hierarchy -top ALU_16bit; \
proc; opt; \
techmap; opt; \
write_verilog $(SIM_DIR)/alu_16bit_synth.v; \
stat"
# Lint with Verilator
lint:
verilator --lint-only -Wall --top-module ALU_16bit \
$(RTL_SOURCES)
# Help
help:
@echo "Makefile for 16-bit ALU Simulation"
@echo ""
@echo "Targets:"
@echo " all - Run simulation (default)"
@echo " compile - Compile RTL and testbench"
@echo " sim - Run simulation"
@echo " wave - View waveforms"
@echo " synth - Synthesize with Yosys"
@echo " lint - Lint check with Verilator"
@echo " clean - Remove build artifacts"
@echo " help - Show this help message"
@echo ""
@echo "Variables:"
@echo " SIM - Simulator to use (iverilog, xsim, vsim, vcs)"
@echo ""
@echo "Examples:"
@echo " make # Run simulation with Icarus Verilog"
@echo " make wave # View waveforms"
@echo " make clean # Clean build artifacts"
# Shortcuts
compile: compile-$(SIM)
sim: sim-$(SIM)
.PHONY: all compile sim wave synth lint clean help