Skip to content

Conversation

@robtorx
Copy link
Contributor

@robtorx robtorx commented Mar 8, 2025

Description & Motivation

Add ability for main to have multiple chip selects and sub to tristate its outputs. Allowing for multidrop configurations in SPI.

Related Issue(s)

#158

Testing

Unit tests for multiple sub configurations.

Backwards-compatibility

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

Documentation

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

@mkorbel1 mkorbel1 self-requested a review March 8, 2025 01:21
required Logic reset,
required Logic start,
required Logic busIn,
Logic? css,
Copy link
Contributor

Choose a reason for hiding this comment

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

add documentation for what css is

..pairConnectIO(this, intf, PairRole.provider);

final isRunning = Logic(name: 'isRunning');
final active = Logic(name: 'enable');
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean to call this "active"?

{required SpiInterface intf,
Logic? busIn,
Logic? reset,
bool triStateOutput = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

document triStateOutput

asyncReset: true,
resetValue: busIn?[-1]);
// flop data from shift register dataOut.
final flopDataOut = FlipFlop(~intf.sclk, shiftReg.dataOut,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why not keep it as a flop like it was?

final int dataLength;

/// The number of Chip Select signals in this interface.
final int multiChipSelects;
Copy link
Contributor

Choose a reason for hiding this comment

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

why no numChipSelects or something?


class SpiMultiSubTest extends Test {
late final SpiInterface intfMain;
late final SpiInterface intfSubA;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: might be better to make this a List<SpiInterface> to reduce the copy-paste for A,B,C,D? And List<SpiSub> etc.


Simulator.injectAction(() {
intf.csb.put(1);
intf.csb[0].put(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is incomplete on the BFM side, right? we need ways to drive different CSB's, not just always 0

Logic? reset,
bool triStateOutput = false,
super.name = 'spiSub'}) {
// SPI Interface
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add validation that the interface always has 1 CS?

Copy link
Contributor

Choose a reason for hiding this comment

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

should we add validation that the interface always has 1 CS?

Copy link
Contributor

Choose a reason for hiding this comment

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

does the SPI checker need updating as well?

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