Skip to content

Commit

Permalink
fix: rework the example
Browse files Browse the repository at this point in the history
  • Loading branch information
esynr3z committed Jan 25, 2024
1 parent e2131da commit d1b7621
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 7 deletions.
30 changes: 29 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# Example

Simple example of how to pack and use packed components to build testbench.
Simple example of how to pack and use packed components to build a testbench.

- `dummy_math_lib` - root directory for `dummy_math_lib` package
- `fizzbuzz_agent` - root directory for `fizzbuzz_agent` package, which depends on `dummy_math_lib`
- `testbench` - directory with testbench using `fizzbuzz_agent`

Normally, to run testbench you simply need to install all dependencies using

```bash
pip install -r requirements.txt
```

However, mentioned packages are protected from publishing to PyPi with the special [trove classifier](https://pypi.org/classifiers/), but you still can pack and install them locally.

Make sure that you have [poetry](https://python-poetry.org/) installed:

```bash
pip install poetry
```

Then you can build [.whl](https://peps.python.org/pep-0427/) and install it to your system:

```bash
cd <package_root>
poetry build
pip install dist/<package>.whl
```

After all packages are installed try to run the testbench in [Verilator](https://www.veripool.org/verilator/) using `make`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hdlp_fizzbuzz_agent_pkg;
package fizzbuzz_agent_pkg;
import dummy_math_lib_pkg::is_divisible_by_3;
import dummy_math_lib_pkg::is_divisible_by_5;

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions example/testbench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj_dir
33 changes: 33 additions & 0 deletions example/testbench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: all clean build sim

BIN := Vtop
NPROC := 4

# Export all variables needed for filelists
$(foreach var, $(shell pip-hdl inspect requirements.txt all_sources_vars), $(eval export $(var)))

BUILD_OPTS = \
--timescale 1ns/1ps \
--cc \
--binary \
--timing \
-O3 \
-j $(NPROC) \
-o $(BIN)

SOURCES = \
$(shell pip-hdl inspect requirements.txt all_filelists_as_args) \
tb.sv

all: clean build sim

clean:
rm -rf obj_dir

build:
# This export is an alternative to a global foreach loop export above
#export $(shell pip-hdl inspect requirements.txt all_sources_vars);\
verilator $(BUILD_OPTS) $(SOURCES)

sim:
./obj_dir/$(BIN)
7 changes: 7 additions & 0 deletions example/testbench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Testbench

Simple testbench that uses an agent, described in `requirements.txt`

Python packages `pip-hdl`, `fizzbuzz-agent` and `dummy-math-lib` has to be installed.

Run `make` to build and simulate the example in Verilator.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module tb;
initial begin
fizzbuzz_agent agent = new();

agent.run_sequence(100);
void'(agent.run_sequence(100));
$finish();
end
endmodule
1 change: 0 additions & 1 deletion example/use_packed_sv_code/Makefile

This file was deleted.

3 changes: 0 additions & 3 deletions example/use_packed_sv_code/README.md

This file was deleted.

0 comments on commit d1b7621

Please sign in to comment.