-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
145 lines (127 loc) · 5.09 KB
/
Makefile
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#RISCV_PREFIX ?= riscv32-unknown-elf-
RISCV_PREFIX ?= riscv32-zephyr-elf-
CC=$(RISCV_PREFIX)gcc
AS=$(RISCV_PREFIX)as
OBJCOPY=$(RISCV_PREFIX)objcopy
all: run_compliance
synthesis: board_top.json
run_compliance: tb_out/cpu_run
cd riscv-compliance && make clean && make
COMPLIANCE_TEST=I-ENDIANESS-01
#COMPLIANCE_TEST=I-ADD-01
#COMPLIANCE_TEST=I-ADDI-01
#COMPLIANCE_TEST=I-ANDI-01
#COMPLIANCE_TEST=I-AUIPC-01
#COMPLIANCE_TEST=I-BEQ-01
#COMPLIANCE_TEST=I-BGE-01
#COMPLIANCE_TEST=I-BGEU-01
#COMPLIANCE_TEST=I-BLT-01
#COMPLIANCE_TEST=I-BLTU-01
#COMPLIANCE_TEST=I-BNE-01
#COMPLIANCE_TEST=I-CSRRC-01
#COMPLIANCE_TEST=I-CSRRCI-01
#COMPLIANCE_TEST=I-CSRRS-01
#COMPLIANCE_TEST=I-CSRRSI-01
#COMPLIANCE_TEST=I-CSRRW-01
#COMPLIANCE_TEST=I-CSRRWI-01
#COMPLIANCE_TEST=I-DELAY_SLOTS-01
#COMPLIANCE_TEST=I-EBREAK-01
#COMPLIANCE_TEST=I-ECALL-01
#COMPLIANCE_TEST=I-FENCE.I-01# Fails
#COMPLIANCE_TEST=I-IO
#COMPLIANCE_TEST=I-JAL-01
#COMPLIANCE_TEST=I-JALR-01
#COMPLIANCE_TEST=I-LB-01
#COMPLIANCE_TEST=I-LBU-01
#COMPLIANCE_TEST=I-LH-01
#COMPLIANCE_TEST=I-LHU-01
#COMPLIANCE_TEST=I-LW-01
#COMPLIANCE_TEST=I-MISALIGN_JMP-01
#COMPLIANCE_TEST=I-MISALIGN_LDST-01
#COMPLIANCE_TEST=I-NOP-01
#COMPLIANCE_TEST=I-OR-01
#COMPLIANCE_TEST=I-ORI-01
#COMPLIANCE_TEST=I-RF_size-01
#COMPLIANCE_TEST=I-RF_width-01
#COMPLIANCE_TEST=I-RF_x0-01
#COMPLIANCE_TEST=I-SB-01
#COMPLIANCE_TEST=I-SH-01
#COMPLIANCE_TEST=I-SLL-01
#COMPLIANCE_TEST=I-SLLI-01
#COMPLIANCE_TEST=I-SLT-01
#COMPLIANCE_TEST=I-SLTI-01
#COMPLIANCE_TEST=I-SLTIU-01
#COMPLIANCE_TEST=I-SLTU-01
#COMPLIANCE_TEST=I-SRA-01
#COMPLIANCE_TEST=I-SRAI-01
#COMPLIANCE_TEST=I-SRL-01
#COMPLIANCE_TEST=I-SRLI-01
#COMPLIANCE_TEST=I-SUB-01
#COMPLIANCE_TEST=I-SW-01
#COMPLIANCE_TEST=I-XOR-01
#COMPLIANCE_TEST=I-XORI-01
run_compliance_quick: tb_out/cpu_run compile_compliance_quick
./tb_out/cpu_run tb_out/$(COMPLIANCE_TEST).elf | tee tb_out/run.out
grep '(DD)' tb_out/run.out | cut -d' ' -f 2 > tb_out/result.log
diff tb_out/result.log riscv-compliance/riscv-test-suite/rv32i/references/$(COMPLIANCE_TEST).reference_output
compile_compliance_quick:
$(CC) -march=rv32i -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Iriscv-compliance/riscv-test-env/ -Iriscv-compliance/riscv-test-env/msc/ -Iriscv-compliance/riscv-target/msc-02/ -Triscv-compliance/riscv-test-env/msc/link.ld riscv-compliance/riscv-test-suite/rv32i/src/$(COMPLIANCE_TEST).S -E > tb_out/$(COMPLIANCE_TEST)-expand.S
$(CC) -Wl,--build-id=none -march=rv32i -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Iriscv-compliance/riscv-test-env/ -Iriscv-compliance/riscv-test-env/msc/ -Iriscv-compliance/riscv-target/msc-02/ -Triscv-compliance/riscv-test-env/msc/link.ld riscv-compliance/riscv-test-suite/rv32i/src/$(COMPLIANCE_TEST).S -o tb_out/$(COMPLIANCE_TEST).elf
$(OBJCOPY) -O binary tb_out/$(COMPLIANCE_TEST).elf tb_out/$(COMPLIANCE_TEST).elf.bin
compile_regfile_tb: regfile.v regfile_sc.cpp
# echo "(MM) Compiling Regfile testbench"
verilator -Wall --sc $^ --exe -o ../tb_out/regfile_tb
make -C obj_dir -f Vregfile.mk
run_regfile_tb: compile_regfile_tb
./tb_out/regfile_tb
compile_mmu_tb: mmu.v mmu_sc.cpp SB_SPRAM256KA.v
echo "(MM) Compiling MMU testbench"
verilator -Wall --sc $^ --exe -o ../tb_out/mmu_tb
make -C obj_dir -f Vmmu.mk
run_mmu_tb: compile_mmu_tb
./tb_out/mmu_tb
tb_out/%.bin: test/%.S
$(AS) -march=rv32i $^ -o $(@:.bin=.elf)
$(OBJCOPY) -O binary $(@:.bin=.elf) $@
# riscv32-unknown-elf-as $^ -o $(@:.bin=.elf)
# riscv32-unknown-elf-objcopy -O binary $(@:.bin=.elf) $@
TEST_PROGRAMS=
TEST_PROGRAMS+=tb_out/00-nop.bin
TEST_PROGRAMS+=tb_out/01-opimm.bin
TEST_PROGRAMS+=tb_out/02-op.bin
TEST_PROGRAMS+=tb_out/03-br.bin
TEST_PROGRAMS+=tb_out/04-lui.bin
TEST_PROGRAMS+=tb_out/05-jalr.bin
TEST_PROGRAMS+=tb_out/06-csrr.bin
TEST_PROGRAMS+=tb_out/07-csrwi.bin
TEST_PROGRAMS+=tb_out/08-csrw.bin
TEST_PROGRAMS+=tb_out/09-csrsi.bin
TEST_PROGRAMS+=tb_out/10-csrs.bin
TEST_PROGRAMS+=tb_out/11-csrci.bin
TEST_PROGRAMS+=tb_out/12-csrc.bin
TEST_PROGRAMS+=tb_out/13-csr.bin
TEST_PROGRAMS+=tb_out/14-mem.bin
TEST_PROGRAMS+=tb_out/15-exception.bin
compile_cpu_top_tb: cpu_top.v cpu_top_sc.cpp core_top.v EBRAM_ROM.v mmu.v regfile.v core/csr_ehu.v core/instruction_decoder.v core.v io_port.v
echo "(MM) Compiling CPU Top testbench"
mkdir -p tb_out
verilator -Icore -Wall --top-module cpu_top --sc $^ --exe -o ../tb_out/cpu_top_tb
make -C obj_dir -f Vcpu_top.mk
tb_out/cpu_run: cpu_run_sc.cpp cpu_top.v core_top.v mmu.v regfile.v core/csr_ehu.v core/instruction_decoder.v core.v timer.v bram_dpstrobe.v
echo "(MM) Compiling CPU Simulator"
mkdir -p tb_out
verilator -Icore -Wall --sc $^ --top-module cpu_top --exe -o ../tb_out/cpu_run
make -C obj_dir -f Vcpu_top.mk
run_cpu_top_tb: compile_cpu_top_tb $(TEST_PROGRAMS)
./tb_out/cpu_top_tb
board_top.json: SPRAM_16Kx16_syn.v EBRAM_ROM.v core.v core_top.v cpu_top.v mmu.v regfile.v timer.v io_port.v core/csr_ehu.v core/instruction_decoder.v board_top.v board_top.ys
yosys $^ | tee synthesis.log
compliance_clean:
cd riscv-compliance && make clean && cd ..
clean:
rm -rf tmp tb_out/* obj_dir
rm -f board_top.json
rm -f board_top.asc
rm -f board_top.blif
rm -f synthesis.log
find . -name "*~" -exec rm -f {} \;