Skip to content

Commit

Permalink
[otbn] rename OTBN assembler Python script
Browse files Browse the repository at this point in the history
In order to be bazelified, which is required in order to build the mask
ROM with bazel, all Python scripts must end in a ".py" extension.

Signed-off-by: Timothy Trippel <ttrippel@google.com>
  • Loading branch information
timothytrippel authored and mcy committed Apr 21, 2022
1 parent ffc9e54 commit efe736b
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 283 deletions.
6 changes: 3 additions & 3 deletions doc/ug/otbn_sw.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ For specific formatting and secure coding guidelines, see the [OTBN style guide]

### Assembler

The OTBN assembler is called `otbn-as` and can be found at `hw/ip/otbn/util/otbn-as`.
The OTBN assembler is called `otbn_as.py` and can be found at `hw/ip/otbn/util/otbn_as.py`.
This has the same command line interface as `riscv32-unknown-elf-as` (indeed, it's a wrapper around that program).
The only difference in default flags is that `otbn-as` passes `-mno-relax`, telling the assembler not to request linker relaxation.
The only difference in default flags is that `otbn_as.py` passes `-mno-relax`, telling the assembler not to request linker relaxation.
This is needed because one of these relaxations generates GP-relative loads, which assume `x3` is treated as a global pointer (not true for OTBN code).

To assemble some code in `foo.s` to an ELF object called `foo.o`, run:
```shell
hw/ip/otbn/util/otbn-as -o foo.o foo.s
hw/ip/otbn/util/otbn_as.py -o foo.o foo.s
```

### Linker
Expand Down
6 changes: 3 additions & 3 deletions hw/ip/otbn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ toolchain](https://docs.opentitan.org/doc/ug/install_instructions/#software-deve
For more details about the toolchain, see the [user
guide](https://docs.opentitan.org/doc/ug/otbn_sw)).

`otbn-as` and `otbn_ld.py` can be used to build .elf files for use with
`otbn_as.py` and `otbn_ld.py` can be used to build .elf files for use with
simulations. They work work similarly to binutils programs they wrap.

```
hw/ip/otbn/util/otbn-as -o prog_bin/prog.o prog.s
hw/ip/otbn/util/otbn_as.py -o prog_bin/prog.o prog.s
hw/ip/otbn/util/otbn_ld.py -o prog_bin/prog.elf prog_bin/prog.o
```

Expand All @@ -50,7 +50,7 @@ users include:
### Run the Python simulator
The quickest way to run an OTBN-only program is to use the Python simulator.
First, generate a `.elf.` file either using the usual build process or by
manually running `otbn-as` and `otbn_ld.py` as shown above. Then, from `$REPO_TOP`:
manually running `otbn_as.py` and `otbn_ld.py` as shown above. Then, from `$REPO_TOP`:
```console
$ hw/ip/otbn/dv/otbnsim/standalone.py -t path/to/prog.elf
```
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/doc/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ OTBN comes with a toolchain consisting of an assembler, a linker, and helper too
The toolchain wraps a RV32 GCC toolchain and supports many of its features.

The following tools are available:
* `otbn-as`: The OTBN assembler.
* `otbn_as.py`: The OTBN assembler.
* `otbn_ld.py`: The OTBN linker.
* `otbn-objdump`: objdump for OTBN.

Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/dv/otbnsim/test/simple/insns/addi.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Simple tests of the addi instruction
This test also uses a comment syntax that broke the parser in a
previous version of otbn-as: if editing it, keep the block
previous version of otbn_as.py: if editing it, keep the block
comments on the same lines as instructions to keep that test in
place.
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/dv/otbnsim/test/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def asm_and_link_one_file(asm_path: str, work_dir: py.path.local) -> str:
Returns the path to the resulting ELF
'''
otbn_as = os.path.join(UTIL_DIR, 'otbn-as')
otbn_as = os.path.join(UTIL_DIR, 'otbn_as.py')
otbn_ld = os.path.join(UTIL_DIR, 'otbn_ld.py')
obj_path = os.path.join(work_dir, 'tst.o')
elf_path = os.path.join(work_dir, 'tst')
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/dv/rig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ are an assembly listing and a linker script, respectively.
To assemble and link, use commands like:
```
hw/ip/otbn/util/otbn-as -o foo.o foo.s
hw/ip/otbn/util/otbn_as.py -o foo.o foo.s
hw/ip/otbn/util/otbn_ld.py -o foo.elf -T foo.ld foo.o
```
This is automated in the `gen-binaries.py` wrapper described above.
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/dv/smoke/run_smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mkdir -p $SMOKE_BIN_DIR

OTBN_UTIL=$REPO_TOP/hw/ip/otbn/util

$OTBN_UTIL/otbn-as -o $SMOKE_BIN_DIR/smoke_test.o $SMOKE_SRC_DIR/smoke_test.s || \
$OTBN_UTIL/otbn_as.py -o $SMOKE_BIN_DIR/smoke_test.o $SMOKE_SRC_DIR/smoke_test.s || \
fail "Failed to assemble smoke_test.s"
$OTBN_UTIL/otbn_ld.py -o $SMOKE_BIN_DIR/smoke.elf $SMOKE_BIN_DIR/smoke_test.o || \
fail "Failed to link smoke_test.o"
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/otbn/util/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $(build-dir) $(lint-build-dir):
mkdir -p $@

pylibs := $(wildcard shared/*.py docs/*.py)
pyscripts := yaml_to_doc.py otbn-as otbn_ld.py otbn-objdump
pyscripts := yaml_to_doc.py otbn_as.py otbn_ld.py otbn-objdump

lint-stamps := $(foreach s,$(pyscripts),$(lint-build-dir)/$(s).stamp)
$(lint-build-dir)/%.stamp: % $(pylibs) | $(lint-build-dir)
Expand Down
Loading

0 comments on commit efe736b

Please sign in to comment.