Skip to content

Conversation

@desmonddak
Copy link
Contributor

Description & Motivation

These are two components needed to build various kinds of cache memory.
First is a CAM which is a contents-addressable memory. It addresses memory by using a tag instead of an address.
It primarily returns a 'hit' but also the address of where it is found (we can work to make this optional).
The CAM also provides a standard write interface for populating the tags as data, using the line address.

Second is a Replacement module which is abstract and one kind of policy implemented; pseudoLRU. This will eventually be an optional Module passed into a Cache that can be used to modify a Cache with different way replacement policies.

Related Issue(s)

None.

Testing

Basic testing of the CAM to allow for simultaneous tag writes then tag lookups.

Backwards-compatibility

Is this a breaking change that will not be backwards-compatible? If yes, how so?

No.

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

No.

@desmonddak desmonddak marked this pull request as draft September 19, 2025 21:39
@desmonddak desmonddak requested a review from mkorbel1 September 19, 2025 21:39
Copy link
Contributor

@mkorbel1 mkorbel1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wonderful!

final int idWidth;

/// The "enable" bit for this interface, enabling a request.
Logic get en => port('en');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need an enable bit?

Copy link
Contributor Author

@desmonddak desmonddak Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To tell it to do the cam match. You are providing a tag in, and the en tells it to do a match and return the idx or data back. This is the same as a DataPortInterface providing an en and addr. Just replace those with en and tag.
You may not want it doing a match if you simply have the tag field set on the read port.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the enable is needed for a write, but if you're doing a read isn't it the same if we just always read whatever address is given? what do you mean "doing a match"? is this for power savings? the combo logic is there either way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point and simpler is better.


/// An interface to a Content-Addressable Memory (CAM) that allows querying
/// for tags and returns the index of the matching tag if found.
class TagInterface extends Interface<DataPortGroup> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but i only see it used in one way, and the write ports are DataPortInterfaces. Is there another place you're planning to use them?

final int idWidth;

/// The "enable" bit for this interface, enabling a request.
Logic get en => port('en');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the enable is needed for a write, but if you're doing a read isn't it the same if we just always read whatever address is given? what do you mean "doing a match"? is this for power savings? the combo logic is there either way

String? logicName,
}) : super(fields, name: logicName ?? config.name);

// Historically the CSR disallowed renaming because the architectural
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kimmeljo any concerns?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these test files are getting pretty long. is there an opportunity to refactor a bit to reduce repetition by making some reusable infra?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants