Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • da/B-ASIC
  • lukja239/B-ASIC
  • robal695/B-ASIC
3 results
Show changes
Commits on Source (2)
"""
Functions to generate memory-variable test data that are used for research.
"""
import random
from typing import Optional, Set
from b_asic.process import PlainMemoryVariable
def _insert_delays(inputorder, outputorder, min_lifetime, cyclic):
size = len(inputorder)
maxdiff = min(outputorder[i] - inputorder[i] for i in range(size))
outputorder = [o - maxdiff + min_lifetime for o in outputorder]
maxdelay = max(outputorder[i] - inputorder[i] for i in range(size))
if cyclic:
if maxdelay < size:
outputorder = [o % size for o in outputorder]
else:
inputorder = inputorder + [i + size for i in inputorder]
outputorder = outputorder + [o + size for o in outputorder]
return inputorder, outputorder
def generate_random_interleaver(
size: int, min_lifetime: int = 0, cyclic: bool = True
) -> Set[PlainMemoryVariable]:
"""
Generate a ProcessCollection with memory variable corresponding to a random
interleaver with length *size*.
Parameters
----------
size : int
The size of the random interleaver sequence.
min_lifetime : int, default: 0
The minimum lifetime for a memory variable. Default is 0 meaning that at least
one variable is passed from the input to the output directly,
cyclic : bool, default: True
If the interleaver should operate continuously in a cyclic manner. That is,
start a new interleaving operation directly after the previous.
Returns
-------
ProcessCollection
"""
inputorder = list(range(size))
outputorder = inputorder[:]
random.shuffle(outputorder)
print(inputorder, outputorder)
inputorder, outputorder = _insert_delays(
inputorder, outputorder, min_lifetime, cyclic
)
print(inputorder, outputorder)
return {
PlainMemoryVariable(inputorder[i], 0, {0: outputorder[i]})
for i in range(size)
}
def generate_matrix_transposer(
height: int,
width: Optional[int] = None,
min_lifetime: int = 0,
cyclic: bool = True,
) -> Set[PlainMemoryVariable]:
r"""
Generate a ProcessCollection with memory variable corresponding to transposing a
matrix of size *height* :math:`\times` *width*. If *width* is not provided, a
square matrix of size *height* :math:`\times` *height* is used.
Parameters
----------
height : int
Matrix height.
width : int, optional
Matrix width. If not provided assumed to be equal to height, i.e., a square
matrix.
min_lifetime : int, default: 0
The minimum lifetime for a memory variable. Default is 0 meaning that at
least one variable is passed from the input to the output directly,
cyclic : bool, default: True
If the interleaver should operate continuously in a cyclic manner. That is,
start a new interleaving operation directly after the previous.
Returns
-------
ProcessCollection
"""
if width is None:
width = height
inputorder = []
for row in range(height):
for col in range(width):
inputorder.append(col + width * row)
outputorder = []
for row in range(width):
for col in range(height):
outputorder.append(col * width + row)
print(inputorder, outputorder)
inputorder, outputorder = _insert_delays(
inputorder, outputorder, min_lifetime, cyclic
)
print(inputorder, outputorder)
return {
PlainMemoryVariable(inputorder[i], 0, {0: outputorder[i]})
for i in range(width * height)
}
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS = -W --keep-going
SPHINXBUILD = python -msphinx
SPHINXPROJ = b_asic
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# workaround because sphinx does not completely clean up (#11139)
clean:
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
rm -rf "$(SOURCEDIR)/examples"
show:
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(shell pwd)/_build/html/index.html')"
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
gui\_utils package
==================
gui\_utils.about\_window module
-------------------------------
.. automodule:: b_asic.gui_utils.about_window
:members:
:undoc-members:
......@@ -28,4 +28,6 @@ Table of Contents
api/index
GUI
scheduler_gui
gui_utils
examples/index
research
Research functions
==================
research.interleaver module
---------------------------
.. automodule:: b_asic.research.interleaver
:members:
:undoc-members: