Skip to content

init branch develop#1

Open
BIGWJZ wants to merge 69 commits into
mainfrom
develop
Open

init branch develop#1
BIGWJZ wants to merge 69 commits into
mainfrom
develop

Conversation

@BIGWJZ

@BIGWJZ BIGWJZ commented Jul 4, 2024

Copy link
Copy Markdown
Collaborator
  1. types definition in src/pcieTypes.bsv & src/dmaTypes.bsv
  2. a test case of AXI-Stream interface

Comment thread src/DmaTypes.bsv Outdated
Comment thread src/DmaTypes.bsv Outdated
Comment thread src/PcieTypes.bsv Outdated
Comment thread src/PcieTypes.bsv Outdated
Comment thread src/PcieTypes.bsv Outdated
Comment thread test/TestAxiStream.bsv Outdated
Comment thread test/TestAxiStream.bsv Outdated
Comment thread test/TestAxiStream.bsv Outdated
Comment thread test/TestAxiStream.bsv Outdated

endmodule

module mkTbAxisWire(AxisFifo#(keepWidth, usrWidth) ifc);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can this module be replaced by mkConnection ?

@BIGWJZ BIGWJZ Jul 14, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It can be replaced. In fact, I planned to remove TestAxiStream because the AXIS interface already has a testbench in the blue-wrapper.

Comment thread src/DmaTypes.bsv Outdated
@BIGWJZ BIGWJZ closed this Jul 4, 2024
@BIGWJZ BIGWJZ reopened this Jul 4, 2024
Comment thread src/PcieTypes.bsv Outdated
Comment thread src/PcieTypes.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
inputFifo.deq;
let offset = getOffSet(request);
// firstChunkLen = offset % PCIE_TLP_BYTES
DmaMemAddr firstLen = zeroExtend(offset[valueOf(PCIE_TLP_BYTES_WIDTH)-1:0]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you have to read the PG213 to find out how to get the Max Payload Size(MPS) and Max Read Request Size(MRRS), those value is not const so you should do some refacrtor.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

MPS&MRRS are passed in the Configuration Status Interface Port . They should be parameters of my module.
image

image

Comment thread test/TestDmaCore.bsv Outdated
Comment thread test/TestDmaCore.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
DmaMemAddr offset = zeroExtend(fromInteger(valueOf(BUS_BOUNDARY)) - pack(request.startAddr[BUS_BOUNDARY_WIDTH-1:0]));
return offset;
// 4096 - startAddr % 4096
Bit#(BUS_BOUNDARY_WIDTH) remainder = truncate(request.startAddr);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bit#(BUS_BOUNDARY_WIDTH) has occured more than once, so use typedef to define a new type.
Duplicated code is a kind of bad smell in your codebase

Comment thread src/DmaRequestCore.bsv Outdated
function DmaMemAddr getOffset(DmaRequestFrame request);
DmaMemAddr offset = zeroExtend(fromInteger(valueOf(BUS_BOUNDARY)) - pack(request.startAddr[BUS_BOUNDARY_WIDTH-1:0]));
return offset;
// 4096 - startAddr % 4096

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

4096 is bus boundary, not tlp boundary. are you massing them up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Here, the calculated offset is relative to BUS_BOUNDARY. The offset will be sliced to PCIE_TLP_BYES in the getFirstChunkLen rule.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there any need to split by BUS_BOUNDARY? If you split by PCIE_TLP_BYES , since PCIE_TLP_BYES <= BUS_BOUNDARY, any slice that aligned to PCIE_TLP_BYES won't cross BUS_BOUNDARY.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right. I have modfied.

Comment thread src/DmaRequestCore.bsv Outdated
end
end else begin
if (isSplittingReg) begin // !isFirst
if (totalLenRemainReg <= fromInteger(valueOf(PCIE_TLP_BYTES))) begin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In a previous comment, I have mentioned that the TLP size is a variable, not a const. This is a very important point. You must fix this issue before moving on.

Comment thread test/TestDmaCore.bsv Outdated
endrule

rule testFinish ;
if (testCntReg == fromInteger(valueOf(TEST_NUM))) $finish();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't write in one line.

@myrfy001 myrfy001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the TLP size is a variable, not a const

Comment thread src/DmaRequestCore.bsv Outdated
Comment thread src/DmaRequestCore.bsv Outdated
typedef TLog#(DEFAULT_TLP_SIZE) DEFAULT_TLP_SIZE_WIDTH;
typedef 3 PCIE_TLP_SIZE_SETTING_WIDTH;
typedef Bit#(PCIE_TLP_SIZE_SETTING_WIDTH) PcieTlpSizeSetting;
typedef enum {DMA_RX, DMA_TX} TRXDirection deriving(Bits, Eq);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do not write in one line.

Comment thread src/StreamUtils.bsv Outdated
endfunction

// Concat two DataStream frames into one. StreamA.isLast must be True, otherwise the function will return a empty frame to end the stream.
function Tuple3#(DataStream, DataStream, DataBytePtr) getConcatStream (DataStream streamA, DataStream streamB, DataBytePtr bytePtrA, DataBytePtr bytePtrB);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread src/DmaTypes.bsv Outdated
} DmaCsrFrame deriving(Bits, Bounded, Eq, FShow);

typedef enum {
DMA_RX, DMA_TX

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

new line

Comment thread src/DmaTypes.bsv Outdated

typedef enum {
DMA_RX, DMA_TX
} TRXDirection deriving(Bits, Eq);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggest you deriving FShow whenever possible. It helps print debug info.

Comment thread src/StreamUtils.bsv Outdated
return tuple3(concatStream, remainStream, remainBytePtr);
endfunction

function Action showDataStream (DataStream stream);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You should make DataStreamderiving FShow, and you can simply display it anyware.

And if you insist on using showDataStream , then you may use it many place in your codebase. Why put it in this file?

@BIGWJZ BIGWJZ Jul 14, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did not notice Fshow before. I will replace showDataStream funciton with it.

Comment thread src/StreamUtils.bsv Outdated
endaction;
endfunction

function Action checkDataStream (DataStream stream, String name);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The same as above, it's a util function, right?

Comment thread src/StreamUtils.bsv Outdated
ByteEn concatByteEnA = streamA.byteEn;

// Fill the high bytes by streamB data
Data concatDataB = streamB.data << bitPtrA;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please align them to make the code pretty. I know there are a lot of code to change, but if you make it a habbit, then you will write beautiful code in the future.

    Data     concatDataB     = streamB.data << bitPtrA;
    ByteEn   concatByteEnB   = streamB.byteEn << bytePtrA;
    Data     concatData      = concatDataA | concatDataB;
    ByteEn   concatByteEn    = concatByteEnA | concatByteEnB;

Comment thread src/StreamUtils.bsv Outdated
FIFOF#(DataStream) outputFifo <- mkFIFOF;

FIFOF#(StreamWithPtr) prepareFifoA <- mkFIFOF;
FIFOF#(StreamWithPtr) prepareFifoB <- mkFIFOF;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The above 5 lines of code looks good.

you may ask why we need to make code pretty. In fact, it's not a problem of pretty or not, but aligned code can make reviewer's life easy. When you will review a lot of code, you will know what it feels like. For better aligned code, you can glimpse the code and won't think much of it, if the code is badly aligned, you brain will take extra effort to "decode" the code you are reading, which will make the reviewer tired for a lot of code to review.

For example, we do not allow to write code inline, and force you to write each element in a new line in an enum or struct. This is because when you are reviewing, your eyes will first look top down, trying to find the boundary of a piece of code. For an if statement, if you write like:

if () begin
    // xxxxx
end
else begin
    // xxxxx
end

you will quickly get the boundary and with a simple glimpse you know the if statement has a else branch. But if you write

if () begin
    // xxxxx
end else begin
    // xxxxx
end

your eyes have to move right a little to find that there is a else statement. This is extra work for your brain.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Understand. I will pay attention to the code format.

Comment thread src/PcieAdapter.bsv Outdated
// Dma To Adapter DataStreams
interface Vector#(DMA_PATH_NUM, FifoIn#(DataStream)) dmaDataFifoIn;
interface Vector#(DMA_PATH_NUM, FifoIn#(SideBandByteEn)) dmaSideBandFifoIn;
// Adapter To Dma StraddleStreams, which may contains 2 TLP

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for different group of interface, add a line of space here will be better.

Comment thread src/PcieAdapter.bsv Outdated
Reg#(Bool) roundRobinReg <- mkReg(False);

function Bool hasStraddleSpace(DataStream sdStream);
return !unpack(sdStream.byteEn[valueOf(STRADDLE_THRESH_BYTE_WIDTH)]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there are functions called msb and lsb to simplify this line of code.

Comment thread src/PcieAdapter.bsv Outdated
endfunction

function Bool isValidShiftStream(DataStream shiftStream);
Bool valid = !unpack(shiftStream.byteEn[0]) && unpack(shiftStream.byteEn[valueOf(STRADDLE_THRESH_BYTE_WIDTH)]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The same as above.


function RawPcieAxiStreamMaster#(usrWidth) convertRawBusToRawPcieAxiStreamMaster(
RawBusMaster#(PcieAxiStream#(usrWidth)) rawBus
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

pay attention to align

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants