Skip to content

Commit ca4f1b7

Browse files
Merge pull request #7 from scopeInfinity/verilog
Execution in Verilog
2 parents da922b7 + d44798d commit ca4f1b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2198
-1600
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ SRC_DIR=.
22
BUILD_DIR=build
33
OUTPUT_DIR=output
44

5-
.PHONY: clean test all run_ping_pong all_programs_binary all_programs_resolved
5+
.PHONY: clean test all run_verilog_io run_ping_pong all_programs_binary all_programs_resolved output_rom_binaries
66

7-
all: all_programs_binary all_programs_resolved
7+
all: all_programs_binary all_programs_resolved verilog_modules
88

99
clean:
1010
rm -rf $(BUILD_DIR)
@@ -19,6 +19,8 @@ test: pytest test_verilog_modules
1919

2020
all_programs_binary: $(patsubst programs/%.asm, $(OUTPUT_DIR)/programs/%.bin, $(shell find programs/ -name '*.asm'))
2121

22+
output_rom_binaries: $(OUTPUT_DIR)/programs/boot_sequence.bin $(OUTPUT_DIR)/programs/ping_pong.bin
23+
2224
$(OUTPUT_DIR)/programs/%.bin: programs/%.asm
2325
mkdir -p $(dir $@)
2426
python3 -m planner asm -b $^ > $@
@@ -31,3 +33,6 @@ $(OUTPUT_DIR)/programs/%_resolved.asm: programs/%.asm
3133

3234
run_ping_pong:
3335
python3 -m planner compile_and_execute ping_pong
36+
37+
run_verilog_io:
38+
python3 -m planner verilog_io

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ The eventual goal(?) is to build a general-purpose processor integrated with sim
88
## Sample Programs
99

1010
* Ping Pong
11+
* 16x8 LED display with W/S/Up/Down keyboard controller
1112
* Source: [ping_pong.asm](programs/ping_pong.asm)
1213
* Generate resolved assembly: `python3 -m planner asm -r programs/ping_pong.asm` [[example](output/programs/ping_pong_resolved.asm)]
1314
* Generate binary: `python3 -m planner asm -b programs/ping_pong.asm` [[example](output/programs/ping_pong.bin)]
14-
* Run on emulator: `python3 -m planner compile_and_execute ping_pong`
15-
* 16x8 LED display with W/S/Up/Down keyboard controller
15+
* Run on python emulator: `python3 -m planner compile_and_execute ping_pong`
1616
* ![image](https://github.com/user-attachments/assets/9fa2f68f-73ae-465c-a29c-cc92b0dc421a)
17+
* Run on verilog emulator: `make verilog_simulate`
1718

1819
## Design
1920

emulator/Makefile.mk

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
BUILD_EMULATOR = $(BUILD_DIR)/emulator
22
SRC_EMULATOR = $(SRC_DIR)/emulator
33

4-
.PHONY: test_verilog_modules
4+
.PHONY: verilog_modules test_verilog_modules verilog_data_prerequisites verilog_simulate
55

6-
$(BUILD_EMULATOR)/%_test: $(SRC_EMULATOR)/%_test.v
6+
$(BUILD_EMULATOR)/%_test: $(SRC_EMULATOR)/%_test.v $(SRC_EMULATOR)/%.v
77
mkdir -p $(dir $@)
8-
iverilog -o $@ $^
8+
iverilog -o $@ $<
9+
10+
verilog_modules: $(BUILD_EMULATOR)/executable_chipset $(patsubst $(SRC_EMULATOR)/%_test.v, $(BUILD_EMULATOR)/%_test, $(shell find $(SRC_EMULATOR) -name '*_test.v'))
11+
mkdir -p $(BUILD_EMULATOR)/io
12+
13+
verilog_data_prerequisites: output_rom_binaries
914

1015
test_verilog_modules: $(patsubst $(SRC_EMULATOR)/%_test.v, $(BUILD_EMULATOR)/%_test, $(shell find $(SRC_EMULATOR) -name '*_test.v'))
16+
$(MAKE) verilog_data_prerequisites
1117
$(foreach test_name, $^, echo "Executing $(test_name)" && ./$(test_name))
18+
19+
$(BUILD_EMULATOR)/executable_chipset: $(SRC_EMULATOR)/executable_chipset.v
20+
$(MAKE) verilog_data_prerequisites
21+
mkdir -p $(dir $@)
22+
iverilog -o $@ $^
23+
24+
verilog_simulate: $(BUILD_EMULATOR)/executable_chipset
25+
./$^ | $(MAKE) run_verilog_io

0 commit comments

Comments
 (0)