-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a329496
commit 3200cbd
Showing
11 changed files
with
339 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...mples/10_demo_full_flow/full_flow_demo/full_flow_demo/tb/out/truth_table_test_results.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
,detector_in,phase_map_out,time | ||
0,00,00,2000 | ||
1,01,10,4000 | ||
2,10,11,6000 | ||
3,11,11,8000 | ||
,input_fock_state,phase_bit,time | ||
0,100,0000000000,2000 | ||
1,001,1111100000,4000 | ||
2,010,0000011111,6000 | ||
3,001,1111100000,8000 |
64 changes: 37 additions & 27 deletions
64
docs/examples/10_demo_full_flow/full_flow_demo/full_flow_demo/tb/test_top.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,69 @@ | ||
|
||
# This file is public domain, it can be freely copied without restrictions. | ||
# SPDX-License-Identifier: CC0-1.0 | ||
import cocotb | ||
from cocotb.triggers import Timer | ||
from cocotb.utils import get_sim_time | ||
import pandas as pd | ||
|
||
|
||
@cocotb.test() | ||
async def truth_table_test(dut): | ||
"""Test for logic defined by the truth table""" | ||
|
||
detector_in_data = [] | ||
phase_map_out_data = [] | ||
input_fock_state_data = [] | ||
phase_bit_data = [] | ||
time_data = [] | ||
|
||
# Test case 1 | ||
dut.detector_in.value = cocotb.binary.BinaryValue("00") | ||
await Timer(2, units='ns') | ||
dut.input_fock_state.value = cocotb.binary.BinaryValue("100") | ||
await Timer(2, units="ns") | ||
|
||
assert dut.phase_map_out.value == cocotb.binary.BinaryValue("00"), f"Test failed for inputs ['detector_in']: expected 00 but got {dut.phase_map_out.value}." | ||
detector_in_data.append(dut.detector_in.value) | ||
phase_map_out_data.append(dut.phase_map_out.value) | ||
assert dut.phase_bit.value == cocotb.binary.BinaryValue( | ||
"0000000000" | ||
), f"Test failed for inputs ['input_fock_state']: expected 0000000000 but got {dut.phase_bit.value}." | ||
input_fock_state_data.append(dut.input_fock_state.value) | ||
phase_bit_data.append(dut.phase_bit.value) | ||
time_data.append(get_sim_time()) | ||
|
||
# Test case 2 | ||
dut.detector_in.value = cocotb.binary.BinaryValue("01") | ||
await Timer(2, units='ns') | ||
dut.input_fock_state.value = cocotb.binary.BinaryValue("001") | ||
await Timer(2, units="ns") | ||
|
||
assert dut.phase_map_out.value == cocotb.binary.BinaryValue("10"), f"Test failed for inputs ['detector_in']: expected 10 but got {dut.phase_map_out.value}." | ||
detector_in_data.append(dut.detector_in.value) | ||
phase_map_out_data.append(dut.phase_map_out.value) | ||
assert dut.phase_bit.value == cocotb.binary.BinaryValue( | ||
"1111100000" | ||
), f"Test failed for inputs ['input_fock_state']: expected 1111100000 but got {dut.phase_bit.value}." | ||
input_fock_state_data.append(dut.input_fock_state.value) | ||
phase_bit_data.append(dut.phase_bit.value) | ||
time_data.append(get_sim_time()) | ||
|
||
# Test case 3 | ||
dut.detector_in.value = cocotb.binary.BinaryValue("10") | ||
await Timer(2, units='ns') | ||
dut.input_fock_state.value = cocotb.binary.BinaryValue("010") | ||
await Timer(2, units="ns") | ||
|
||
assert dut.phase_map_out.value == cocotb.binary.BinaryValue("11"), f"Test failed for inputs ['detector_in']: expected 11 but got {dut.phase_map_out.value}." | ||
detector_in_data.append(dut.detector_in.value) | ||
phase_map_out_data.append(dut.phase_map_out.value) | ||
assert dut.phase_bit.value == cocotb.binary.BinaryValue( | ||
"0000011111" | ||
), f"Test failed for inputs ['input_fock_state']: expected 0000011111 but got {dut.phase_bit.value}." | ||
input_fock_state_data.append(dut.input_fock_state.value) | ||
phase_bit_data.append(dut.phase_bit.value) | ||
time_data.append(get_sim_time()) | ||
|
||
# Test case 4 | ||
dut.detector_in.value = cocotb.binary.BinaryValue("11") | ||
await Timer(2, units='ns') | ||
dut.input_fock_state.value = cocotb.binary.BinaryValue("001") | ||
await Timer(2, units="ns") | ||
|
||
assert dut.phase_map_out.value == cocotb.binary.BinaryValue("11"), f"Test failed for inputs ['detector_in']: expected 11 but got {dut.phase_map_out.value}." | ||
detector_in_data.append(dut.detector_in.value) | ||
phase_map_out_data.append(dut.phase_map_out.value) | ||
assert dut.phase_bit.value == cocotb.binary.BinaryValue( | ||
"1111100000" | ||
), f"Test failed for inputs ['input_fock_state']: expected 1111100000 but got {dut.phase_bit.value}." | ||
input_fock_state_data.append(dut.input_fock_state.value) | ||
phase_bit_data.append(dut.phase_bit.value) | ||
time_data.append(get_sim_time()) | ||
|
||
simulation_data = { | ||
"detector_in": detector_in_data, | ||
"phase_map_out": phase_map_out_data, | ||
"time": time_data | ||
"input_fock_state": input_fock_state_data, | ||
"phase_bit": phase_bit_data, | ||
"time": time_data, | ||
} | ||
|
||
pd.DataFrame(simulation_data).to_csv("/home/daquintero/phd/piel_private/docs/examples/10_demo_full_flow/full_flow_demo/full_flow_demo/tb/out/truth_table_test_results.csv") | ||
pd.DataFrame(simulation_data).to_csv( | ||
"/home/daquintero/phd/piel_private/docs/examples/10_demo_full_flow/full_flow_demo/full_flow_demo/tb/out/truth_table_test_results.csv" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.