Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci update #37

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ on:
jobs:
tests:
name: Python ${{matrix.python-version}} | ${{matrix.sim}}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
SIM: ${{matrix.sim}}
strategy:
fail-fast: false
matrix:
include:
- sim: verilator
sim-version: v4.106
sim-version: v5.020
python-version: '3.10'
steps:
- uses: actions/checkout@v3
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Install Verilator
if: matrix.sim == 'verilator'
run: |
sudo apt install -y --no-install-recommends make g++ perl python3 autoconf flex bison libfl2 libfl-dev zlibc zlib1g zlib1g-dev
sudo apt install -y --no-install-recommends make g++ help2man perl python3 autoconf flex bison libfl2 libfl-dev zlib1g zlib1g-dev
git clone https://github.com/verilator/verilator.git -b ${{matrix.sim-version}}
cd verilator
autoconf
Expand Down
3 changes: 1 addition & 2 deletions tjmonopix2/tests/test_hardware/drivers/Drive320Clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ def __init__(self, entity):
BusDriver.__init__(self, entity, "", entity.CLK320)

async def run(self):

cocotb.fork(Clock(self.clock, 3120).start())
cocotb.start_soon(Clock(self.clock, 3120).start())
Binary file modified tjmonopix2/tests/test_hardware/hdl/libmonopix2.a
Binary file not shown.
58 changes: 29 additions & 29 deletions tjmonopix2/tests/test_hardware/hdl/monopix2.sv
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
// See instructions in your simulator for how to use DPI libraries

module monopix2 (
input logic LVDS_CMD
, input logic LVDS_CMD_CLK
input logic LVDS_CMD_CLK
, input logic LVDS_SER_CLK
, output logic LVDS_CHSYNC_CLK_OUT
, input logic RESETB_EXT
, input logic LVDS_CMD
, input logic LVDS_PULSE_EXT
, output logic LVDS_DATA_OUT
, output logic LVDS_HITOR_OUT
, output logic LVDS_CHSYNC_LOCKED_OUT
, output logic LVDS_CHSYNC_CLK_OUT
, input logic RESETB_EXT
, input logic [262143:0] ANALOG_HIT
);

Expand All @@ -23,20 +23,20 @@ module monopix2 (
// Checks to make sure the .sv wrapper and library agree
import "DPI-C" function void monopix2_protectlib_check_hash(int protectlib_hash__V);

// Creates an instance of the secret module at initial-time
// Creates an instance of the library module at initial-time
// (one for each instance in the user's design) also evaluates
// the secret module's initial process
// the library module's initial process
import "DPI-C" function chandle monopix2_protectlib_create(string scope__V);

// Updates all non-clock inputs and retrieves the results
import "DPI-C" function longint monopix2_protectlib_combo_update (
chandle handle__V
, output logic LVDS_CHSYNC_CLK_OUT
, input logic LVDS_CMD
, input logic LVDS_PULSE_EXT
, output logic LVDS_DATA_OUT
, output logic LVDS_HITOR_OUT
, output logic LVDS_CHSYNC_LOCKED_OUT
, output logic LVDS_CHSYNC_CLK_OUT
, input logic [262143:0] ANALOG_HIT
);

Expand All @@ -45,11 +45,11 @@ module monopix2 (
chandle handle__V
, input logic LVDS_CMD_CLK
, input logic LVDS_SER_CLK
, output logic LVDS_CHSYNC_CLK_OUT
, input logic RESETB_EXT
, output logic LVDS_DATA_OUT
, output logic LVDS_HITOR_OUT
, output logic LVDS_CHSYNC_LOCKED_OUT
, output logic LVDS_CHSYNC_CLK_OUT
, input logic RESETB_EXT
);

// Need to convince some simulators that the input to the module
Expand All @@ -61,46 +61,45 @@ module monopix2 (
, input logic [262143:0] ANALOG_HIT
);

// Evaluates the secret module's final process
// Evaluates the library module's final process
import "DPI-C" function void monopix2_protectlib_final(chandle handle__V);

// verilator tracing_off
chandle handle__V;

time last_combo_seqnum__V;
time last_seq_seqnum__V;

logic LVDS_CHSYNC_CLK_OUT_combo__V;
logic LVDS_DATA_OUT_combo__V;
logic LVDS_HITOR_OUT_combo__V;
logic LVDS_CHSYNC_LOCKED_OUT_combo__V;
logic LVDS_CHSYNC_CLK_OUT_combo__V;
logic LVDS_CHSYNC_CLK_OUT_seq__V;
logic LVDS_DATA_OUT_seq__V;
logic LVDS_HITOR_OUT_seq__V;
logic LVDS_CHSYNC_LOCKED_OUT_seq__V;
logic LVDS_CHSYNC_CLK_OUT_seq__V;
logic LVDS_CHSYNC_CLK_OUT_tmp__V;
logic LVDS_DATA_OUT_tmp__V;
logic LVDS_HITOR_OUT_tmp__V;
logic LVDS_CHSYNC_LOCKED_OUT_tmp__V;
logic LVDS_CHSYNC_CLK_OUT_tmp__V;

time last_combo_seqnum__V;
time last_seq_seqnum__V;

// Hash value to make sure this file and the corresponding
// library agree
localparam int protectlib_hash__V = 32'd1563611712;
localparam int protectlib_hash__V = 32'd2954403249;

initial begin
monopix2_protectlib_check_hash(protectlib_hash__V);
handle__V = monopix2_protectlib_create($sformatf("%m"));
end

// Combinatorialy evaluate changes to inputs
always @(*) begin
always @* begin
last_combo_seqnum__V = monopix2_protectlib_combo_update(
handle__V
, LVDS_CHSYNC_CLK_OUT_combo__V
, LVDS_CMD
, LVDS_PULSE_EXT
, LVDS_DATA_OUT_combo__V
, LVDS_HITOR_OUT_combo__V
, LVDS_CHSYNC_LOCKED_OUT_combo__V
, LVDS_CHSYNC_CLK_OUT_combo__V
, ANALOG_HIT
);
end
Expand All @@ -117,30 +116,31 @@ module monopix2 (
handle__V
, LVDS_CMD_CLK
, LVDS_SER_CLK
, LVDS_CHSYNC_CLK_OUT_tmp__V
, RESETB_EXT
, LVDS_DATA_OUT_tmp__V
, LVDS_HITOR_OUT_tmp__V
, LVDS_CHSYNC_LOCKED_OUT_tmp__V
, LVDS_CHSYNC_CLK_OUT_tmp__V
, RESETB_EXT
);
LVDS_CHSYNC_CLK_OUT_seq__V <= LVDS_CHSYNC_CLK_OUT_tmp__V;
LVDS_DATA_OUT_seq__V <= LVDS_DATA_OUT_tmp__V;
LVDS_HITOR_OUT_seq__V <= LVDS_HITOR_OUT_tmp__V;
LVDS_CHSYNC_LOCKED_OUT_seq__V <= LVDS_CHSYNC_LOCKED_OUT_tmp__V;
LVDS_CHSYNC_CLK_OUT_seq__V <= LVDS_CHSYNC_CLK_OUT_tmp__V;
end

// Select between combinatorial and sequential results
always @(*) begin
always @* begin
if (last_seq_seqnum__V > last_combo_seqnum__V) begin
LVDS_CHSYNC_CLK_OUT = LVDS_CHSYNC_CLK_OUT_seq__V;
LVDS_DATA_OUT = LVDS_DATA_OUT_seq__V;
LVDS_HITOR_OUT = LVDS_HITOR_OUT_seq__V;
LVDS_CHSYNC_LOCKED_OUT = LVDS_CHSYNC_LOCKED_OUT_seq__V;
LVDS_CHSYNC_CLK_OUT = LVDS_CHSYNC_CLK_OUT_seq__V;
end else begin
end
else begin
LVDS_CHSYNC_CLK_OUT = LVDS_CHSYNC_CLK_OUT_combo__V;
LVDS_DATA_OUT = LVDS_DATA_OUT_combo__V;
LVDS_HITOR_OUT = LVDS_HITOR_OUT_combo__V;
LVDS_CHSYNC_LOCKED_OUT = LVDS_CHSYNC_LOCKED_OUT_combo__V;
LVDS_CHSYNC_CLK_OUT = LVDS_CHSYNC_CLK_OUT_combo__V;
end
end

Expand Down
27 changes: 4 additions & 23 deletions tjmonopix2/tests/test_hardware/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import typing

import basil
import cocotb
import tjmonopix2
import yaml
from basil.utils.sim.utils import cocotb_compile_and_run

import tjmonopix2
from tjmonopix2 import utils
from tjmonopix2.system.bdaq53 import BDAQ53
from tjmonopix2.system.tjmonopix2 import TJMonoPix2
Expand All @@ -23,9 +23,6 @@ def setup_cocotb(extra_defines: list = []) -> dict:
if "SIM" not in os.environ.keys():
os.environ["SIM"] = "verilator"

if os.environ["SIM"] == "verilator":
patch_cocotb_makefile()

tjmonopix2_path = os.path.dirname(tjmonopix2.__file__) # tjmonopix2 package path
top_dir = os.path.join(
tjmonopix2_path, ".."
Expand Down Expand Up @@ -64,15 +61,10 @@ def setup_cocotb(extra_defines: list = []) -> dict:
"-DVERSION_PATCH={:s}".format(version[2]),
"-LDFLAGS {:s}/tjmonopix2/tests/test_hardware/hdl/libmonopix2.a".format(top_dir),
"--hierarchical",
"-Wno-fatal",
"-Wno-COMBDLY",
"-Wno-PINMISSING",
"-Wno-fatal",
"--output-split 15000",
"-O3",
"-CFLAGS -O3",
],
build_args=[
"-j 2"
"-Wno-LATCH",
],
extra_defines=extra_defines,
)
Expand Down Expand Up @@ -100,17 +92,6 @@ def setup_cocotb(extra_defines: list = []) -> dict:
return cnfg


def patch_cocotb_makefile() -> None:
makefile_path = os.path.join(
os.path.dirname(cocotb.__file__), "share/makefiles/simulators"
)
with open(os.path.join(makefile_path, "Makefile.verilator"), "r+") as makefile:
content = makefile.read()
makefile.seek(0)
makefile.truncate()
makefile.write(content.replace("--public-flat-rw ", ""))


def wait_for_sim(dut: BDAQ53, repetitions=8) -> None:
dut.write_command(dut.write_sync(write=False), repetitions=repetitions)

Expand Down
Loading