Skip to content

Commit a7f5b48

Browse files
committed
[roc + crorc] Clean up reset level & fix CRORC bug
1 parent 6193ad4 commit a7f5b48

File tree

12 files changed

+36
-35
lines changed

12 files changed

+36
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cmake-build-*
66
*.swp
77
*.swo
88
*.pyc
9+
*.patch

include/ReadoutCard/ParameterTypes/ResetLevel.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ namespace roc
2626
/// Namespace for the RORC reset level enum, and supporting functions
2727
struct ResetLevel {
2828
enum type {
29-
Nothing = 0, ///< No reset
30-
Internal = 1, ///< Reset internally only
31-
InternalDiu = 2, ///< Reset internally, and the DIU
32-
InternalDiuSiu = 3, ///< Reset internally, the DIU, and the SIU
29+
Nothing = 0, ///< No reset
30+
Internal = 1, ///< Reset internally only (+DIU for the CRORC)
31+
InternalSiu = 2, ///< Reset internally, the DIU, and the SIU (n/a for the CRU)
3332
};
3433

3534
/// Converts a ResetLevel to a string
@@ -38,7 +37,7 @@ struct ResetLevel {
3837
/// Converts a string to a ResetLevel
3938
static ResetLevel::type fromString(const std::string& string);
4039

41-
/// Returns true if the reset level includes external resets (SIU and/or DIU)
40+
/// Returns true if the reset level includes external resets (SIU)
4241
static bool includesExternal(const ResetLevel::type& level);
4342
};
4443

src/CommandLineUtilities/ProgramReset.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ProgramReset : public Program
2727
public:
2828
virtual Description getDescription()
2929
{
30-
return { "Reset", "Resets a channel", "roc-reset --id=12345 --channel=0 --reset=INTERNAL_DIU_SIU" };
30+
return { "Reset", "Resets a channel", "roc-reset --id=12345 --channel=0 --reset=INTERNAL_SIU" };
3131
}
3232

3333
virtual void addOptions(boost::program_options::options_description& options)

src/Crorc/Constants.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ static constexpr Register CHANNEL_RRBARX(0x00000084);
385385
// Register to send DDL commands
386386
static constexpr Register DDL_COMMAND(0x00000018); //TODO: Find a better name
387387
static constexpr Register DDL_STATUS(0x0000001C);
388-
static constexpr uint32_t SIU_RESET(0x000000f1);
388+
static constexpr uint32_t SIU_RESET(0x000000F1);
389+
static constexpr uint32_t RDYRX(0x00000014);
390+
static constexpr uint32_t STBRD(0x00000054);
391+
static constexpr uint32_t EOBTR(0x000000B4);
389392

390393
// At bit 13
391394
static constexpr uint32_t LINK_DOWN(0x00002000);

src/Crorc/CrorcBar.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void CrorcBar::startTrigger(uint32_t command) //TODO: Rename this
235235
void CrorcBar::stopTrigger()
236236
{
237237
try {
238-
sendDdlCommand(Crorc::Registers::DDL_COMMAND.address, Fee::EOBTR);
238+
sendDdlCommand(Crorc::Registers::DDL_COMMAND.address, Crorc::Registers::EOBTR);
239239
} catch (const Exception& e) {
240240
log("Stopping DDL trigger timed out");
241241
}
@@ -246,17 +246,19 @@ void CrorcBar::resetCard()
246246
writeRegister(Crorc::Registers::CRORC_CSR.index, Crorc::Registers::CRORC_RESET);
247247
}
248248

249-
void CrorcBar::resetDevice()
249+
void CrorcBar::resetDevice(bool withSiu)
250250
{
251251
resetCard();
252-
resetSiu();
252+
if (withSiu) {
253+
resetSiu();
254+
}
253255
assertLinkUp();
254256

255-
resetSiu();
257+
if (withSiu) {
258+
resetSiu();
259+
}
256260
resetCard();
257261
assertLinkUp();
258-
259-
return;
260262
}
261263

262264
void CrorcBar::startDataReceiver(uintptr_t readyFifoBusAddress)

src/Crorc/CrorcBar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CrorcBar final : public BarInterfaceBase
5050
void configure(bool force = false) override;
5151
Crorc::ReportInfo report();
5252

53-
void resetDevice();
53+
void resetDevice(bool withSiu);
5454
void startDataReceiver(uintptr_t readyFifoBusAddress);
5555
void stopDataReceiver();
5656
void startTrigger(uint32_t command);

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ namespace roc
4040
{
4141

4242
CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
43-
: DmaChannelPdaBase(parameters, allowedChannels()), //
44-
mPageSize(parameters.getDmaPageSize().get_value_or(DMA_PAGE_SIZE)), // 8 kB default for uniformity with CRU
45-
mInitialResetLevel(ResetLevel::Internal), // It's good to reset at least the card channel in general
46-
mSTBRD(parameters.getStbrdEnabled().get_value_or(false)), //TODO: Set as a parameter
43+
: DmaChannelPdaBase(parameters, allowedChannels()),
44+
mPageSize(parameters.getDmaPageSize().get_value_or(DMA_PAGE_SIZE)), // 8 kB default for uniformity with CRU
45+
mSTBRD(parameters.getStbrdEnabled().get_value_or(false)),
4746
mUseFeeAddress(false), // Not sure
4847
mDataSource(parameters.getDataSource().get_value_or(DataSource::Internal)) // Internal loopback by default
4948
{
@@ -95,7 +94,11 @@ CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
9594
getReadyFifoUser()->reset();
9695
mDmaBufferUserspace = getBufferProvider().getAddress();
9796

98-
deviceResetChannel();
97+
if (mDataSource == DataSource::Fee || mDataSource == DataSource::Siu) {
98+
deviceResetChannel(ResetLevel::InternalSiu);
99+
} else {
100+
deviceResetChannel(ResetLevel::Internal);
101+
}
99102
}
100103

101104
auto CrorcDmaChannel::allowedChannels() -> AllowedChannels
@@ -150,7 +153,7 @@ void CrorcDmaChannel::startPendingDma()
150153
getBar()->assertLinkUp();
151154

152155
// RDYRX command to FEE
153-
uint32_t command = (mRDYRX) ? Fee::RDYRX : Fee::STBRD;
156+
uint32_t command = (mRDYRX) ? Crorc::Registers::RDYRX : Crorc::Registers::STBRD;
154157
getBar()->startTrigger(command);
155158
}
156159
}
@@ -191,7 +194,9 @@ void CrorcDmaChannel::deviceResetChannel(ResetLevel::type resetLevel)
191194
if (resetLevel == ResetLevel::Nothing) {
192195
return;
193196
}
194-
getBar()->resetDevice();
197+
198+
bool resetSiu = (resetLevel == ResetLevel::InternalSiu) ? true : false;
199+
getBar()->resetDevice(resetSiu);
195200
}
196201

197202
void CrorcDmaChannel::startDataGenerator() //TODO: Update this
@@ -207,7 +212,7 @@ void CrorcDmaChannel::startDataGenerator() //TODO: Update this
207212
getCrorc().setSiuLoopback(mDiuConfig);
208213
std::this_thread::sleep_for(100ms); // XXX Why???
209214
getCrorc().assertLinkUp();
210-
getCrorc().siuCommand(Ddl::RandCIFST);
215+
getCrorc().siuCommand(Ddl::RandCIFST); //TODO: To be removed
211216
getCrorc().diuCommand(Ddl::RandCIFST);
212217
}
213218

src/Crorc/CrorcDmaChannel.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
6666
protected:
6767
virtual void deviceStartDma() override;
6868
virtual void deviceStopDma() override;
69-
virtual void deviceResetChannel(ResetLevel::type resetLevel = ResetLevel::InternalDiuSiu) override;
69+
virtual void deviceResetChannel(ResetLevel::type resetLevel = ResetLevel::InternalSiu) override;
7070

7171
private:
7272
/// Superpage size supported by the CRORC backend
@@ -180,9 +180,6 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
180180
/// DMA page size
181181
const size_t mPageSize;
182182

183-
/// Reset level on initialization of channel
184-
ResetLevel::type mInitialResetLevel;
185-
186183
/// Allows sending the RDYRX and EOBTR commands.
187184
bool mRDYRX;
188185

src/Cru/CruDmaChannel.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace roc
3131

3232
CruDmaChannel::CruDmaChannel(const Parameters& parameters)
3333
: DmaChannelPdaBase(parameters, allowedChannels()),
34-
mInitialResetLevel(ResetLevel::Internal), // It's good to reset at least the card channel in general
3534
mDataSource(parameters.getDataSource().get_value_or(DataSource::Internal)), // DG loopback mode by default
3635
mDmaPageSize(parameters.getDmaPageSize().get_value_or(Cru::DMA_PAGE_SIZE))
3736
{

src/Cru/CruDmaChannel.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ class CruDmaChannel final : public DmaChannelPdaBase
149149

150150
// These variables are configuration parameters
151151

152-
/// Reset level on initialization of channel
153-
const ResetLevel::type mInitialResetLevel;
154-
155152
/// Gives the data source
156153
const DataSource::type mDataSource;
157154

0 commit comments

Comments
 (0)