Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

[smem] fix read-under-write serialization #2595

Merged
merged 3 commits into from
Jan 25, 2023

Conversation

ekiwi
Copy link
Contributor

@ekiwi ekiwi commented Jan 25, 2023

Also adds some tests for the parser and
the serializer.

Type of Improvement

  • bug fix

API Impact

  • smem now serializes correctly

Backend Code Generation Impact

  • none

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (1.2.x, 1.3.0, 1.4.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

Also adds some tests for the parser and
the serializer.
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

Nice.

One concern about the serialization format. I'd prefer to always serialize this.

src/main/scala/firrtl/ir/Serializer.scala Outdated Show resolved Hide resolved
src/test/scala/firrtlTests/ParserSpec.scala Outdated Show resolved Hide resolved
it should "serialize read-under-write behavior for smems correctly" in {
def parseSerializeParse(src: String): Circuit = Parser.parse(Parser.parse(src).serialize)
val undefined = parseSerializeParse(SMemTestCircuit.src(""))
assert(SMemTestCircuit.findRuw(undefined) == ReadUnderWrite.Undefined)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: using non-assert matchers may be more readable:

SMemTestCircuit.findRuw(undefined) should be (ReadUnderWrite.Undefined)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree. I like to keep things simple and scalatest will still highlight the failure correctly when using plain asserts. The should or must matchers have some weird corner cases (I forgot what they were, but there was some trouble in the past that would have been avoided by sticking to the basics).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you insist on using the should and I will change it in order to get this change in.

Copy link
Member

Choose a reason for hiding this comment

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

There's no problem with using them here and continuing to use them aligns with all the other tests in this file.

For corner cases, you may be thinking of string matching on include vs contains? The former looks for a substring match and the latter looks for an exact match.

Copy link
Member

Choose a reason for hiding this comment

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

Don't care. It's good to land as-is. 👍

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

LGTM

it should "serialize read-under-write behavior for smems correctly" in {
def parseSerializeParse(src: String): Circuit = Parser.parse(Parser.parse(src).serialize)
val undefined = parseSerializeParse(SMemTestCircuit.src(""))
assert(SMemTestCircuit.findRuw(undefined) == ReadUnderWrite.Undefined)
Copy link
Member

Choose a reason for hiding this comment

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

There's no problem with using them here and continuing to use them aligns with all the other tests in this file.

For corner cases, you may be thinking of string matching on include vs contains? The former looks for a substring match and the latter looks for an exact match.

@ekiwi ekiwi added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Jan 25, 2023
@mergify mergify bot merged commit 82af22f into chipsalliance:master Jan 25, 2023
mergify bot pushed a commit that referenced this pull request Jan 25, 2023
* [smem] fix read-under-write serialization

Also adds some tests for the parser and
the serializer.

* Serializer: always serialize smem ruw behavior

* test: simplify smem test circuit

(cherry picked from commit 82af22f)
@mergify mergify bot added the Backported This PR has been backported to marked stable branch label Jan 25, 2023
mergify bot added a commit that referenced this pull request Jan 25, 2023
* [smem] fix read-under-write serialization

Also adds some tests for the parser and
the serializer.

* Serializer: always serialize smem ruw behavior

* test: simplify smem test circuit

(cherry picked from commit 82af22f)

Co-authored-by: Kevin Laeufer <laeufer@cs.berkeley.edu>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Backported This PR has been backported to marked stable branch Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants