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

Port ContentAddressableMemory from #395 #573

Merged
merged 35 commits into from
May 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
07f969c
Port ContentAddressableMemory.
Jan 29, 2024
9fee2ec
Port ContentAddressableMemory - tests
Jan 29, 2024
3e58cc2
Typos
Jan 29, 2024
5bf3b58
Update transactron/utils/amaranth_ext/elaboratables.py
lekcyjna123 Mar 17, 2024
7a14803
Start updating
Mar 17, 2024
deb7ccc
Merge branch 'master' into lekcyjna/port-cam
Mar 17, 2024
f560816
Fix some typing. Introduce hypothesis to generate values according to…
Mar 17, 2024
a33e930
Type fixes.
Mar 17, 2024
b7c097f
Very WIP hypothesis tests which works.
Apr 1, 2024
80df321
A little bit better solution.
Apr 1, 2024
b79897e
Merge branch 'master' into lekcyjna/port-cam
Apr 28, 2024
785657b
Prepare cleaner hypothesis integration. It work, but other tests not …
Apr 28, 2024
a993985
Fix other tests
Apr 28, 2024
1fccc59
Fix Multipriority encoder test.
Apr 28, 2024
a1da5f6
Make MuliPriorityEncoder logarithmic
Apr 28, 2024
0cffe57
Extend CAM
Apr 28, 2024
54dcb16
Extend CAM test
Apr 28, 2024
0ba17ec
Some fixes to test.
Apr 28, 2024
283e9e7
Fix test.
May 3, 2024
6a76949
Some formating
May 3, 2024
0d4ca9f
Fix formatting
May 3, 2024
202f35e
Merge branch 'master' into lekcyjna/port-cam
May 3, 2024
6312e1c
Fix after merge
May 3, 2024
16b55c8
Add create_priority_encoder
May 5, 2024
0dd252c
Add test
May 5, 2024
b716644
Doc string changes.
May 5, 2024
42f8104
Lint.
May 5, 2024
8933040
Update transactron/utils/amaranth_ext/elaboratables.py
lekcyjna123 May 5, 2024
060a904
Added create_simple variant
May 5, 2024
384fc09
Update transactron/utils/amaranth_ext/elaboratables.py
lekcyjna123 May 5, 2024
cfc4cca
Add comments about output file.
May 5, 2024
b67c4c1
Merge branch 'lekcyjna/port-cam' of github.com:kuznia-rdzeni/corebloc…
May 5, 2024
d1f14f4
Merge branch 'master' into lekcyjna/port-cam
May 12, 2024
bbd1d7a
Fix typos
tilk May 14, 2024
5e6ba59
Merge branch 'master' into lekcyjna/port-cam
tilk May 14, 2024
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
55 changes: 54 additions & 1 deletion transactron/utils/amaranth_ext/elaboratables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Literal, Optional, overload
from collections.abc import Iterable
from amaranth import *
from transactron.utils._typing import HasElaborate, ModuleLike
from transactron.utils._typing import HasElaborate, ModuleLike, ValueLike

__all__ = [
"OneHotSwitchDynamic",
Expand Down Expand Up @@ -272,6 +272,59 @@ def __init__(self, input_width: int, outputs_count: int):
self.outputs = [Signal(range(self.input_width), name=f"output_{i}") for i in range(self.outputs_count)]
self.valids = [Signal(name=f"valid_{i}") for i in range(self.outputs_count)]

@staticmethod
def create_priority_encoder(m : Module, input_width : int, input : ValueLike, outputs_count : int = 1, name : Optional[str]=None) -> list[tuple[Signal, Signal]]:
""" Syntax sugar for creation of MultiPriorityEncoder

This staticmethod allow to use MultiPriorityEncoder in more functional
way. Instead of creating the instance manually, connecting all signals and
adding a submodule you can call this function to do it automaticaly.

This function is equivalent of:

.. highlight:: python
.. code-block:: python

m.submodules += prio_encoder = PriorityEncoder(cnt)
m.d.top_comb += prio_encoder.input.eq(one_hot_singal)
idx = prio_encoder.outputs
valid = prio.encoder.valids

Parameters
----------
m: TModule
Module to which MultiPriorityEncoder should be added.
input_width : int
Width of the one hot signal.
input : ValueLike
One hot signal to decode.
outputs_count : int
Count of different decoder outputs to be generated at once. Default: 1.
name : Optional[str[
lekcyjna123 marked this conversation as resolved.
Show resolved Hide resolved
Name which should be used while adding MultiPriorityEncoder to the submodules.
If None it will be added as anonymous submodule. Provided name can not be
used in already added submodule. Default: None.

Returns
-------
return : list[tuple[Signal, Signal]]
Return list with len equal to outputs_count. Each tuple contain
a pair of decoded index on the first place and valid signal
on the second place.
"""
prio_encoder = MultiPriorityEncoder(input_width, outputs_count)
if name is None:
m.submodules += prio_encoder
else:
try:
getattr(m.submodules, name)
raise ValueError(f"Name: {name} is already in use, so MultiPriorityEncoder can not be added with it.")
except AttributeError:
setattr(m.submodules, name, prio_encoder)
m.d.top_comb += prio_encoder.input.eq(input)
return list(zip(prio_encoder.outputs, prio_encoder.valids))


def build_tree(self, m: Module, in_sig: Signal, start_idx: int):
assert len(in_sig) > 0
level_outputs = [
Expand Down