From 2a371132fff64ba65237e32f19a4d4589ad1a8c9 Mon Sep 17 00:00:00 2001 From: Marcus10110 Date: Wed, 30 Sep 2020 20:42:14 -0700 Subject: [PATCH] clang-format update of Management Data Input/Output (MDIO) Analyzer --- src/MDIOAnalyzer.cpp | 758 +++++++++++------------ src/MDIOAnalyzer.h | 123 ++-- src/MDIOAnalyzerResults.cpp | 891 +++++++++++++++------------- src/MDIOAnalyzerResults.h | 101 ++-- src/MDIOAnalyzerSettings.cpp | 90 ++- src/MDIOAnalyzerSettings.h | 53 +- src/MDIOSimulationDataGenerator.cpp | 296 +++++---- src/MDIOSimulationDataGenerator.h | 90 ++- 8 files changed, 1246 insertions(+), 1156 deletions(-) diff --git a/src/MDIOAnalyzer.cpp b/src/MDIOAnalyzer.cpp index bb21f37..37b464b 100644 --- a/src/MDIOAnalyzer.cpp +++ b/src/MDIOAnalyzer.cpp @@ -2,428 +2,431 @@ #include "MDIOAnalyzerSettings.h" #include -MDIOAnalyzer::MDIOAnalyzer() -: Analyzer2(), -mSettings( new MDIOAnalyzerSettings() ), -mSimulationInitialized( false ) +MDIOAnalyzer::MDIOAnalyzer() : Analyzer2(), mSettings( new MDIOAnalyzerSettings() ), mSimulationInitialized( false ) { - SetAnalyzerSettings( mSettings.get() ); + SetAnalyzerSettings( mSettings.get() ); } MDIOAnalyzer::~MDIOAnalyzer() { - KillThread(); + KillThread(); } void MDIOAnalyzer::WorkerThread() -{ - mSampleRateHz = GetSampleRate(); - // mPacketInTransaction = 0; - // mTransactionID = 0; - - // mMDio and mMdc have the actual data from the channel - mMdio = GetAnalyzerChannelData( mSettings->mMdioChannel ); - mMdc = GetAnalyzerChannelData( mSettings->mMdcChannel ); - - for( ; ; ) - { - // normally pulled up - AdvanceToHighMDIO(); - - // go to the beggining of a start frame (MDIO HIGH->LOW transition) - AdvanceToStartFrame(); - - // Put a marker in the start position - mResults->AddMarker( mMdio->GetSampleNumber(), AnalyzerResults::Start, mSettings->mMdioChannel ); - - // process the packet - ProcessStartFrame(); - ProcessOpcodeFrame(); - ProcessPhyAddrFrame(); - ProcessRegAddrDevTypeFrame(); - ProcessTAFrame(); - ProcessAddrDataFrame(); - - // Put a marker in the end of the packet - mResults->AddMarker( mMdio->GetSampleNumber(), AnalyzerResults::Stop, mSettings->mMdioChannel ); - - AddArrowMarkers(); - - // commit the generated frames to a packet - U64 packet_id = mResults->CommitPacketAndStartNewPacket(); - - // NOTE: For future support of transactions in MDIOAnalyzer class - // add the current packet to the current transaction - // mResults->AddPacketToTransaction( mTransactionID, packet_id ); - - // finally commit the results to the MDIOAnalyzerResults class - mResults->CommitResults(); - - // NOTE: For future support of transactions in MDIOAnalyzer class - // Check if it is the end of a C22 or C45 transaction (C45 transaction consists of two frames) - /* - if( ( mCurrentPacket.clause == MDIO_C22_PACKET ) || - ( mCurrentPacket.clause == MDIO_C45_PACKET && mPacketInTransaction == 2 ) ) - { - mTransactionID++; - mPacketInTransaction = 0; - } - */ - } +{ + mSampleRateHz = GetSampleRate(); + // mPacketInTransaction = 0; + // mTransactionID = 0; + + // mMDio and mMdc have the actual data from the channel + mMdio = GetAnalyzerChannelData( mSettings->mMdioChannel ); + mMdc = GetAnalyzerChannelData( mSettings->mMdcChannel ); + + for( ;; ) + { + // normally pulled up + AdvanceToHighMDIO(); + + // go to the beggining of a start frame (MDIO HIGH->LOW transition) + AdvanceToStartFrame(); + + // Put a marker in the start position + mResults->AddMarker( mMdio->GetSampleNumber(), AnalyzerResults::Start, mSettings->mMdioChannel ); + + // process the packet + ProcessStartFrame(); + ProcessOpcodeFrame(); + ProcessPhyAddrFrame(); + ProcessRegAddrDevTypeFrame(); + ProcessTAFrame(); + ProcessAddrDataFrame(); + + // Put a marker in the end of the packet + mResults->AddMarker( mMdio->GetSampleNumber(), AnalyzerResults::Stop, mSettings->mMdioChannel ); + + AddArrowMarkers(); + + // commit the generated frames to a packet + U64 packet_id = mResults->CommitPacketAndStartNewPacket(); + + // NOTE: For future support of transactions in MDIOAnalyzer class + // add the current packet to the current transaction + // mResults->AddPacketToTransaction( mTransactionID, packet_id ); + + // finally commit the results to the MDIOAnalyzerResults class + mResults->CommitResults(); + + // NOTE: For future support of transactions in MDIOAnalyzer class + // Check if it is the end of a C22 or C45 transaction (C45 transaction consists of two frames) + /* + if( ( mCurrentPacket.clause == MDIO_C22_PACKET ) || + ( mCurrentPacket.clause == MDIO_C45_PACKET && mPacketInTransaction == 2 ) ) + { + mTransactionID++; + mPacketInTransaction = 0; + } + */ + } } -void MDIOAnalyzer::AddArrowMarkers() +void MDIOAnalyzer::AddArrowMarkers() { - // add arrows in clock posedges - for( U32 i=0; i < mMdcPosedgeArrows.size(); i++ ) - { - mResults->AddMarker( mMdcPosedgeArrows[i], AnalyzerResults::UpArrow, mSettings->mMdcChannel ); - } - mMdcPosedgeArrows.clear(); - - // add arrows in clock negedges - for( U32 i=0; i < mMdcNegedgeArrows.size(); i++ ) - { - mResults->AddMarker( mMdcNegedgeArrows[i], AnalyzerResults::DownArrow, mSettings->mMdcChannel ); - } - mMdcNegedgeArrows.clear(); + // add arrows in clock posedges + for( U32 i = 0; i < mMdcPosedgeArrows.size(); i++ ) + { + mResults->AddMarker( mMdcPosedgeArrows[ i ], AnalyzerResults::UpArrow, mSettings->mMdcChannel ); + } + mMdcPosedgeArrows.clear(); + + // add arrows in clock negedges + for( U32 i = 0; i < mMdcNegedgeArrows.size(); i++ ) + { + mResults->AddMarker( mMdcNegedgeArrows[ i ], AnalyzerResults::DownArrow, mSettings->mMdcChannel ); + } + mMdcNegedgeArrows.clear(); } -void MDIOAnalyzer::AdvanceToStartFrame() +void MDIOAnalyzer::AdvanceToStartFrame() { - if( mMdio->GetBitState() == BIT_LOW ) - { - AnalyzerHelpers::Assert( "AdvanceToStartFrame() must be called with MDIO line with HIGH state" ); - } - - mMdio->AdvanceToNextEdge(); // high->low transition - mMdc->AdvanceToAbsPosition( mMdio->GetSampleNumber() ); - if( mMdc->GetBitState( ) == BIT_HIGH ) - mMdc->AdvanceToNextEdge( ); + if( mMdio->GetBitState() == BIT_LOW ) + { + AnalyzerHelpers::Assert( "AdvanceToStartFrame() must be called with MDIO line with HIGH state" ); + } + + mMdio->AdvanceToNextEdge(); // high->low transition + mMdc->AdvanceToAbsPosition( mMdio->GetSampleNumber() ); + if( mMdc->GetBitState() == BIT_HIGH ) + mMdc->AdvanceToNextEdge(); } -void MDIOAnalyzer::ProcessStartFrame() +void MDIOAnalyzer::ProcessStartFrame() { - // starting sample of the start frame - U64 starting_sample = mMdio->GetSampleNumber(); - - // get the value of the two bits of the start frame - BitState bit0, bit1; - GetBit( bit0, mMdcPosedgeArrows ); // sample first bit - GetBit( bit1, mMdcPosedgeArrows ); // sample second bit - - // create and set the start frame - Frame frame; - frame.mType = ( bit1 == BIT_HIGH ) ? MDIO_C22_START : MDIO_C45_START; - frame.mFlags = 0; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); - - mCurrentPacket.clause = ( frame.mType == MDIO_C22_START ) ? MDIO_C22_PACKET : MDIO_C45_PACKET; - - // NOTE: For future support of transactions in MDIOAnalyzer class - /* - if( mCurrentPacket.clause == MDIO_C45_PACKET ) - { - mPacketInTransaction++; - } - */ + // starting sample of the start frame + U64 starting_sample = mMdio->GetSampleNumber(); + + // get the value of the two bits of the start frame + BitState bit0, bit1; + GetBit( bit0, mMdcPosedgeArrows ); // sample first bit + GetBit( bit1, mMdcPosedgeArrows ); // sample second bit + + // create and set the start frame + Frame frame; + frame.mType = ( bit1 == BIT_HIGH ) ? MDIO_C22_START : MDIO_C45_START; + frame.mFlags = 0; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); + + mCurrentPacket.clause = ( frame.mType == MDIO_C22_START ) ? MDIO_C22_PACKET : MDIO_C45_PACKET; + + // NOTE: For future support of transactions in MDIOAnalyzer class + /* + if( mCurrentPacket.clause == MDIO_C45_PACKET ) + { + mPacketInTransaction++; + } + */ } -void MDIOAnalyzer::ProcessOpcodeFrame() +void MDIOAnalyzer::ProcessOpcodeFrame() { - // starting sample of the start frame - U64 starting_sample = mMdio->GetSampleNumber()+1; - - // get the value of the two bits of the start frame - BitState bit0, bit1; - GetBit( bit0, mMdcPosedgeArrows ); // sample first bit - GetBit( bit1, mMdcPosedgeArrows ); // sample second bit - - // reconstruct the opcode - DataBuilder opcode; - U64 value=0; - opcode.Reset( &value, AnalyzerEnums::MsbFirst, 2 ); - opcode.AddBit(bit0); - opcode.AddBit(bit1); - - // create and set the opcode frame - Frame frame; - - if( mCurrentPacket.clause == MDIO_C22_PACKET ) - { - switch( value ) - { - case C45_ADDRESS: - frame.mType = MDIO_UNKNOWN; // Clause 22 opcode cannot be C45_ADDRESS (00) - mCurrentPacket.operation = MDIO_PACKET_WRITE; - break; - case C22_WRITE: - frame.mType = MDIO_OP_W; - mCurrentPacket.operation = MDIO_PACKET_WRITE; - break; - case C22_READ: - frame.mType = MDIO_OP_R; - mCurrentPacket.operation = MDIO_PACKET_READ; - break; - case C45_READ: - frame.mType = MDIO_UNKNOWN; // Clause 22 opcode cannot be C45_READ (11) - mCurrentPacket.operation = MDIO_PACKET_READ; - break; - default: - frame.mType = MDIO_UNKNOWN; - } - } - else // mCurrentPacket.clause == MDIO_C45_PACKET - { - mCurrentPacket.c45Type = MDIO_C45_PACKET_DATA; - mCurrentPacket.operation = MDIO_PACKET_WRITE; - - switch( value ) - { - case C45_ADDRESS: - frame.mType = MDIO_C45_OP_ADDR; - mCurrentPacket.c45Type = MDIO_C45_PACKET_ADDR; - mCurrentPacket.operation = MDIO_PACKET_WRITE; - break; - case C45_WRITE: - frame.mType = MDIO_OP_W; - mCurrentPacket.operation = MDIO_PACKET_WRITE; - break; - case C45_READ_AND_ADDR: - frame.mType = MDIO_C45_OP_READ_INC_ADDR; - mCurrentPacket.operation = MDIO_PACKET_READ; - break; - case C45_READ: - frame.mType = MDIO_OP_R; - mCurrentPacket.operation = MDIO_PACKET_READ; - break; - default: - frame.mType = MDIO_UNKNOWN; - } - } - - if( frame.mType == MDIO_UNKNOWN ) - { - frame.mFlags = DISPLAY_AS_ERROR_FLAG; - } - else - { - frame.mFlags = 0; - } - - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); + // starting sample of the start frame + U64 starting_sample = mMdio->GetSampleNumber() + 1; + + // get the value of the two bits of the start frame + BitState bit0, bit1; + GetBit( bit0, mMdcPosedgeArrows ); // sample first bit + GetBit( bit1, mMdcPosedgeArrows ); // sample second bit + + // reconstruct the opcode + DataBuilder opcode; + U64 value = 0; + opcode.Reset( &value, AnalyzerEnums::MsbFirst, 2 ); + opcode.AddBit( bit0 ); + opcode.AddBit( bit1 ); + + // create and set the opcode frame + Frame frame; + + if( mCurrentPacket.clause == MDIO_C22_PACKET ) + { + switch( value ) + { + case C45_ADDRESS: + frame.mType = MDIO_UNKNOWN; // Clause 22 opcode cannot be C45_ADDRESS (00) + mCurrentPacket.operation = MDIO_PACKET_WRITE; + break; + case C22_WRITE: + frame.mType = MDIO_OP_W; + mCurrentPacket.operation = MDIO_PACKET_WRITE; + break; + case C22_READ: + frame.mType = MDIO_OP_R; + mCurrentPacket.operation = MDIO_PACKET_READ; + break; + case C45_READ: + frame.mType = MDIO_UNKNOWN; // Clause 22 opcode cannot be C45_READ (11) + mCurrentPacket.operation = MDIO_PACKET_READ; + break; + default: + frame.mType = MDIO_UNKNOWN; + } + } + else // mCurrentPacket.clause == MDIO_C45_PACKET + { + mCurrentPacket.c45Type = MDIO_C45_PACKET_DATA; + mCurrentPacket.operation = MDIO_PACKET_WRITE; + + switch( value ) + { + case C45_ADDRESS: + frame.mType = MDIO_C45_OP_ADDR; + mCurrentPacket.c45Type = MDIO_C45_PACKET_ADDR; + mCurrentPacket.operation = MDIO_PACKET_WRITE; + break; + case C45_WRITE: + frame.mType = MDIO_OP_W; + mCurrentPacket.operation = MDIO_PACKET_WRITE; + break; + case C45_READ_AND_ADDR: + frame.mType = MDIO_C45_OP_READ_INC_ADDR; + mCurrentPacket.operation = MDIO_PACKET_READ; + break; + case C45_READ: + frame.mType = MDIO_OP_R; + mCurrentPacket.operation = MDIO_PACKET_READ; + break; + default: + frame.mType = MDIO_UNKNOWN; + } + } + + if( frame.mType == MDIO_UNKNOWN ) + { + frame.mFlags = DISPLAY_AS_ERROR_FLAG; + } + else + { + frame.mFlags = 0; + } + + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); } -void MDIOAnalyzer::ProcessPhyAddrFrame() +void MDIOAnalyzer::ProcessPhyAddrFrame() { - // starting sample of the start frame - U64 starting_sample = mMdio->GetSampleNumber()+1; - - // get the value of the the 5 bits of the phyaddr frame - DataBuilder opcode; - U64 value; - opcode.Reset( &value, AnalyzerEnums::MsbFirst, 5 ); - for(U32 i=0; i < 5; ++i) - { - BitState bit; - GetBit( bit, mMdcPosedgeArrows ); - opcode.AddBit(bit); - } - - // create and set the phyaddr frame - Frame frame; - frame.mType = MDIO_PHYADDR; - frame.mData1 = value; - frame.mFlags = 0; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); + // starting sample of the start frame + U64 starting_sample = mMdio->GetSampleNumber() + 1; + + // get the value of the the 5 bits of the phyaddr frame + DataBuilder opcode; + U64 value; + opcode.Reset( &value, AnalyzerEnums::MsbFirst, 5 ); + for( U32 i = 0; i < 5; ++i ) + { + BitState bit; + GetBit( bit, mMdcPosedgeArrows ); + opcode.AddBit( bit ); + } + + // create and set the phyaddr frame + Frame frame; + frame.mType = MDIO_PHYADDR; + frame.mData1 = value; + frame.mFlags = 0; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); } -void MDIOAnalyzer::ProcessRegAddrDevTypeFrame() +void MDIOAnalyzer::ProcessRegAddrDevTypeFrame() { - // starting sample of the start frame - U64 starting_sample = mMdio->GetSampleNumber()+1; - - // get the value of the 5 bits of register address or devtype frame - DataBuilder opcode; - U64 value; - opcode.Reset( &value, AnalyzerEnums::MsbFirst, 5 ); - for(U32 i=0; i < 5; ++i) - { - BitState bit; - GetBit( bit, mMdcPosedgeArrows ); - opcode.AddBit(bit); - } - - // create and set the phyaddr frame - Frame frame; - if( mCurrentPacket.clause == MDIO_C22_PACKET ) - { - frame.mType = MDIO_C22_REGADDR; - } - else - { - frame.mType = GetDevType(value); - } - frame.mData1 = value; - frame.mFlags = 0; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); + // starting sample of the start frame + U64 starting_sample = mMdio->GetSampleNumber() + 1; + + // get the value of the 5 bits of register address or devtype frame + DataBuilder opcode; + U64 value; + opcode.Reset( &value, AnalyzerEnums::MsbFirst, 5 ); + for( U32 i = 0; i < 5; ++i ) + { + BitState bit; + GetBit( bit, mMdcPosedgeArrows ); + opcode.AddBit( bit ); + } + + // create and set the phyaddr frame + Frame frame; + if( mCurrentPacket.clause == MDIO_C22_PACKET ) + { + frame.mType = MDIO_C22_REGADDR; + } + else + { + frame.mType = GetDevType( value ); + } + frame.mData1 = value; + frame.mFlags = 0; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); } void MDIOAnalyzer::ProcessTAFrame() { - if( mCurrentPacket.operation == MDIO_PACKET_READ ) - { - ProcessTAFrameInReadPacket(); - } - else // mCurrentPacket.operation == MDIO_PACKET_WRITE - { - ProcessTAFrameInWritePacket(); - } + if( mCurrentPacket.operation == MDIO_PACKET_READ ) + { + ProcessTAFrameInReadPacket(); + } + else // mCurrentPacket.operation == MDIO_PACKET_WRITE + { + ProcessTAFrameInWritePacket(); + } } -void MDIOAnalyzer::ProcessTAFrameInWritePacket() +void MDIOAnalyzer::ProcessTAFrameInWritePacket() { - // starting sample of the TA frame - U64 starting_sample = mMdio->GetSampleNumber()+1; - - // get the value of the two bits of the start frame - BitState bit0, bit1; - GetBit( bit0, mMdcPosedgeArrows); - GetBit( bit1, mMdcPosedgeArrows ); - - Frame frame; - frame.mType = MDIO_TA; - // display as an error if the TA bits are not "10" - frame.mFlags = ( bit0 == BIT_HIGH && bit1 == BIT_LOW ) ? 0 : DISPLAY_AS_ERROR_FLAG; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); + // starting sample of the TA frame + U64 starting_sample = mMdio->GetSampleNumber() + 1; + + // get the value of the two bits of the start frame + BitState bit0, bit1; + GetBit( bit0, mMdcPosedgeArrows ); + GetBit( bit1, mMdcPosedgeArrows ); + + Frame frame; + frame.mType = MDIO_TA; + // display as an error if the TA bits are not "10" + frame.mFlags = ( bit0 == BIT_HIGH && bit1 == BIT_LOW ) ? 0 : DISPLAY_AS_ERROR_FLAG; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); } -void MDIOAnalyzer::ProcessTAFrameInReadPacket() +void MDIOAnalyzer::ProcessTAFrameInReadPacket() { - // starting sample of the TA frame - U64 starting_sample = mMdio->GetSampleNumber()+1; + // starting sample of the TA frame + U64 starting_sample = mMdio->GetSampleNumber() + 1; - mMdc->AdvanceToNextEdge(); // posedge - mMdc->AdvanceToNextEdge(); // negedge + mMdc->AdvanceToNextEdge(); // posedge + mMdc->AdvanceToNextEdge(); // negedge - mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // move to the mMdc negedge - mMdcNegedgeArrows.push_back( mMdc->GetSampleNumber() ); + mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // move to the mMdc negedge + mMdcNegedgeArrows.push_back( mMdc->GetSampleNumber() ); - BitState bit_state = mMdio->GetBitState(); // sample the mMdio channel + BitState bit_state = mMdio->GetBitState(); // sample the mMdio channel - U8 errorTA; - if( bit_state == BIT_LOW ) // check if the slave didn't take the bus - { - errorTA = 0; // OK - } - else - { - errorTA = DISPLAY_AS_ERROR_FLAG; - } + U8 errorTA; + if( bit_state == BIT_LOW ) // check if the slave didn't take the bus + { + errorTA = 0; // OK + } + else + { + errorTA = DISPLAY_AS_ERROR_FLAG; + } - mMdc->AdvanceToNextEdge(); // posedge + mMdc->AdvanceToNextEdge(); // posedge - mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // advance mMdio + mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // advance mMdio - Frame frame; - frame.mType = MDIO_TA; - frame.mFlags = errorTA; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + Frame frame; + frame.mType = MDIO_TA; + frame.mFlags = errorTA; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); - // after this TA, the data frame will be sampled in the negedge of the MDC clock + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); + // after this TA, the data frame will be sampled in the negedge of the MDC clock } -void MDIOAnalyzer::ProcessAddrDataFrame() +void MDIOAnalyzer::ProcessAddrDataFrame() { - U64 starting_sample = mMdio->GetSampleNumber()+1; - - DataBuilder opcode; - U64 value; - opcode.Reset( &value, AnalyzerEnums::MsbFirst, 16 ); - std::vector & arrows = ( mCurrentPacket.operation == MDIO_PACKET_READ ) - ? mMdcNegedgeArrows : mMdcPosedgeArrows; - for(U32 i=0; i < 16; ++i) - { - BitState bit; - GetBit( bit, arrows ); - opcode.AddBit(bit); - } - - Frame frame; - if( mCurrentPacket.clause == MDIO_C22_PACKET ) - { - frame.mType = MDIO_C22_DATA; - } - else // mCurrentPacket.clause == MDIO_C45_PACKET - { - frame.mType = ( mCurrentPacket.c45Type == MDIO_C45_PACKET_ADDR ) ? MDIO_C45_ADDR : MDIO_C45_DATA; - } - frame.mData1 = value; - frame.mFlags = 0; - frame.mStartingSampleInclusive = starting_sample; - frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); - - mResults->AddFrame( frame ); - ReportProgress( frame.mEndingSampleInclusive ); + U64 starting_sample = mMdio->GetSampleNumber() + 1; + + DataBuilder opcode; + U64 value; + opcode.Reset( &value, AnalyzerEnums::MsbFirst, 16 ); + std::vector& arrows = ( mCurrentPacket.operation == MDIO_PACKET_READ ) ? mMdcNegedgeArrows : mMdcPosedgeArrows; + for( U32 i = 0; i < 16; ++i ) + { + BitState bit; + GetBit( bit, arrows ); + opcode.AddBit( bit ); + } + + Frame frame; + if( mCurrentPacket.clause == MDIO_C22_PACKET ) + { + frame.mType = MDIO_C22_DATA; + } + else // mCurrentPacket.clause == MDIO_C45_PACKET + { + frame.mType = ( mCurrentPacket.c45Type == MDIO_C45_PACKET_ADDR ) ? MDIO_C45_ADDR : MDIO_C45_DATA; + } + frame.mData1 = value; + frame.mFlags = 0; + frame.mStartingSampleInclusive = starting_sample; + frame.mEndingSampleInclusive = mMdio->GetSampleNumber(); + + mResults->AddFrame( frame ); + ReportProgress( frame.mEndingSampleInclusive ); } -void MDIOAnalyzer::AdvanceToHighMDIO() +void MDIOAnalyzer::AdvanceToHighMDIO() { - if( mMdio->GetBitState() == BIT_LOW ) - { - mMdio->AdvanceToNextEdge(); // go to high state - mMdc->AdvanceToAbsPosition( mMdio->GetSampleNumber() ); - } + if( mMdio->GetBitState() == BIT_LOW ) + { + mMdio->AdvanceToNextEdge(); // go to high state + mMdc->AdvanceToAbsPosition( mMdio->GetSampleNumber() ); + } } -MDIOFrameType MDIOAnalyzer::GetDevType(const U64 & value) +MDIOFrameType MDIOAnalyzer::GetDevType( const U64& value ) { - switch (value) - { - case DEV_RESERVED: return MDIO_C45_DEVTYPE_RESERVED; - case DEV_PMD_PMA: return MDIO_C45_DEVTYPE_PMD_PMA; - case DEV_WIS: return MDIO_C45_DEVTYPE_WIS; - case DEV_PCS: return MDIO_C45_DEVTYPE_PCS; - case DEV_PHY_XS: return MDIO_C45_DEVTYPE_PHY_XS; - case DEV_DTE_XS: return MDIO_C45_DEVTYPE_DTE_XS; - default: return MDIO_C45_DEVTYPE_OTHER; - } + switch( value ) + { + case DEV_RESERVED: + return MDIO_C45_DEVTYPE_RESERVED; + case DEV_PMD_PMA: + return MDIO_C45_DEVTYPE_PMD_PMA; + case DEV_WIS: + return MDIO_C45_DEVTYPE_WIS; + case DEV_PCS: + return MDIO_C45_DEVTYPE_PCS; + case DEV_PHY_XS: + return MDIO_C45_DEVTYPE_PHY_XS; + case DEV_DTE_XS: + return MDIO_C45_DEVTYPE_DTE_XS; + default: + return MDIO_C45_DEVTYPE_OTHER; + } } -void MDIOAnalyzer::GetBit( BitState& bit_state, std::vector & arrows) +void MDIOAnalyzer::GetBit( BitState& bit_state, std::vector& arrows ) { - mMdc->AdvanceToNextEdge(); // in write operation its a posedge, in read operation its a negedge - U64 edge = mMdc->GetSampleNumber(); - arrows.push_back( edge ); + mMdc->AdvanceToNextEdge(); // in write operation its a posedge, in read operation its a negedge + U64 edge = mMdc->GetSampleNumber(); + arrows.push_back( edge ); - mMdio->AdvanceToAbsPosition( edge ); // move mMdio to sample - bit_state = mMdio->GetBitState(); // sample the mMdio channel + mMdio->AdvanceToAbsPosition( edge ); // move mMdio to sample + bit_state = mMdio->GetBitState(); // sample the mMdio channel - mMdc->AdvanceToNextEdge(); // in write write operation its a nededge, in read operation its a posedge - mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // advance mMdio + mMdc->AdvanceToNextEdge(); // in write write operation its a nededge, in read operation its a posedge + mMdio->AdvanceToAbsPosition( mMdc->GetSampleNumber() ); // advance mMdio } bool MDIOAnalyzer::NeedsRerun() @@ -438,38 +441,39 @@ void MDIOAnalyzer::SetupResults() mResults->AddChannelBubblesWillAppearOn( mSettings->mMdioChannel ); } -U32 MDIOAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels ) +U32 MDIOAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate, + SimulationChannelDescriptor** simulation_channels ) { - if( mSimulationInitialized == false ) - { - mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() ); - mSimulationInitialized = true; - } - - return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels ); + if( mSimulationInitialized == false ) + { + mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() ); + mSimulationInitialized = true; + } + + return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels ); } U32 MDIOAnalyzer::GetMinimumSampleRateHz() { - return 500000; // Minimum sampling rate: 500 Khz. + return 500000; // Minimum sampling rate: 500 Khz. } const char* MDIOAnalyzer::GetAnalyzerName() const { - return "MDIO"; + return "MDIO"; } const char* GetAnalyzerName() { - return "MDIO"; + return "MDIO"; } Analyzer* CreateAnalyzer() { - return new MDIOAnalyzer(); + return new MDIOAnalyzer(); } void DestroyAnalyzer( Analyzer* analyzer ) { - delete analyzer; + delete analyzer; } diff --git a/src/MDIOAnalyzer.h b/src/MDIOAnalyzer.h index d25d456..ac30455 100644 --- a/src/MDIOAnalyzer.h +++ b/src/MDIOAnalyzer.h @@ -5,74 +5,87 @@ #include "MDIOAnalyzerResults.h" #include "MDIOSimulationDataGenerator.h" -enum MDIOPacketClauseType { MDIO_C22_PACKET, MDIO_C45_PACKET }; -enum MDIOPacketC45Type { MDIO_C45_PACKET_ADDR, MDIO_C45_PACKET_DATA }; -enum MDIOPacketOperation { MDIO_PACKET_READ, MDIO_PACKET_WRITE }; +enum MDIOPacketClauseType +{ + MDIO_C22_PACKET, + MDIO_C45_PACKET +}; +enum MDIOPacketC45Type +{ + MDIO_C45_PACKET_ADDR, + MDIO_C45_PACKET_DATA +}; +enum MDIOPacketOperation +{ + MDIO_PACKET_READ, + MDIO_PACKET_WRITE +}; // struct to take actions depending on the type of the current MDIO packet -struct PacketType +struct PacketType { - MDIOPacketClauseType clause; - MDIOPacketC45Type c45Type; - MDIOPacketOperation operation; + MDIOPacketClauseType clause; + MDIOPacketC45Type c45Type; + MDIOPacketOperation operation; }; class MDIOAnalyzerSettings; class MDIOAnalyzer : public Analyzer2 { -public: - MDIOAnalyzer(); - virtual ~MDIOAnalyzer(); - virtual void WorkerThread(); + public: + MDIOAnalyzer(); + virtual ~MDIOAnalyzer(); + virtual void WorkerThread(); - virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels ); - virtual U32 GetMinimumSampleRateHz(); + virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels ); + virtual U32 GetMinimumSampleRateHz(); - virtual const char* GetAnalyzerName() const; - virtual bool NeedsRerun(); + virtual const char* GetAnalyzerName() const; + virtual bool NeedsRerun(); virtual void SetupResults(); -protected: - void AdvanceToStartFrame(); - - void ProcessStartFrame(); - void ProcessOpcodeFrame(); - void ProcessPhyAddrFrame(); - void ProcessRegAddrDevTypeFrame(); - void ProcessTAFrame(); - void ProcessAddrDataFrame(); - - void AdvanceToHighMDIO(); - - void ProcessTAFrameInReadPacket(); - void ProcessTAFrameInWritePacket(); - - void AddArrowMarkers(); - void GetBit( BitState& bit_state, std::vector & arrows ); - MDIOFrameType GetDevType(const U64 & value); - -protected: - std::auto_ptr< MDIOAnalyzerSettings > mSettings; - std::auto_ptr< MDIOAnalyzerResults > mResults; - - AnalyzerChannelData* mMdio; - AnalyzerChannelData* mMdc; - - MDIOSimulationDataGenerator mSimulationDataGenerator; - bool mSimulationInitialized; - - // U8 mPacketInTransaction; - // U64 mTransactionID; - - PacketType mCurrentPacket; - - std::vector mMdcPosedgeArrows; - std::vector mMdcNegedgeArrows; - - U32 mSampleRateHz; + + protected: + void AdvanceToStartFrame(); + + void ProcessStartFrame(); + void ProcessOpcodeFrame(); + void ProcessPhyAddrFrame(); + void ProcessRegAddrDevTypeFrame(); + void ProcessTAFrame(); + void ProcessAddrDataFrame(); + + void AdvanceToHighMDIO(); + + void ProcessTAFrameInReadPacket(); + void ProcessTAFrameInWritePacket(); + + void AddArrowMarkers(); + void GetBit( BitState& bit_state, std::vector& arrows ); + MDIOFrameType GetDevType( const U64& value ); + + protected: + std::auto_ptr mSettings; + std::auto_ptr mResults; + + AnalyzerChannelData* mMdio; + AnalyzerChannelData* mMdc; + + MDIOSimulationDataGenerator mSimulationDataGenerator; + bool mSimulationInitialized; + + // U8 mPacketInTransaction; + // U64 mTransactionID; + + PacketType mCurrentPacket; + + std::vector mMdcPosedgeArrows; + std::vector mMdcNegedgeArrows; + + U32 mSampleRateHz; }; extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName(); -extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer( ); +extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer(); extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer ); -#endif //MDIO_ANALYZER_H +#endif // MDIO_ANALYZER_H diff --git a/src/MDIOAnalyzerResults.cpp b/src/MDIOAnalyzerResults.cpp index 8269f60..55ae9fd 100644 --- a/src/MDIOAnalyzerResults.cpp +++ b/src/MDIOAnalyzerResults.cpp @@ -7,9 +7,7 @@ #include MDIOAnalyzerResults::MDIOAnalyzerResults( MDIOAnalyzer* analyzer, MDIOAnalyzerSettings* settings ) -: AnalyzerResults(), - mSettings( settings ), - mAnalyzer( analyzer ) + : AnalyzerResults(), mSettings( settings ), mAnalyzer( analyzer ) { } @@ -17,472 +15,531 @@ MDIOAnalyzerResults::~MDIOAnalyzerResults() { } -void MDIOAnalyzerResults::GenStartString(const Frame & frame, const char* clause, bool tabular) +void MDIOAnalyzerResults::GenStartString( const Frame& frame, const char* clause, bool tabular ) { - if( !tabular ) - { - AddResultString( "ST" ); - AddResultString( "ST C", clause ); - } - AddResultString( "START C", clause ); + if( !tabular ) + { + AddResultString( "ST" ); + AddResultString( "ST C", clause ); + } + AddResultString( "START C", clause ); } -void MDIOAnalyzerResults::GenOpString(const Frame & frame, - const char* opcode_str0, const char* opcode_str1, - const char* opcode_str2, bool tabular) +void MDIOAnalyzerResults::GenOpString( const Frame& frame, const char* opcode_str0, const char* opcode_str1, const char* opcode_str2, + bool tabular ) { - if( !tabular ) - { - AddResultString( opcode_str0 ); - AddResultString( opcode_str1 ); - AddResultString( "OP[", opcode_str1, "]" ); - } - AddResultString( "OPCODE [", opcode_str2, "]" ); + if( !tabular ) + { + AddResultString( opcode_str0 ); + AddResultString( opcode_str1 ); + AddResultString( "OP[", opcode_str1, "]" ); + } + AddResultString( "OPCODE [", opcode_str2, "]" ); } -void MDIOAnalyzerResults::GenPhyAddrString(const Frame & frame, DisplayBase display_base, bool tabular) +void MDIOAnalyzerResults::GenPhyAddrString( const Frame& frame, DisplayBase display_base, bool tabular ) { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - - if( !tabular ) - { - AddResultString( "PHY" ); - AddResultString( "PHY[", number_str, "]" ); - AddResultString( "PHYADR[", number_str, "]" ); - } - AddResultString( "PHY Address [", number_str, "]" ); + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + + if( !tabular ) + { + AddResultString( "PHY" ); + AddResultString( "PHY[", number_str, "]" ); + AddResultString( "PHYADR[", number_str, "]" ); + } + AddResultString( "PHY Address [", number_str, "]" ); } -void MDIOAnalyzerResults::GenC22RegAddrString(const Frame & frame, DisplayBase display_base, bool tabular) +void MDIOAnalyzerResults::GenC22RegAddrString( const Frame& frame, DisplayBase display_base, bool tabular ) { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - - if( !tabular ) - { - AddResultString( "REG" ); - AddResultString( "REG[", number_str, "]" ); - AddResultString( "REGADR[", number_str, "]" ); - } - AddResultString( "Register Address [", number_str, "]" ); + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + + if( !tabular ) + { + AddResultString( "REG" ); + AddResultString( "REG[", number_str, "]" ); + AddResultString( "REGADR[", number_str, "]" ); + } + AddResultString( "Register Address [", number_str, "]" ); } -void MDIOAnalyzerResults::GenC45DevTypeString(const Frame & frame, DisplayBase display_base, - const char* devtype, bool tabular) +void MDIOAnalyzerResults::GenC45DevTypeString( const Frame& frame, DisplayBase display_base, const char* devtype, bool tabular ) { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - - if( !tabular ) - { - AddResultString( "DEV" ); - AddResultString( "DEVTYPE[", devtype, "]" ); - } - AddResultString("DEVTYPE [", devtype, "] - ", number_str); + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + + if( !tabular ) + { + AddResultString( "DEV" ); + AddResultString( "DEVTYPE[", devtype, "]" ); + } + AddResultString( "DEVTYPE [", devtype, "] - ", number_str ); } -void MDIOAnalyzerResults::GenTAString(const Frame & frame, DisplayBase display_base, bool tabular) +void MDIOAnalyzerResults::GenTAString( const Frame& frame, DisplayBase display_base, bool tabular ) { - if ( frame.mFlags & DISPLAY_AS_ERROR_FLAG ) - { - if (!tabular) - { - AddResultString( "!TA" ); - } - AddResultString( "!Turnaround" ); - } - else - { - if (!tabular) - { - AddResultString( "TA" ); - } - AddResultString( "Turnaround" ); - } + if( frame.mFlags & DISPLAY_AS_ERROR_FLAG ) + { + if( !tabular ) + { + AddResultString( "!TA" ); + } + AddResultString( "!Turnaround" ); + } + else + { + if( !tabular ) + { + AddResultString( "TA" ); + } + AddResultString( "Turnaround" ); + } } -void MDIOAnalyzerResults::GenC22DataString(const Frame & frame, DisplayBase display_base, bool tabular) +void MDIOAnalyzerResults::GenC22DataString( const Frame& frame, DisplayBase display_base, bool tabular ) { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - - if( !tabular ) - { - AddResultString( "D" ); - AddResultString( "D[", number_str, "]" ); - } - AddResultString( "Data [", number_str, "]" ); + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + + if( !tabular ) + { + AddResultString( "D" ); + AddResultString( "D[", number_str, "]" ); + } + AddResultString( "Data [", number_str, "]" ); } -void MDIOAnalyzerResults::GenC45AddrDataString(const Frame & frame, DisplayBase display_base, - const char* str0, const char* str1, const char* str2, - bool tabular) +void MDIOAnalyzerResults::GenC45AddrDataString( const Frame& frame, DisplayBase display_base, const char* str0, const char* str1, + const char* str2, bool tabular ) { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - - if( !tabular ) - { - AddResultString( str0 ); - AddResultString( str1, "[", number_str, "]" ); - } - AddResultString( str2, " [", number_str, "]" ); + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + + if( !tabular ) + { + AddResultString( str0 ); + AddResultString( str1, "[", number_str, "]" ); + } + AddResultString( str2, " [", number_str, "]" ); } -void MDIOAnalyzerResults::GenUnknownString(bool tabular) +void MDIOAnalyzerResults::GenUnknownString( bool tabular ) { - if( !tabular ) - { - AddResultString("!U"); - AddResultString("!Ukw"); - } - AddResultString("!Unknown"); + if( !tabular ) + { + AddResultString( "!U" ); + AddResultString( "!Ukw" ); + } + AddResultString( "!Unknown" ); } -void MDIOAnalyzerResults::GenBubbleText(U64 frame_index, DisplayBase display_base, bool tabular) +void MDIOAnalyzerResults::GenBubbleText( U64 frame_index, DisplayBase display_base, bool tabular ) { - ClearResultStrings(); - Frame frame = GetFrame( frame_index ); - - switch( frame.mType ) - { - case MDIO_C22_START: GenStartString(frame, "22", tabular); break; - case MDIO_C45_START: GenStartString(frame, "45", tabular); break; - case MDIO_OP_W: GenOpString(frame, "W", "WR", "Write", tabular); break; - case MDIO_OP_R: GenOpString(frame, "R", "RD", "Read", tabular); break; - case MDIO_C45_OP_ADDR: GenOpString(frame, "A", "AD", "Address", tabular); break; - case MDIO_C45_OP_READ_INC_ADDR: GenOpString(frame, "R+A", "RD +AD", "Read-Increment-Address", tabular); break; - case MDIO_PHYADDR: GenPhyAddrString(frame, display_base, tabular); break; - case MDIO_C22_REGADDR: GenC22RegAddrString(frame, display_base, tabular); break; - case MDIO_C45_DEVTYPE_RESERVED: GenC45DevTypeString(frame, display_base, "Reserved", tabular); break; - case MDIO_C45_DEVTYPE_PMD_PMA: GenC45DevTypeString(frame, display_base, "PMD/PMA", tabular); break; - case MDIO_C45_DEVTYPE_WIS: GenC45DevTypeString(frame, display_base, "WIS", tabular); break; - case MDIO_C45_DEVTYPE_PCS: GenC45DevTypeString(frame, display_base, "PCS", tabular); break; - case MDIO_C45_DEVTYPE_PHY_XS: GenC45DevTypeString(frame, display_base, "PHY XS", tabular); break; - case MDIO_C45_DEVTYPE_DTE_XS: GenC45DevTypeString(frame, display_base, "DTE XS", tabular); break; - case MDIO_C45_DEVTYPE_OTHER: GenC45DevTypeString(frame, display_base, "Other", tabular); break; - case MDIO_TA: GenTAString(frame, display_base, tabular); break; - case MDIO_C22_DATA: GenC22DataString(frame, display_base, tabular); break; - case MDIO_C45_ADDR: GenC45AddrDataString(frame, display_base, "A", "ADDR", "Address", tabular); break; - case MDIO_C45_DATA: GenC45AddrDataString(frame, display_base, "D", "DATA", "Data", tabular); break; - case MDIO_UNKNOWN: GenUnknownString(tabular); break; + ClearResultStrings(); + Frame frame = GetFrame( frame_index ); + + switch( frame.mType ) + { + case MDIO_C22_START: + GenStartString( frame, "22", tabular ); + break; + case MDIO_C45_START: + GenStartString( frame, "45", tabular ); + break; + case MDIO_OP_W: + GenOpString( frame, "W", "WR", "Write", tabular ); + break; + case MDIO_OP_R: + GenOpString( frame, "R", "RD", "Read", tabular ); + break; + case MDIO_C45_OP_ADDR: + GenOpString( frame, "A", "AD", "Address", tabular ); + break; + case MDIO_C45_OP_READ_INC_ADDR: + GenOpString( frame, "R+A", "RD +AD", "Read-Increment-Address", tabular ); + break; + case MDIO_PHYADDR: + GenPhyAddrString( frame, display_base, tabular ); + break; + case MDIO_C22_REGADDR: + GenC22RegAddrString( frame, display_base, tabular ); + break; + case MDIO_C45_DEVTYPE_RESERVED: + GenC45DevTypeString( frame, display_base, "Reserved", tabular ); + break; + case MDIO_C45_DEVTYPE_PMD_PMA: + GenC45DevTypeString( frame, display_base, "PMD/PMA", tabular ); + break; + case MDIO_C45_DEVTYPE_WIS: + GenC45DevTypeString( frame, display_base, "WIS", tabular ); + break; + case MDIO_C45_DEVTYPE_PCS: + GenC45DevTypeString( frame, display_base, "PCS", tabular ); + break; + case MDIO_C45_DEVTYPE_PHY_XS: + GenC45DevTypeString( frame, display_base, "PHY XS", tabular ); + break; + case MDIO_C45_DEVTYPE_DTE_XS: + GenC45DevTypeString( frame, display_base, "DTE XS", tabular ); + break; + case MDIO_C45_DEVTYPE_OTHER: + GenC45DevTypeString( frame, display_base, "Other", tabular ); + break; + case MDIO_TA: + GenTAString( frame, display_base, tabular ); + break; + case MDIO_C22_DATA: + GenC22DataString( frame, display_base, tabular ); + break; + case MDIO_C45_ADDR: + GenC45AddrDataString( frame, display_base, "A", "ADDR", "Address", tabular ); + break; + case MDIO_C45_DATA: + GenC45AddrDataString( frame, display_base, "D", "DATA", "Data", tabular ); + break; + case MDIO_UNKNOWN: + GenUnknownString( tabular ); + break; } } void MDIOAnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& /*channel*/, DisplayBase display_base ) { - GenBubbleText(frame_index, display_base, false); + GenBubbleText( frame_index, display_base, false ); } // export_type_user_id is needed if we have more than one export type void MDIOAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 /*export_type_user_id*/ ) { - std::ofstream file_stream( file, std::ios::out ); - - U64 trigger_sample = mAnalyzer->GetTriggerSample(); - U32 sample_rate = mAnalyzer->GetSampleRate(); - - file_stream << "Time [s],Packet ID,MDIOClause,OP,PHYADDR,REGADDR/DEVTYPE,ADDR/DATA" << std::endl; - - U64 num_packets = GetNumPackets(); - - for( U32 packet_id=0; packet_id < num_packets; ++packet_id ) - { - - // get the frames contained in packet with index packet_id - U64 first_frame_id; - U64 last_frame_id; - GetFramesContainedInPacket( packet_id, &first_frame_id, &last_frame_id ); - - U64 frame_id = first_frame_id; - - // get MDIO_START frame to get the MDIOClause column value - Frame frame = GetFrame( frame_id ); - - char time_str[128]; - AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 ); - - // Time [s] and Packet ID column - file_stream << time_str << "," << packet_id << ","; - - if( frame.mType == MDIO_C22_START ) - { - file_stream << "22,"; - } - else if( frame.mType == MDIO_C45_START ) - { - file_stream << "45,"; - } - else - { - file_stream << ","; - } - - ++frame_id; - - if( frame_id > last_frame_id ) - { - continue; - } - - // OP frame - frame = GetFrame( frame_id ); - - switch( frame.mType ) - { - case MDIO_OP_W: file_stream << "Write,"; break; - case MDIO_OP_R: file_stream << "Read,"; break; - case MDIO_C45_OP_ADDR: file_stream << "Address,"; break; - case MDIO_C45_OP_READ_INC_ADDR: file_stream << "Read +Addr,"; break; - default: file_stream << ","; break; - } - - ++frame_id; - - if( frame_id > last_frame_id ) - { - continue; - } - - // PHYADDR frame - frame = GetFrame( frame_id ); - - if( frame.mType != MDIO_PHYADDR ) - { - file_stream << ","; - } - - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - - file_stream << number_str << ","; - - ++frame_id; - - if( frame_id > last_frame_id ) - { - continue; - } - - // REGADR or DEVTYPE frame - frame = GetFrame( frame_id ); - - char number_str2[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str2, 128 ); - - switch( frame.mType ) - { - case MDIO_C22_REGADDR: file_stream << number_str2 << ","; break; - case MDIO_C45_DEVTYPE_RESERVED: file_stream << number_str2 << "(Reserved),"; break; - case MDIO_C45_DEVTYPE_PMD_PMA: file_stream << number_str2 << "(PMD/PMA),"; break; - case MDIO_C45_DEVTYPE_WIS: file_stream << number_str2 << "(WIS),"; break; - case MDIO_C45_DEVTYPE_PCS: file_stream << number_str2 << "(PCS),"; break; - case MDIO_C45_DEVTYPE_PHY_XS: file_stream << number_str2 << "(PHY XS),"; break; - case MDIO_C45_DEVTYPE_DTE_XS: file_stream << number_str2 << "(DTE XS),"; break; - case MDIO_C45_DEVTYPE_OTHER: file_stream << number_str2 << "(Other),"; break; - default: file_stream << ","; - } - - ++frame_id; - if( frame_id > last_frame_id ) - { - continue; - } - - // TA frame - frame = GetFrame( frame_id ); - - if( frame.mType != MDIO_TA ) - { - file_stream << ","; - } - - ++frame_id; - if( frame_id > last_frame_id ) - { - continue; - } - - // MDIO_C22_DATA or MDIO_C45_ADDRDATA frame - frame = GetFrame( frame_id ); - - if( frame.mType == MDIO_C22_DATA || - frame.mType == MDIO_C45_ADDR || - frame.mType == MDIO_C45_DATA ) - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - file_stream << number_str; - } - else - { - file_stream << ","; - } - - file_stream << std::endl; - - // check for cancel and update progress - if( UpdateExportProgressAndCheckForCancel( packet_id, num_packets ) ) - { - return; - } - - } - - UpdateExportProgressAndCheckForCancel( num_packets, num_packets ); + std::ofstream file_stream( file, std::ios::out ); + + U64 trigger_sample = mAnalyzer->GetTriggerSample(); + U32 sample_rate = mAnalyzer->GetSampleRate(); + + file_stream << "Time [s],Packet ID,MDIOClause,OP,PHYADDR,REGADDR/DEVTYPE,ADDR/DATA" << std::endl; + + U64 num_packets = GetNumPackets(); + + for( U32 packet_id = 0; packet_id < num_packets; ++packet_id ) + { + // get the frames contained in packet with index packet_id + U64 first_frame_id; + U64 last_frame_id; + GetFramesContainedInPacket( packet_id, &first_frame_id, &last_frame_id ); + + U64 frame_id = first_frame_id; + + // get MDIO_START frame to get the MDIOClause column value + Frame frame = GetFrame( frame_id ); + + char time_str[ 128 ]; + AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 ); + + // Time [s] and Packet ID column + file_stream << time_str << "," << packet_id << ","; + + if( frame.mType == MDIO_C22_START ) + { + file_stream << "22,"; + } + else if( frame.mType == MDIO_C45_START ) + { + file_stream << "45,"; + } + else + { + file_stream << ","; + } + + ++frame_id; + + if( frame_id > last_frame_id ) + { + continue; + } + + // OP frame + frame = GetFrame( frame_id ); + + switch( frame.mType ) + { + case MDIO_OP_W: + file_stream << "Write,"; + break; + case MDIO_OP_R: + file_stream << "Read,"; + break; + case MDIO_C45_OP_ADDR: + file_stream << "Address,"; + break; + case MDIO_C45_OP_READ_INC_ADDR: + file_stream << "Read +Addr,"; + break; + default: + file_stream << ","; + break; + } + + ++frame_id; + + if( frame_id > last_frame_id ) + { + continue; + } + + // PHYADDR frame + frame = GetFrame( frame_id ); + + if( frame.mType != MDIO_PHYADDR ) + { + file_stream << ","; + } + + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + + file_stream << number_str << ","; + + ++frame_id; + + if( frame_id > last_frame_id ) + { + continue; + } + + // REGADR or DEVTYPE frame + frame = GetFrame( frame_id ); + + char number_str2[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str2, 128 ); + + switch( frame.mType ) + { + case MDIO_C22_REGADDR: + file_stream << number_str2 << ","; + break; + case MDIO_C45_DEVTYPE_RESERVED: + file_stream << number_str2 << "(Reserved),"; + break; + case MDIO_C45_DEVTYPE_PMD_PMA: + file_stream << number_str2 << "(PMD/PMA),"; + break; + case MDIO_C45_DEVTYPE_WIS: + file_stream << number_str2 << "(WIS),"; + break; + case MDIO_C45_DEVTYPE_PCS: + file_stream << number_str2 << "(PCS),"; + break; + case MDIO_C45_DEVTYPE_PHY_XS: + file_stream << number_str2 << "(PHY XS),"; + break; + case MDIO_C45_DEVTYPE_DTE_XS: + file_stream << number_str2 << "(DTE XS),"; + break; + case MDIO_C45_DEVTYPE_OTHER: + file_stream << number_str2 << "(Other),"; + break; + default: + file_stream << ","; + } + + ++frame_id; + if( frame_id > last_frame_id ) + { + continue; + } + + // TA frame + frame = GetFrame( frame_id ); + + if( frame.mType != MDIO_TA ) + { + file_stream << ","; + } + + ++frame_id; + if( frame_id > last_frame_id ) + { + continue; + } + + // MDIO_C22_DATA or MDIO_C45_ADDRDATA frame + frame = GetFrame( frame_id ); + + if( frame.mType == MDIO_C22_DATA || frame.mType == MDIO_C45_ADDR || frame.mType == MDIO_C45_DATA ) + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + file_stream << number_str; + } + else + { + file_stream << ","; + } + + file_stream << std::endl; + + // check for cancel and update progress + if( UpdateExportProgressAndCheckForCancel( packet_id, num_packets ) ) + { + return; + } + } + + UpdateExportProgressAndCheckForCancel( num_packets, num_packets ); } void MDIOAnalyzerResults::GenerateFrameTabularText( U64 frame_index, DisplayBase display_base ) { ClearTabularText(); - Frame frame = GetFrame( frame_index ); - - switch( frame.mType ) - { - case MDIO_C22_START: - AddTabularText( "START C", "22" ); - break; - - case MDIO_C45_START: - AddTabularText( "START C", "45" ); - break; - - case MDIO_OP_W: - AddTabularText( "OPCODE [", "Write", "]" ); - break; - - case MDIO_OP_R: - AddTabularText( "OPCODE [", "Read", "]" ); - break; - - case MDIO_C45_OP_ADDR: - AddTabularText( "OPCODE [", "Address", "]" ); - break; - - case MDIO_C45_OP_READ_INC_ADDR: - AddTabularText( "OPCODE [", "Read-Increment-Address", "]" ); - break; - - case MDIO_PHYADDR: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText( "PHY Address [", number_str, "]" ); - } - break; - - case MDIO_C22_REGADDR: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText( "Register Address [", number_str, "]" ); - } - break; - - case MDIO_C45_DEVTYPE_RESERVED: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "Reserved", "] - ", number_str); - } - break; - - case MDIO_C45_DEVTYPE_PMD_PMA: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "PMD/PMA", "] - ", number_str); - } - break; - - case MDIO_C45_DEVTYPE_WIS: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "WIS", "] - ", number_str); - } - break; - - case MDIO_C45_DEVTYPE_PCS: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "PCS", "] - ", number_str); - } - break; - case MDIO_C45_DEVTYPE_PHY_XS: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "PHY XS", "] - ", number_str); - } - break; - case MDIO_C45_DEVTYPE_DTE_XS: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "DTE XS", "] - ", number_str); - } - break; - case MDIO_C45_DEVTYPE_OTHER: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); - AddTabularText("DEVTYPE [", "Other", "] - ", number_str); - } - break; - case MDIO_TA: - if ( frame.mFlags & DISPLAY_AS_ERROR_FLAG ) - { - AddTabularText( "!Turnaround" ); - } - else - { - AddTabularText( "Turnaround" ); - } - break; - - case MDIO_C22_DATA: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - AddTabularText( "Data [", number_str, "]" ); - } - break; - - case MDIO_C45_ADDR: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - AddTabularText( "Address", " [", number_str, "]" ); - } - break; - - case MDIO_C45_DATA: - { - char number_str[128]; - AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); - AddTabularText( "Data", " [", number_str, "]" ); - } - break; - - case MDIO_UNKNOWN: - AddTabularText("!Unknown"); - break; + Frame frame = GetFrame( frame_index ); + + switch( frame.mType ) + { + case MDIO_C22_START: + AddTabularText( "START C", "22" ); + break; + + case MDIO_C45_START: + AddTabularText( "START C", "45" ); + break; + + case MDIO_OP_W: + AddTabularText( "OPCODE [", "Write", "]" ); + break; + + case MDIO_OP_R: + AddTabularText( "OPCODE [", "Read", "]" ); + break; + + case MDIO_C45_OP_ADDR: + AddTabularText( "OPCODE [", "Address", "]" ); + break; + + case MDIO_C45_OP_READ_INC_ADDR: + AddTabularText( "OPCODE [", "Read-Increment-Address", "]" ); + break; + + case MDIO_PHYADDR: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "PHY Address [", number_str, "]" ); + } + break; + + case MDIO_C22_REGADDR: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "Register Address [", number_str, "]" ); + } + break; + + case MDIO_C45_DEVTYPE_RESERVED: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "Reserved", "] - ", number_str ); + } + break; + + case MDIO_C45_DEVTYPE_PMD_PMA: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "PMD/PMA", "] - ", number_str ); + } + break; + + case MDIO_C45_DEVTYPE_WIS: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "WIS", "] - ", number_str ); + } + break; + + case MDIO_C45_DEVTYPE_PCS: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "PCS", "] - ", number_str ); + } + break; + case MDIO_C45_DEVTYPE_PHY_XS: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "PHY XS", "] - ", number_str ); + } + break; + case MDIO_C45_DEVTYPE_DTE_XS: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "DTE XS", "] - ", number_str ); + } + break; + case MDIO_C45_DEVTYPE_OTHER: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 5, number_str, 128 ); + AddTabularText( "DEVTYPE [", "Other", "] - ", number_str ); + } + break; + case MDIO_TA: + if( frame.mFlags & DISPLAY_AS_ERROR_FLAG ) + { + AddTabularText( "!Turnaround" ); + } + else + { + AddTabularText( "Turnaround" ); + } + break; + + case MDIO_C22_DATA: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + AddTabularText( "Data [", number_str, "]" ); + } + break; + + case MDIO_C45_ADDR: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + AddTabularText( "Address", " [", number_str, "]" ); + } + break; + + case MDIO_C45_DATA: + { + char number_str[ 128 ]; + AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 16, number_str, 128 ); + AddTabularText( "Data", " [", number_str, "]" ); + } + break; + case MDIO_UNKNOWN: + AddTabularText( "!Unknown" ); + break; } } void MDIOAnalyzerResults::GeneratePacketTabularText( U64 /*packet_id*/, DisplayBase /*display_base*/ ) { - ClearResultStrings(); - AddResultString( "not supported" ); + ClearResultStrings(); + AddResultString( "not supported" ); } void MDIOAnalyzerResults::GenerateTransactionTabularText( U64 /*transaction_id*/, DisplayBase /*display_base*/ ) { - ClearResultStrings(); - AddResultString( "not supported" ); + ClearResultStrings(); + AddResultString( "not supported" ); } diff --git a/src/MDIOAnalyzerResults.h b/src/MDIOAnalyzerResults.h index 9bca77d..2ca20ca 100644 --- a/src/MDIOAnalyzerResults.h +++ b/src/MDIOAnalyzerResults.h @@ -6,55 +6,62 @@ class MDIOAnalyzer; class MDIOAnalyzerSettings; -enum MDIOFrameType { MDIO_C22_START = 0, MDIO_C45_START, - MDIO_OP_W, MDIO_OP_R, MDIO_C45_OP_ADDR, MDIO_C45_OP_READ_INC_ADDR, - MDIO_PHYADDR, - MDIO_C22_REGADDR, - MDIO_C45_DEVTYPE_RESERVED, MDIO_C45_DEVTYPE_PMD_PMA, MDIO_C45_DEVTYPE_WIS, - MDIO_C45_DEVTYPE_PCS, MDIO_C45_DEVTYPE_PHY_XS, MDIO_C45_DEVTYPE_DTE_XS, MDIO_C45_DEVTYPE_OTHER, - MDIO_TA, - MDIO_C22_DATA, - MDIO_C45_ADDR, - MDIO_C45_DATA, - MDIO_UNKNOWN - }; +enum MDIOFrameType +{ + MDIO_C22_START = 0, + MDIO_C45_START, + MDIO_OP_W, + MDIO_OP_R, + MDIO_C45_OP_ADDR, + MDIO_C45_OP_READ_INC_ADDR, + MDIO_PHYADDR, + MDIO_C22_REGADDR, + MDIO_C45_DEVTYPE_RESERVED, + MDIO_C45_DEVTYPE_PMD_PMA, + MDIO_C45_DEVTYPE_WIS, + MDIO_C45_DEVTYPE_PCS, + MDIO_C45_DEVTYPE_PHY_XS, + MDIO_C45_DEVTYPE_DTE_XS, + MDIO_C45_DEVTYPE_OTHER, + MDIO_TA, + MDIO_C22_DATA, + MDIO_C45_ADDR, + MDIO_C45_DATA, + MDIO_UNKNOWN +}; class MDIOAnalyzerResults : public AnalyzerResults { -public: - MDIOAnalyzerResults( MDIOAnalyzer* analyzer, MDIOAnalyzerSettings* settings ); - virtual ~MDIOAnalyzerResults(); - - virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base ); - virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id ); - - virtual void GenerateFrameTabularText(U64 frame_index, DisplayBase display_base ); - virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base ); - virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base ); - -protected: - void GenBubbleText(U64 frame_index, DisplayBase display_base, bool tabular); - - // helper functions to generate text for each type of frame - void GenStartString(const Frame & frame, const char* clause, bool tabular); - void GenOpString(const Frame & frame, - const char* opcode_str0, const char* opcode_str1, const char* opcode_str2, - bool tabular); - void GenPhyAddrString(const Frame & frame, DisplayBase display_base, bool tabular); - void GenC22RegAddrString(const Frame & frame, DisplayBase display_base, bool tabular); - void GenC45DevTypeString(const Frame & frame, DisplayBase display_base, - const char* devtype, bool tabular); - void GenC45DevType(const Frame & frame, DisplayBase display_base, bool tabular); - void GenTAString(const Frame & frame, DisplayBase display_base, bool tabular); - void GenC22DataString(const Frame & frame, DisplayBase display_base, bool tabular); - void GenC45AddrDataString(const Frame & frame, DisplayBase display_base, - const char* str0, const char* str1, const char* str2, - bool tabular); - void GenUnknownString(bool tabular); - -protected: - MDIOAnalyzerSettings* mSettings; - MDIOAnalyzer* mAnalyzer; + public: + MDIOAnalyzerResults( MDIOAnalyzer* analyzer, MDIOAnalyzerSettings* settings ); + virtual ~MDIOAnalyzerResults(); + + virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base ); + virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id ); + + virtual void GenerateFrameTabularText( U64 frame_index, DisplayBase display_base ); + virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base ); + virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base ); + + protected: + void GenBubbleText( U64 frame_index, DisplayBase display_base, bool tabular ); + + // helper functions to generate text for each type of frame + void GenStartString( const Frame& frame, const char* clause, bool tabular ); + void GenOpString( const Frame& frame, const char* opcode_str0, const char* opcode_str1, const char* opcode_str2, bool tabular ); + void GenPhyAddrString( const Frame& frame, DisplayBase display_base, bool tabular ); + void GenC22RegAddrString( const Frame& frame, DisplayBase display_base, bool tabular ); + void GenC45DevTypeString( const Frame& frame, DisplayBase display_base, const char* devtype, bool tabular ); + void GenC45DevType( const Frame& frame, DisplayBase display_base, bool tabular ); + void GenTAString( const Frame& frame, DisplayBase display_base, bool tabular ); + void GenC22DataString( const Frame& frame, DisplayBase display_base, bool tabular ); + void GenC45AddrDataString( const Frame& frame, DisplayBase display_base, const char* str0, const char* str1, const char* str2, + bool tabular ); + void GenUnknownString( bool tabular ); + + protected: + MDIOAnalyzerSettings* mSettings; + MDIOAnalyzer* mAnalyzer; }; -#endif //MDIO_ANALYZER_RESULTS +#endif // MDIO_ANALYZER_RESULTS diff --git a/src/MDIOAnalyzerSettings.cpp b/src/MDIOAnalyzerSettings.cpp index c6e571b..5cb641b 100644 --- a/src/MDIOAnalyzerSettings.cpp +++ b/src/MDIOAnalyzerSettings.cpp @@ -1,28 +1,26 @@ #include "MDIOAnalyzerSettings.h" #include -MDIOAnalyzerSettings::MDIOAnalyzerSettings() -: mMdioChannel( UNDEFINED_CHANNEL ), - mMdcChannel( UNDEFINED_CHANNEL ) +MDIOAnalyzerSettings::MDIOAnalyzerSettings() : mMdioChannel( UNDEFINED_CHANNEL ), mMdcChannel( UNDEFINED_CHANNEL ) { - mMdioChannelInterface.reset( new AnalyzerSettingInterfaceChannel() ); - mMdioChannelInterface->SetTitleAndTooltip( "MDIO", "MDIO data bus" ); - mMdioChannelInterface->SetChannel( mMdioChannel ); - - mMdcChannelInterface.reset( new AnalyzerSettingInterfaceChannel() ); - mMdcChannelInterface->SetTitleAndTooltip( "MDC", "MDIO clock line " ); - mMdcChannelInterface->SetChannel( mMdcChannel ); - - AddInterface( mMdioChannelInterface.get() ); - AddInterface( mMdcChannelInterface.get() ); - - AddExportOption( 0, "Export as text/csv file" ); - AddExportExtension( 0, "text", "txt" ); - AddExportExtension( 0, "csv", "csv" ); - - ClearChannels(); - AddChannel( mMdioChannel, "MDIO", false ); - AddChannel( mMdcChannel, "MDC", false ); + mMdioChannelInterface.reset( new AnalyzerSettingInterfaceChannel() ); + mMdioChannelInterface->SetTitleAndTooltip( "MDIO", "MDIO data bus" ); + mMdioChannelInterface->SetChannel( mMdioChannel ); + + mMdcChannelInterface.reset( new AnalyzerSettingInterfaceChannel() ); + mMdcChannelInterface->SetTitleAndTooltip( "MDC", "MDIO clock line " ); + mMdcChannelInterface->SetChannel( mMdcChannel ); + + AddInterface( mMdioChannelInterface.get() ); + AddInterface( mMdcChannelInterface.get() ); + + AddExportOption( 0, "Export as text/csv file" ); + AddExportExtension( 0, "text", "txt" ); + AddExportExtension( 0, "csv", "csv" ); + + ClearChannels(); + AddChannel( mMdioChannel, "MDIO", false ); + AddChannel( mMdcChannel, "MDC", false ); } MDIOAnalyzerSettings::~MDIOAnalyzerSettings() @@ -31,49 +29,49 @@ MDIOAnalyzerSettings::~MDIOAnalyzerSettings() bool MDIOAnalyzerSettings::SetSettingsFromInterfaces() { - if( mMdioChannelInterface->GetChannel() == mMdcChannelInterface->GetChannel() ) - { - SetErrorText( "MDIO and MDC can't be assigned to the same input." ); - return false; - } + if( mMdioChannelInterface->GetChannel() == mMdcChannelInterface->GetChannel() ) + { + SetErrorText( "MDIO and MDC can't be assigned to the same input." ); + return false; + } - mMdioChannel = mMdioChannelInterface->GetChannel(); - mMdcChannel = mMdcChannelInterface->GetChannel(); + mMdioChannel = mMdioChannelInterface->GetChannel(); + mMdcChannel = mMdcChannelInterface->GetChannel(); - ClearChannels(); - AddChannel( mMdioChannel, "MDIO", true ); - AddChannel( mMdcChannel, "MDC", true ); + ClearChannels(); + AddChannel( mMdioChannel, "MDIO", true ); + AddChannel( mMdcChannel, "MDC", true ); - return true; + return true; } void MDIOAnalyzerSettings::UpdateInterfacesFromSettings() { - mMdioChannelInterface->SetChannel( mMdioChannel ); - mMdcChannelInterface->SetChannel( mMdcChannel ); + mMdioChannelInterface->SetChannel( mMdioChannel ); + mMdcChannelInterface->SetChannel( mMdcChannel ); } void MDIOAnalyzerSettings::LoadSettings( const char* settings ) { - SimpleArchive text_archive; - text_archive.SetString( settings ); + SimpleArchive text_archive; + text_archive.SetString( settings ); - text_archive >> mMdioChannel; - text_archive >> mMdcChannel; + text_archive >> mMdioChannel; + text_archive >> mMdcChannel; - ClearChannels(); - AddChannel( mMdioChannel, "MDIO", true ); - AddChannel( mMdcChannel, "MDC", true ); + ClearChannels(); + AddChannel( mMdioChannel, "MDIO", true ); + AddChannel( mMdcChannel, "MDC", true ); - UpdateInterfacesFromSettings(); + UpdateInterfacesFromSettings(); } const char* MDIOAnalyzerSettings::SaveSettings() { - SimpleArchive text_archive; + SimpleArchive text_archive; - text_archive << mMdioChannel; - text_archive << mMdcChannel; + text_archive << mMdioChannel; + text_archive << mMdcChannel; - return SetReturnString( text_archive.GetString() ); + return SetReturnString( text_archive.GetString() ); } diff --git a/src/MDIOAnalyzerSettings.h b/src/MDIOAnalyzerSettings.h index 7d80941..0793ceb 100644 --- a/src/MDIOAnalyzerSettings.h +++ b/src/MDIOAnalyzerSettings.h @@ -5,27 +5,48 @@ #include // enums for the values in the different MDIO frames: START, OP, DEVTYPE -enum MdioStart { C45_START = 0, C22_START }; -enum MdioOpCode { C45_ADDRESS = 0, C45_WRITE = 1, C22_WRITE = 1,C22_READ = 2, C45_READ_AND_ADDR = 2, C45_READ = 3 }; -enum MdioDevType { DEV_RESERVED = 0, DEV_PMD_PMA, DEV_WIS, DEV_PCS, DEV_PHY_XS, DEV_DTE_XS, DEV_OTHER }; +enum MdioStart +{ + C45_START = 0, + C22_START +}; +enum MdioOpCode +{ + C45_ADDRESS = 0, + C45_WRITE = 1, + C22_WRITE = 1, + C22_READ = 2, + C45_READ_AND_ADDR = 2, + C45_READ = 3 +}; +enum MdioDevType +{ + DEV_RESERVED = 0, + DEV_PMD_PMA, + DEV_WIS, + DEV_PCS, + DEV_PHY_XS, + DEV_DTE_XS, + DEV_OTHER +}; class MDIOAnalyzerSettings : public AnalyzerSettings { -public: - MDIOAnalyzerSettings(); - virtual ~MDIOAnalyzerSettings(); + public: + MDIOAnalyzerSettings(); + virtual ~MDIOAnalyzerSettings(); - virtual bool SetSettingsFromInterfaces(); - void UpdateInterfacesFromSettings(); - virtual void LoadSettings( const char* settings ); - virtual const char* SaveSettings(); + virtual bool SetSettingsFromInterfaces(); + void UpdateInterfacesFromSettings(); + virtual void LoadSettings( const char* settings ); + virtual const char* SaveSettings(); - Channel mMdioChannel; - Channel mMdcChannel; + Channel mMdioChannel; + Channel mMdcChannel; -protected: - std::auto_ptr< AnalyzerSettingInterfaceChannel > mMdioChannelInterface; - std::auto_ptr< AnalyzerSettingInterfaceChannel > mMdcChannelInterface; + protected: + std::auto_ptr mMdioChannelInterface; + std::auto_ptr mMdcChannelInterface; }; -#endif //MDIO_ANALYZER_SETTINGS +#endif // MDIO_ANALYZER_SETTINGS diff --git a/src/MDIOSimulationDataGenerator.cpp b/src/MDIOSimulationDataGenerator.cpp index 870a354..5c32ce0 100644 --- a/src/MDIOSimulationDataGenerator.cpp +++ b/src/MDIOSimulationDataGenerator.cpp @@ -10,237 +10,229 @@ MDIOSimulationDataGenerator::~MDIOSimulationDataGenerator() void MDIOSimulationDataGenerator::Initialize( U32 simulation_sample_rate, MDIOAnalyzerSettings* settings ) { - mSimulationSampleRateHz = simulation_sample_rate; - mSettings = settings; + mSimulationSampleRateHz = simulation_sample_rate; + mSettings = settings; - // 1.7 Mhz is a commonly used frequency - mClockGenerator.Init( 1700000*2, mSimulationSampleRateHz ); + // 1.7 Mhz is a commonly used frequency + mClockGenerator.Init( 1700000 * 2, mSimulationSampleRateHz ); - // Set the simulation channels - mMdio = mSimulationChannels.Add( mSettings->mMdioChannel, mSimulationSampleRateHz, BIT_HIGH ); - mMdc = mSimulationChannels.Add( mSettings->mMdcChannel, mSimulationSampleRateHz, BIT_LOW ); + // Set the simulation channels + mMdio = mSimulationChannels.Add( mSettings->mMdioChannel, mSimulationSampleRateHz, BIT_HIGH ); + mMdc = mSimulationChannels.Add( mSettings->mMdcChannel, mSimulationSampleRateHz, BIT_LOW ); - // start the simulation with 10 periods of idle - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 20.0 ) ); + // start the simulation with 10 periods of idle + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 20.0 ) ); } U32 MDIOSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_requested, U32 sample_rate, - SimulationChannelDescriptor** simulation_channels ) + SimulationChannelDescriptor** simulation_channels ) { - U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, - sample_rate, - mSimulationSampleRateHz ); + U64 adjusted_largest_sample_requested = + AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, sample_rate, mSimulationSampleRateHz ); - MdioOpCode opcodeValues[3] = { C45_WRITE, C22_READ, C45_READ }; // address - U8 opIndex = 0; + MdioOpCode opcodeValues[ 3 ] = { C45_WRITE, C22_READ, C45_READ }; // address + U8 opIndex = 0; - MdioDevType devTypeValues[7] = { DEV_RESERVED, DEV_PMD_PMA, DEV_WIS, DEV_PCS, DEV_PHY_XS, DEV_DTE_XS, DEV_OTHER }; - U8 devTypeIndex = 0; + MdioDevType devTypeValues[ 7 ] = { DEV_RESERVED, DEV_PMD_PMA, DEV_WIS, DEV_PCS, DEV_PHY_XS, DEV_DTE_XS, DEV_OTHER }; + U8 devTypeIndex = 0; - U16 regAddrValue = 0; - U8 regAddrValue5b = 0; + U16 regAddrValue = 0; + U8 regAddrValue5b = 0; - U16 dataValueC22 = 0; - U16 dataValueC45 = 0; - U8 phyAddressValue = 0; + U16 dataValueC22 = 0; + U16 dataValueC45 = 0; + U8 phyAddressValue = 0; - while( mMdc->GetCurrentSampleNumber() < adjusted_largest_sample_requested ) - { + while( mMdc->GetCurrentSampleNumber() < adjusted_largest_sample_requested ) + { + CreateMdioC45Transaction( opcodeValues[ opIndex % 3 ], // OpCode + phyAddressValue++, // PHY Address + devTypeValues[ devTypeIndex++ % 7 ], // DevType + regAddrValue++, // Register Address + dataValueC45++ // Data + ); - CreateMdioC45Transaction( opcodeValues[opIndex % 3], // OpCode - phyAddressValue++, // PHY Address - devTypeValues[devTypeIndex++ % 7], // DevType - regAddrValue++, // Register Address - dataValueC45++ // Data - ); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 10.0 ) ); // insert 5 periods of idle - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 10.0 ) ); //insert 5 periods of idle + CreateMdioC22Transaction( opcodeValues[ opIndex++ % 3 ], // OpCode + phyAddressValue++, // PHY Address + regAddrValue5b++, // Register Address + dataValueC22++ // Data + ); - CreateMdioC22Transaction( opcodeValues[opIndex++ % 3], // OpCode - phyAddressValue++, // PHY Address - regAddrValue5b++, // Register Address - dataValueC22++ // Data - ); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 20.0 ) ); // insert 10 periods of idle + } - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 20.0 ) ); //insert 10 periods of idle - - } - - *simulation_channels = mSimulationChannels.GetArray(); - return mSimulationChannels.GetCount(); + *simulation_channels = mSimulationChannels.GetArray(); + return mSimulationChannels.GetCount(); } void MDIOSimulationDataGenerator::CreateMdioC22Transaction( MdioOpCode opCode, U8 phyAddress, U8 regAddress, U16 data ) { - // A Clause 22 transaction consists of ONE packet containing a 5 bit register address, and a 16 bit data - CreateStart(C22_START); - CreateOpCode(opCode); - CreatePhyAddress(phyAddress); - CreateRegAddress(regAddress); - CreateTurnAround(IsReadOperation(opCode)); - CreateData(data); + // A Clause 22 transaction consists of ONE packet containing a 5 bit register address, and a 16 bit data + CreateStart( C22_START ); + CreateOpCode( opCode ); + CreatePhyAddress( phyAddress ); + CreateRegAddress( regAddress ); + CreateTurnAround( IsReadOperation( opCode ) ); + CreateData( data ); } -void MDIOSimulationDataGenerator::CreateMdioC45Transaction( MdioOpCode opCode, U8 phyAddress, - MdioDevType devType, U16 regAddress, U16 data ) +void MDIOSimulationDataGenerator::CreateMdioC45Transaction( MdioOpCode opCode, U8 phyAddress, MdioDevType devType, U16 regAddress, + U16 data ) { - // A Clause 45 transaction consists of TWO packets. - // The first frame contains a 16 bit register address, the second has the 16 bit data + // A Clause 45 transaction consists of TWO packets. + // The first frame contains a 16 bit register address, the second has the 16 bit data - // First packet - CreateStart(C45_START); - CreateOpCode(C45_ADDRESS); - CreatePhyAddress(phyAddress); - CreateDevType(devType); - CreateTurnAround(IsReadOperation(opCode)); - CreateAddressOrData(regAddress); + // First packet + CreateStart( C45_START ); + CreateOpCode( C45_ADDRESS ); + CreatePhyAddress( phyAddress ); + CreateDevType( devType ); + CreateTurnAround( IsReadOperation( opCode ) ); + CreateAddressOrData( regAddress ); - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 2.0 ) ); //insert 1 periods of idle + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 2.0 ) ); // insert 1 periods of idle - // Second packet - CreateStart(C45_START); - CreateOpCode(opCode); - CreatePhyAddress(phyAddress); - CreateDevType(devType); - CreateTurnAround(IsReadOperation(opCode)); - CreateAddressOrData(data); + // Second packet + CreateStart( C45_START ); + CreateOpCode( opCode ); + CreatePhyAddress( phyAddress ); + CreateDevType( devType ); + CreateTurnAround( IsReadOperation( opCode ) ); + CreateAddressOrData( data ); } bool MDIOSimulationDataGenerator::IsReadOperation( MdioOpCode opcode ) { - return ( opcode == C22_READ || - opcode == C45_READ_AND_ADDR || - opcode == C45_READ ); + return ( opcode == C22_READ || opcode == C45_READ_AND_ADDR || opcode == C45_READ ); } void MDIOSimulationDataGenerator::CreateStart( MdioStart start ) { - if( mMdc->GetCurrentBitState() == BIT_HIGH ) - { - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); - mMdc->Transition(); - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - } - - BitExtractor bit_extractor( start, AnalyzerEnums::MsbFirst, 2 ); + if( mMdc->GetCurrentBitState() == BIT_HIGH ) + { + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); + mMdc->Transition(); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + } - for( U32 i=0; i<2; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } + BitExtractor bit_extractor( start, AnalyzerEnums::MsbFirst, 2 ); + for( U32 i = 0; i < 2; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } } void MDIOSimulationDataGenerator::CreateOpCode( MdioOpCode opCode ) { - BitExtractor bit_extractor( opCode, AnalyzerEnums::MsbFirst, 2 ); + BitExtractor bit_extractor( opCode, AnalyzerEnums::MsbFirst, 2 ); - for( U32 i=0; i<2; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } + for( U32 i = 0; i < 2; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } } void MDIOSimulationDataGenerator::CreatePhyAddress( U8 address ) { - BitExtractor bit_extractor( address, AnalyzerEnums::MsbFirst, 5 ); + BitExtractor bit_extractor( address, AnalyzerEnums::MsbFirst, 5 ); - for( U32 i=0; i<5; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } + for( U32 i = 0; i < 5; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } } void MDIOSimulationDataGenerator::CreateRegAddress( U8 address ) { + BitExtractor bit_extractor( address, AnalyzerEnums::MsbFirst, 5 ); - BitExtractor bit_extractor( address, AnalyzerEnums::MsbFirst, 5 ); - - for( U32 i=0; i<5; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } - + for( U32 i = 0; i < 5; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } } void MDIOSimulationDataGenerator::CreateDevType( MdioDevType devType ) { - BitExtractor bit_extractor( devType, AnalyzerEnums::MsbFirst, 5 ); + BitExtractor bit_extractor( devType, AnalyzerEnums::MsbFirst, 5 ); - for( U32 i=0; i<5; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } + for( U32 i = 0; i < 5; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } } void MDIOSimulationDataGenerator::CreateTurnAround( bool isReadOperation ) { - if( isReadOperation ) - { - CreateTAForRead(); - } - else - { - CreateTAForWrite(); - } + if( isReadOperation ) + { + CreateTAForRead(); + } + else + { + CreateTAForWrite(); + } } void MDIOSimulationDataGenerator::CreateTAForRead() { - mMdio->TransitionIfNeeded(BIT_HIGH); - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->Transition(); // MDC posedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdio->Transition(); // MDIO line goes down (by the slave) - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->Transition(); // MDC negedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); - mMdc->Transition(); // MDC posedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdio->TransitionIfNeeded( BIT_HIGH ); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->Transition(); // MDC posedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdio->Transition(); // MDIO line goes down (by the slave) + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->Transition(); // MDC negedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); + mMdc->Transition(); // MDC posedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); } void MDIOSimulationDataGenerator::CreateTAForWrite() { - mMdio->TransitionIfNeeded(BIT_HIGH); - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->Transition(); // MDC posedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); - mMdc->Transition(); // MDC negedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdio->Transition(); // value 0 - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->Transition(); // MDC posedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); - mMdc->Transition(); // MDC negedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdio->TransitionIfNeeded( BIT_HIGH ); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->Transition(); // MDC posedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); + mMdc->Transition(); // MDC negedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdio->Transition(); // value 0 + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->Transition(); // MDC posedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); + mMdc->Transition(); // MDC negedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); } -void MDIOSimulationDataGenerator::CreateData(U16 data) +void MDIOSimulationDataGenerator::CreateData( U16 data ) { - BitExtractor bit_extractor( data, AnalyzerEnums::MsbFirst, 16 ); + BitExtractor bit_extractor( data, AnalyzerEnums::MsbFirst, 16 ); - for( U32 i=0; i<16; i++ ) - { - CreateBit( bit_extractor.GetNextBit() ); - } + for( U32 i = 0; i < 16; i++ ) + { + CreateBit( bit_extractor.GetNextBit() ); + } - mMdio->TransitionIfNeeded( BIT_HIGH ); // Release the bus (normally pulled up) + mMdio->TransitionIfNeeded( BIT_HIGH ); // Release the bus (normally pulled up) - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->TransitionIfNeeded( BIT_LOW ); // clk must remain low on idle + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->TransitionIfNeeded( BIT_LOW ); // clk must remain low on idle } -void MDIOSimulationDataGenerator::CreateAddressOrData(U16 data) +void MDIOSimulationDataGenerator::CreateAddressOrData( U16 data ) { - CreateData(data); + CreateData( data ); } void MDIOSimulationDataGenerator::CreateBit( BitState bit_state ) { - mMdio->TransitionIfNeeded( bit_state ); - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); - mMdc->Transition(); // MDC posedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); - mMdc->Transition(); // MDC negedge - mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdio->TransitionIfNeeded( bit_state ); + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); + mMdc->Transition(); // MDC posedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 1.0 ) ); + mMdc->Transition(); // MDC negedge + mSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 0.5 ) ); } diff --git a/src/MDIOSimulationDataGenerator.h b/src/MDIOSimulationDataGenerator.h index 5d875d2..aa86409 100644 --- a/src/MDIOSimulationDataGenerator.h +++ b/src/MDIOSimulationDataGenerator.h @@ -10,50 +10,48 @@ class MDIOAnalyzerSettings; class MDIOSimulationDataGenerator { -public: - MDIOSimulationDataGenerator(); - ~MDIOSimulationDataGenerator(); - - void Initialize( U32 simulation_sample_rate, MDIOAnalyzerSettings* settings ); - U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, - SimulationChannelDescriptor** simulation_channel ); - -protected: - MDIOAnalyzerSettings* mSettings; - U32 mSimulationSampleRateHz; - -protected: - // Helper functions to create MDIO Clause 22 and Clause 45 transactions - void CreateMdioC22Transaction( MdioOpCode OpCode, U8 phyAddress, U8 regAddress, U16 data ); - void CreateMdioC45Transaction( MdioOpCode opCode, U8 phyAddress, - MdioDevType devType, U16 regAddress, U16 data ); - - // Helper functions for frames creation - void CreateStart( MdioStart start ); // 2 bits: 01 for Clause 22, 00 for Clause 45 - void CreateOpCode( MdioOpCode opCode ); // 2 bits - void CreatePhyAddress( U8 address ); // 5 bits - void CreateTurnAround( bool isReadOperation ); // 2 bits: Turnaround time to change bus ownership from STA to MMD if required - - // Clause 22 specific frames - void CreateRegAddress( U8 address ); // 5 bits (used on Clause 22) - void CreateData( U16 data ); // 16 bits (used on Clause 22) - - // Clause 45 specific frames - void CreateDevType( MdioDevType devType ); // 5 bits (used on Clause 45) - void CreateAddressOrData( U16 data ); // 16 bits (used on Clause 45) - - void CreateTAForRead(); - void CreateTAForWrite(); - - void CreateBit( BitState bit_state ); - - bool IsReadOperation( MdioOpCode opcode ); - -protected: - ClockGenerator mClockGenerator; - - SimulationChannelDescriptorGroup mSimulationChannels; - SimulationChannelDescriptor *mMdio; - SimulationChannelDescriptor *mMdc; + public: + MDIOSimulationDataGenerator(); + ~MDIOSimulationDataGenerator(); + + void Initialize( U32 simulation_sample_rate, MDIOAnalyzerSettings* settings ); + U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel ); + + protected: + MDIOAnalyzerSettings* mSettings; + U32 mSimulationSampleRateHz; + + protected: + // Helper functions to create MDIO Clause 22 and Clause 45 transactions + void CreateMdioC22Transaction( MdioOpCode OpCode, U8 phyAddress, U8 regAddress, U16 data ); + void CreateMdioC45Transaction( MdioOpCode opCode, U8 phyAddress, MdioDevType devType, U16 regAddress, U16 data ); + + // Helper functions for frames creation + void CreateStart( MdioStart start ); // 2 bits: 01 for Clause 22, 00 for Clause 45 + void CreateOpCode( MdioOpCode opCode ); // 2 bits + void CreatePhyAddress( U8 address ); // 5 bits + void CreateTurnAround( bool isReadOperation ); // 2 bits: Turnaround time to change bus ownership from STA to MMD if required + + // Clause 22 specific frames + void CreateRegAddress( U8 address ); // 5 bits (used on Clause 22) + void CreateData( U16 data ); // 16 bits (used on Clause 22) + + // Clause 45 specific frames + void CreateDevType( MdioDevType devType ); // 5 bits (used on Clause 45) + void CreateAddressOrData( U16 data ); // 16 bits (used on Clause 45) + + void CreateTAForRead(); + void CreateTAForWrite(); + + void CreateBit( BitState bit_state ); + + bool IsReadOperation( MdioOpCode opcode ); + + protected: + ClockGenerator mClockGenerator; + + SimulationChannelDescriptorGroup mSimulationChannels; + SimulationChannelDescriptor* mMdio; + SimulationChannelDescriptor* mMdc; }; -#endif //MDIO_SIMULATION_DATA_GENERATOR +#endif // MDIO_SIMULATION_DATA_GENERATOR