diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-07-09 13:41:09 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2021-07-09 14:23:33 +0000 |
| commit | a9192c63df8073bf3f7134b8ef8e3768e6e6f078 (patch) | |
| tree | e9a2a4c870e685d0c5950caf979decb260528b2a | |
| parent | update examples (diff) | |
| download | subv-a9192c63df8073bf3f7134b8ef8e3768e6e6f078.tar.gz subv-a9192c63df8073bf3f7134b8ef8e3768e6e6f078.zip | |
remove 0x prefix
| -rw-r--r-- | examples/ask_name.subv | 2 | ||||
| -rw-r--r-- | examples/hello_world.subv | 2 | ||||
| -rw-r--r-- | subv.py | 10 | ||||
| -rwxr-xr-x | survey.py | 2 | ||||
| -rwxr-xr-x | validate.py | 14 |
5 files changed, 13 insertions, 17 deletions
diff --git a/examples/ask_name.subv b/examples/ask_name.subv index f54213f..f411bfc 100644 --- a/examples/ask_name.subv +++ b/examples/ask_name.subv @@ -114,7 +114,7 @@ print:break: read: # read a C-string into a0 # load 0x10000000 (UART0) into t0 - 37/lui 5/rd/t0 0x10000/imm20 + 37/lui 5/rd/t0 10000/imm20 # load 0x0a (\n) into t1 13/opi 6/rd/t1 0/subop/add 0/rs/x0 0a/imm12 diff --git a/examples/hello_world.subv b/examples/hello_world.subv index 84ad0b2..d25aa83 100644 --- a/examples/hello_world.subv +++ b/examples/hello_world.subv @@ -17,7 +17,7 @@ loop: print: # load 0x10000000 (UART0) into t0 - 37/lui 5/rd/t0 0x10000/imm20 + 37/lui 5/rd/t0 10000/imm20 print:loop: # load unsigned byte at a0 03/load 6/rd/t1 4/width/bu a/rs/a0 0/imm12 @@ -2,7 +2,7 @@ import re import bits white = re.compile(r"[ \t\.\n]+") -hex = re.compile(r"^\-?(0x)?[0-9a-f]+$") +hex = re.compile(r"^\-?[0-9a-f]+$") num = re.compile(r"^\d+$") ref_re = re.compile(r"^([^\[+-]+)(?:([+-]\d+))?$") immediate_re = re.compile(r"^(imm|off|csr)(\d+)(hi|lo)?$") @@ -16,23 +16,19 @@ def parse_part(part): (0,) >>> parse_part('00') (0,) - >>> parse_part('0x00') - (0,) >>> parse_part('12') (18,) - >>> parse_part('0x12') - (18,) >>> parse_part('-12') (-18,) - >>> parse_part('-0x12') - (-18,) >>> parse_part('00/with/tag') (0, 'with', 'tag') >>> parse_part('-12/and/tag') (-18, 'and', 'tag') + >>> parse_part('cafe/and/tag') + (51966, 'and', 'tag') >>> parse_part('label/tag*') ('label', 'tag*') @@ -61,7 +61,7 @@ Resolves label references and substitutes them with literal values. ... # repeatedly print "Hi\\\\n" ... main: ... # load 0x10010000 (UART0) into t0 -... 37/u 5/rd/t0 0x10010/imm20 +... 37/u 5/rd/t0 10010/imm20 ... # store 0x48 (H) in UART0+0 ... 13/i 0/subop/add 6/rd/t1 0/rs/x0 48/imm12 ... 23/s 2/subop/word 5/rs/t0 6/rs/t1 0/off12 diff --git a/validate.py b/validate.py index bdf8f95..30cef46 100755 --- a/validate.py +++ b/validate.py @@ -10,7 +10,7 @@ no missing arguments. ... == code 0x80000000 ... main: ... # load 0x10010000 (UART0) into t0 -... 37/lui 5/rd/t0 0x10010/imm20 +... 37/lui 5/rd/t0 10010/imm20 ... # store 0x48 (H) in UART0+0 ... 13/opi 6/rd/t1 0/subop/add 0/rs/x0 48/imm12 ... 23/store 2/width/word 5/rs/t0 0/off12 6/rs/t1 @@ -347,20 +347,20 @@ def validate_jalr(inputs): ] -def validate_csr(inputs): +def validate_system(inputs): """ validate system operations. - >>> validate_csr(subv.parse('73/system 0/dest/x0 1/subop/csrrw 5/rs/t0 afe/csr12')['instr']) + >>> validate_system(subv.parse('73/system 0/dest/x0 1/subop/csrrw 5/rs/t0 afe/csr12')['instr']) [(115, 'i'), (0, 'rd'), (1, 'funct3'), (5, 'rs'), (2814, 'imm12')] - >>> validate_csr(subv.parse('73/system 0/dest/x0 5/subop/csrrwi 7/imm5 afe/csr12')['instr']) + >>> validate_system(subv.parse('73/system 0/dest/x0 5/subop/csrrwi 7/imm5 afe/csr12')['instr']) [(115, 'i'), (0, 'rd'), (5, 'funct3'), (7, 'imm5'), (2814, 'imm12')] - >>> validate_csr(subv.parse('73/system 0/dest/x0 1/subop/csrrw 7/imm5 afe/csr12')['instr']) + >>> validate_system(subv.parse('73/system 0/dest/x0 1/subop/csrrw 7/imm5 afe/csr12')['instr']) Traceback (most recent call last): ... ValueError: Expected a register with label rs/rs1/src - >>> validate_csr(subv.parse('73/system 0/dest/x0 5/subop/csrrwi 5/rs/t0 afe/csr12')['instr']) + >>> validate_system(subv.parse('73/system 0/dest/x0 5/subop/csrrwi 5/rs/t0 afe/csr12')['instr']) Traceback (most recent call last): ... ValueError: Expected an immediate with size 5 @@ -480,7 +480,7 @@ instr_map = { "opr": (validate_opr, 0x33), "opi": (validate_i, 0x13), "jalr": (validate_jalr, 0x67), - "system": (validate_csr, 0x73), + "system": (validate_system, 0x73), "load": (validate_load, 0x03), "store": (validate_store, 0x23), "branch": (validate_branch, 0x63), |
