-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile_1mb
More file actions
97 lines (82 loc) · 3.46 KB
/
Makefile_1mb
File metadata and controls
97 lines (82 loc) · 3.46 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
# Makefile for SHA256 1MB Processor Simulation
# Verilator settings
VERILATOR = verilator
VERILATOR_FLAGS = -Wall -Wno-WIDTHTRUNC -Wno-WIDTHEXPAND -Wno-UNSIGNED -Wno-EOFNEWLINE -Wno-DECLFILENAME -Wno-UNUSEDPARAM -Wno-INFINITELOOP --no-timing --cc --exe --build --trace
# Source files
VERILOG_SOURCES = sha256_1mb_processor.v
CPP_SOURCES = sha256_1mb_sim_main.cpp
CPP_QUICK_SOURCES = sha256_1mb_sim_main_quick.cpp
# Output executable
EXECUTABLE = sha256_1mb_sim
EXECUTABLE_QUICK = sha256_1mb_sim_quick
# Default target
all: $(EXECUTABLE)
# Build the 1MB simulation
$(EXECUTABLE): $(VERILOG_SOURCES) $(CPP_SOURCES)
@echo "Building SHA256 1MB processor simulation..."
$(VERILATOR) $(VERILATOR_FLAGS) -top-module sha256_1mb_processor \
$(VERILOG_SOURCES) $(CPP_SOURCES) -o $(EXECUTABLE)
@echo "Build complete!"
# Build the quick test simulation
$(EXECUTABLE_QUICK): $(VERILOG_SOURCES) $(CPP_QUICK_SOURCES)
@echo "Building SHA256 1MB processor quick test..."
$(VERILATOR) $(VERILATOR_FLAGS) -top-module sha256_1mb_processor \
$(VERILOG_SOURCES) $(CPP_QUICK_SOURCES) -o $(EXECUTABLE_QUICK)
@echo "Quick test build complete!"
# Run the 1MB simulation
run: $(EXECUTABLE)
@echo "Running SHA256 1MB processor simulation..."
@echo "WARNING: This will process 1MB of data and may take several minutes..."
./obj_dir/$(EXECUTABLE)
@echo "Simulation complete!"
# Run quick test
quick: $(EXECUTABLE_QUICK)
@echo "Running SHA256 1MB processor quick test..."
./obj_dir/$(EXECUTABLE_QUICK)
@echo "Quick test complete!"
# Generate expected hash for verification
verify:
@echo "Generating expected SHA256 hash for 1MB verification..."
@python3 -c "import hashlib; data = bytes(range(256)) * 4096; print('Expected SHA256:', hashlib.sha256(data).hexdigest())"
# Quick test with smaller data for verification
test-small:
@echo "Testing with smaller data pattern..."
@python3 -c "import hashlib; data = bytes(range(256)) * 4; print('1KB pattern SHA256:', hashlib.sha256(data).hexdigest())"
# View waveform (requires GTKWave)
wave:
@if [ -f sha256_1mb_waveform.vcd ]; then \
echo "Opening waveform in GTKWave..."; \
gtkwave sha256_1mb_waveform.vcd; \
elif [ -f sha256_1mb_quick_waveform.vcd ]; then \
echo "Opening quick test waveform in GTKWave..."; \
gtkwave sha256_1mb_quick_waveform.vcd; \
else \
echo "No waveform file found. Run 'make quick' or 'make run' first."; \
fi
# Clean build artifacts
clean:
rm -rf obj_dir/
rm -f sha256_1mb_waveform.vcd sha256_1mb_quick_waveform.vcd
@echo "Clean complete!"
# Performance estimation
estimate:
@echo "Performance Estimation for 1MB SHA256 Processing:"
@echo "- Data size: 1MB = 1,048,576 bytes"
@echo "- Number of blocks: 2049 (2048 data + 1 padding)"
@echo "- Cycles per block: ~80 (64 compression + 16 setup)"
@echo "- Estimated total cycles: ~164,000"
@echo "- At 100MHz: ~1.64ms processing time"
@echo "- Estimated throughput: ~640 MB/s"
# Help
help:
@echo "Available targets:"
@echo " all - Build the 1MB simulation (default)"
@echo " run - Build and run the 1MB simulation"
@echo " quick - Build and run quick test (recommended first)"
@echo " verify - Generate expected SHA256 hash for 1MB"
@echo " test-small - Test with 1KB pattern for quick verification"
@echo " estimate - Show performance estimates"
@echo " wave - View waveform in GTKWave"
@echo " clean - Clean build artifacts"
@echo " help - Show this help message"
.PHONY: all run quick verify test-small estimate wave clean help