Display a single digit

This commit is contained in:
unlockable
2024-07-11 15:21:49 +08:00
parent bd64dcf361
commit 79cbd5b0a4
5 changed files with 39 additions and 3 deletions

6
13display_digit.asm Normal file
View File

@@ -0,0 +1,6 @@
lui $s0, 0x4000
addi $s0, $s0, 0x10
addi $s1, $zero, 0x1ff
sw $s1, 0($s0)
end:
j end

5
13display_digit.txt Normal file
View File

@@ -0,0 +1,5 @@
20'd0: instruction <= 32'h3c104000;
20'd1: instruction <= 32'h22100010;
20'd2: instruction <= 32'h201101ff;
20'd3: instruction <= 32'hae110000;
20'd4: instruction <= 32'h08000004;

5
13display_digit_mars.txt Normal file
View File

@@ -0,0 +1,5 @@
3c104000
22100010
201101ff
ae110000
08000004

18
bcd_digits.md Normal file
View File

@@ -0,0 +1,18 @@
| Digit | Binary | Hex |
| :---: | :-------: | :----: |
| 0 | `0111111` | `0x3f` |
| 1 | `0000110` | `0x6` |
| 2 | `1011011` | `0x5b` |
| 3 | `1001111` | `0x4f` |
| 4 | `1100110` | `0x66` |
| 5 | `1101101` | `0x6d` |
| 6 | `1111101` | `0x7d` |
| 7 | `0000111` | `0x7` |
| 8 | `1111111` | `0x7f` |
| 9 | `1101111` | `0x6f` |
| A | `1110111` | `0x77` |
| B | `1111100` | `0x7c` |
| C | `1011000` | `0x58` |
| D | `1011110` | `0x5e` |
| E | `1111001` | `0x79` |
| F | `1110001` | `0x71` |

View File

@@ -1,5 +1,7 @@
file_name = input("File name: ")
with open(file_name) as fl:
with open(file_name + "_mars.txt") as fl:
file_content = fl.readlines()
for idx, inst in enumerate(file_content):
print("20'd%d: instruction <= 32'h%s;" % (idx, inst.strip()))
with open(file_name + ".txt", "w") as fl:
for idx, inst in enumerate(file_content):
# print("20'd%d: instruction <= 32'h%s;" % (idx, inst.strip()))
fl.write("20'd%d: instruction <= 32'h%s;\n" % (idx, inst.strip()))