aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_fpga/gen_data_strings_v.py
diff options
context:
space:
mode:
Diffstat (limited to 'atk16_fpga/gen_data_strings_v.py')
-rwxr-xr-xatk16_fpga/gen_data_strings_v.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/atk16_fpga/gen_data_strings_v.py b/atk16_fpga/gen_data_strings_v.py
new file mode 100755
index 0000000..afb374e
--- /dev/null
+++ b/atk16_fpga/gen_data_strings_v.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+def gen(name, message):
+ for line in message.split('\n'):
+ print(f'// {line}')
+
+ print(f"`define LEN_{name} {len(message)}")
+ print(f"`define STR_{name} \\")
+ print(f" reg [7:0] str_{name} [0:`LEN_{name}-1]; \\")
+ print(f" initial begin \\")
+ for i, c in enumerate(message):
+ print(f" str_{name}[{i}] = 8'd{ord(c)}; \\")
+
+ print(f" end")
+ print("")
+
+gen("welcome", "Welcome to the ATK16 serial programmer. Press 'h' for help.\n")
+gen("help",
+ "Help:\n" +
+ " h - help\n" +
+ " p - program\n"
+)
+gen("program_ready",
+ "Ready to receive program data. Reset device after transmission.\n"
+)