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

Implemented scatterUnitWB and gatherUnitWB #31

Merged
merged 12 commits into from
Jul 11, 2022

Conversation

lmbollen
Copy link
Contributor

@lmbollen lmbollen commented Mar 31, 2022

This PR implements a wishbone addressable scatter unit and a wishbone addressable gather unit.

TODO:

  • Implement generic scatter unit
  • Implement generic gather unit.
  • Implement wishbone interface for the generic scatter and gather units.
  • Documentation
  • Testing

@lmbollen lmbollen force-pushed the byte-addressable-memories branch from 87ab3d9 to 0204aa4 Compare May 2, 2022 11:59
@lmbollen lmbollen force-pushed the byte-addressable-memories branch from 0204aa4 to 5f15986 Compare May 4, 2022 09:39
@lmbollen lmbollen force-pushed the scatter-gather-wishbone branch 2 times, most recently from 3f7d068 to 693a235 Compare May 4, 2022 12:08
@lmbollen lmbollen changed the base branch from byte-addressable-memories to register-wishbone May 4, 2022 12:08
bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
-- | Wishbone master-slave port scatterUnit.
Signal dom (WishboneM2S 4 awSU) ->
-- | (slave - master data scatterUnit , slave - master data calendar)
(Signal dom (WishboneS2M 4), Signal dom (WishboneS2M bsCal))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why the scatter memory has a 32bit WB bus, but the calendar has a configurable-width WB bus. Why not?:

  • Both configurable, or
  • Both 32 bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We know that:

  • The framewidth for now will be 64 bits since we have to send over the timing oracles(f.k.a. UGNs).
  • The wishbone bus interface that accesses the s/g units will most likely be 32 bits since they're hooked up to rv32imc.

By enforcing the s/g unit bus to be 32 bits we can have a nice way to interface with the 64 bit s/g units (either using the upper or lower 32 bits).
However, the calendar wishbone bus has no requirements to constrain the amount of bytes on the bus and may not be hooked up to the same processor that the s/g bus is hooked up to.

To summarize:

  • The s/g bus cannot be easily made configurable due to the 64 bit framewidth constraint
  • There is no reason other than readability(?) to constrain the calendar bus to 32 bits.

bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Outdated Show resolved Hide resolved
Comment on lines 186 to 219
-- | Generates a 'CalendarConfig' for the 'gatherUnitWB' or 'scatterUnitWB'
genCalendarConfig ::
forall bytes addressWidth calEntry maxDepth .
( KnownNat bytes
, 1 <= bytes
, KnownNat maxDepth
, 1 <= maxDepth
, calEntry ~ Index maxDepth
, KnownNat addressWidth) =>
SNat maxDepth ->
Gen (CalendarConfig bytes addressWidth calEntry)
genCalendarConfig sizeNat@(snatToNum -> dMax) = do
dA <- Gen.enum 1 dMax
dB <- Gen.enum 1 dMax
case (TN.someNatVal dA, TN.someNatVal dB) of
( SomeNat (snatProxy -> depthA)
,SomeNat (snatProxy -> depthB)) -> do
let
regAddrBits = SNat @(NatRequiredBits (Regs calEntry (bytes * 8)))
bsCalEntry = SNat @(BitSize calEntry)
case
( isInBounds d1 depthA sizeNat
, isInBounds d1 depthB sizeNat
, compareSNat regAddrBits (SNat @addressWidth)
, compareSNat d1 bsCalEntry) of
(InBounds, InBounds, SNatLE, SNatLE)-> go depthA depthB
(a,b,c,d) -> error $ "genCalendarConfig: calEntry constraints not satisfied: ("
<> show a <> ", " <> show b <> ", " <> show c <> ", " <> show d <> "), \n(depthA, depthB, maxDepth, calEntry bitsize) = ("
<> show depthA <> ", " <> show depthB <> ", " <> show sizeNat <> ", " <> show bsCalEntry <> ")"
where
go :: forall depthA depthB .
( LessThan depthA maxDepth
, LessThan depthB maxDepth
, NatFitsInBits (Regs calEntry (bytes * 8)) addressWidth) =>
SNat depthA ->
SNat depthB ->
Gen (CalendarConfig bytes addressWidth (Index maxDepth))
go SNat SNat = do
calActive <- fromMaybe errmsg . fromList @depthA . P.take (natToNum @depthA)
<$> Gen.shuffle @_ @(Index maxDepth) [0.. natToNum @(maxDepth-1)]
calShadow <- fromMaybe errmsg . fromList @depthB . P.take (natToNum @depthB) <$> Gen.shuffle @_ @(Index maxDepth) [0.. natToNum @(maxDepth-1)]
return $ CalendarConfig sizeNat calActive calShadow
errmsg = errorX "genCalendarConfig: list to vector conversion failed"
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The generator in Tests.Calendar requires a supplied generator for the elements, but for the scatter / gather tests, you want the entries in the calendar to be unique, which therefor uses a shuffled version of an incrementing list.

@lmbollen lmbollen force-pushed the scatter-gather-wishbone branch 2 times, most recently from d4521ee to 834edfe Compare May 18, 2022 07:00
@lmbollen lmbollen force-pushed the scatter-gather-wishbone branch 4 times, most recently from 8d3c5bb to bfeede4 Compare May 20, 2022 14:02
@lmbollen lmbollen force-pushed the register-wishbone branch 3 times, most recently from f8c8290 to c27825b Compare May 23, 2022 07:22
@lmbollen lmbollen force-pushed the scatter-gather-wishbone branch 2 times, most recently from 2cab9fc to 5049cbd Compare June 28, 2022 12:21
@lmbollen lmbollen changed the base branch from main to resettable-memories June 28, 2022 12:38
@lmbollen lmbollen force-pushed the resettable-memories branch 4 times, most recently from 5ffaeb0 to 1679a92 Compare July 4, 2022 13:44
Base automatically changed from resettable-memories to main July 4, 2022 14:21
Copy link
Contributor

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

I think your test cases would be more readable if you export the the pre-type level fuzzed parts to top-level.

bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/src/Bittide/ScatterGather.hs Show resolved Hide resolved
bittide/src/Bittide/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Outdated Show resolved Hide resolved
bittide/tests/Tests/ScatterGather.hs Outdated Show resolved Hide resolved
@martijnbastiaan martijnbastiaan merged commit ea16cab into main Jul 11, 2022
@martijnbastiaan martijnbastiaan deleted the scatter-gather-wishbone branch July 11, 2022 12:33
@lmbollen lmbollen restored the scatter-gather-wishbone branch September 27, 2022 13:33
@lmbollen lmbollen deleted the scatter-gather-wishbone branch September 27, 2022 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants