Skip to content

Commit

Permalink
feat: add an example
Browse files Browse the repository at this point in the history
  • Loading branch information
esynr3z committed Jan 24, 2024
1 parent b6156ff commit e2131da
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Example

Simple example of how to pack and use packed components to build testbench.
3 changes: 3 additions & 0 deletions example/pack_sv_code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# dummy_math_lib

Simple SystemVerilog package without extra dependencies.
4 changes: 4 additions & 0 deletions example/pack_sv_code/dummy_math_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Dummy math library."""
from pip_hdl import PackageMetaInfo

metainfo = PackageMetaInfo("dummy_math_lib")
9 changes: 9 additions & 0 deletions example/pack_sv_code/dummy_math_lib/dummy_math_lib_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dummy_math_lib_pkg;
function automatic bit is_divisible_by_3(int unsigned number);
return (number % 3) == 0;
endfunction

function automatic bit is_divisible_by_5(int unsigned number);
return (number % 5) == 0;
endfunction
endpackage
1 change: 1 addition & 0 deletions example/pack_sv_code/dummy_math_lib/filelist.f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${DUMMY_MATH_LIB_SOURCES_ROOT}/dummy_math_lib_pkg.sv
16 changes: 16 additions & 0 deletions example/pack_sv_code/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "dummy-math-lib"
version = "0.1.0"
description = "Example for pip-hdl: dummy math library"
authors = ["esynr3z <esynr3z@gmail.com>"]
classifiers = [
"Private :: Do not Upload", # Prevent uploading to PyPI
]

[tool.poetry.dependencies]
python = "^3.8"
pip_hdl = "^0.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 3 additions & 0 deletions example/pack_sv_code_with_dependencies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# fizzbuzz_agent_pkg

SystemVerilog package with some agent and single dependency.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Fizz-buzz agent."""
from pip_hdl import PackageMetaInfo

metainfo = PackageMetaInfo("fizzbuzz_agent")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${FIZZBUZZ_AGENT_SOURCES_ROOT}/fizzbuzz_agent_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package hdlp_fizzbuzz_agent_pkg;
import dummy_math_lib_pkg::is_divisible_by_3;
import dummy_math_lib_pkg::is_divisible_by_5;

class fizzbuzz_agent;
function run_sequence(int unsigned limit);
for (int i = 0; i < limit; i++) begin
string msg;

if (dummy_math_lib_pkg::is_divisible_by_5(i) && dummy_math_lib_pkg::is_divisible_by_3(i)) begin
msg = "FizzBuzz";
end else if (dummy_math_lib_pkg::is_divisible_by_3(i)) begin
msg = "Fizz";
end else if (dummy_math_lib_pkg::is_divisible_by_5(i)) begin
msg = "Buzz";
end else begin
msg = $sformatf("%0d", i);
end

$display(msg);
end
endfunction : run_sequence
endclass : fizzbuzz_agent
endpackage
17 changes: 17 additions & 0 deletions example/pack_sv_code_with_dependencies/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "fizzbuzz-agent"
version = "0.1.0"
description = "Example for pip-hdl: agent to create fizz-buzz sequence"
authors = ["esynr3z <esynr3z@gmail.com>"]
classifiers = [
"Private :: Do not Upload", # Prevent uploading to PyPI
]

[tool.poetry.dependencies]
python = "^3.8"
pip_hdl = "^0.1"
dummy_math_lib = "^0.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
1 change: 1 addition & 0 deletions example/use_packed_sv_code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# FIXME
3 changes: 3 additions & 0 deletions example/use_packed_sv_code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Testbench

Simple testbench that uses an agent, described in `requirements.txt`
1 change: 1 addition & 0 deletions example/use_packed_sv_code/requrements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fizzbuzz_agent==0.1.0
10 changes: 10 additions & 0 deletions example/use_packed_sv_code/tb.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module tb;
import fizzbuzz_agent_pkg::fizzbuzz_agent;

initial begin
fizzbuzz_agent agent = new();

agent.run_sequence(100);
$finish();
end
endmodule

0 comments on commit e2131da

Please sign in to comment.