-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init branch develop #1
base: main
Are you sure you want to change the base?
Conversation
BIGWJZ
commented
Jul 4, 2024
- types definition in src/pcieTypes.bsv & src/dmaTypes.bsv
- a test case of AXI-Stream interface
test/TestAxiStream.bsv
Outdated
|
||
endmodule | ||
|
||
module mkTbAxisWire(AxisFifo#(keepWidth, usrWidth) ifc); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
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]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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
src/DmaRequestCore.bsv
Outdated
return (highIdx > lowIdx); | ||
endfunction | ||
|
||
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/DmaRequestCore.bsv
Outdated
end | ||
end else begin | ||
if (isSplittingReg) begin // !isFirst | ||
if (totalLenRemainReg <= fromInteger(valueOf(PCIE_TLP_BYTES))) begin |
There was a problem hiding this comment.
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.
test/TestDmaCore.bsv
Outdated
endrule | ||
|
||
rule testFinish ; | ||
if (testCntReg == fromInteger(valueOf(TEST_NUM))) $finish(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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); |
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do defensive coding. Add an assert here since you have requirements for input params.
It will save you from endless debugging.
see
and
src/DmaTypes.bsv
Outdated
@@ -27,12 +21,16 @@ typedef struct { | |||
DMACsrValue value; | |||
} DmaCsrFrame deriving(Bits, Bounded, Eq, FShow); | |||
|
|||
typedef enum { | |||
DMA_RX, DMA_TX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line
src/DmaTypes.bsv
Outdated
@@ -27,12 +21,16 @@ typedef struct { | |||
DMACsrValue value; | |||
} DmaCsrFrame deriving(Bits, Bounded, Eq, FShow); | |||
|
|||
typedef enum { | |||
DMA_RX, DMA_TX | |||
} TRXDirection deriving(Bits, Eq); |
There was a problem hiding this comment.
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.
src/StreamUtils.bsv
Outdated
return tuple3(concatStream, remainStream, remainBytePtr); | ||
endfunction | ||
|
||
function Action showDataStream (DataStream stream); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/StreamUtils.bsv
Outdated
endaction; | ||
endfunction | ||
|
||
function Action checkDataStream (DataStream stream, String name); |
There was a problem hiding this comment.
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?
src/StreamUtils.bsv
Outdated
ByteEn concatByteEnA = streamA.byteEn; | ||
|
||
// Fill the high bytes by streamB data | ||
Data concatDataB = streamB.data << bitPtrA; |
There was a problem hiding this comment.
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;
src/StreamUtils.bsv
Outdated
FIFOF#(DataStream) outputFifo <- mkFIFOF; | ||
|
||
FIFOF#(StreamWithPtr) prepareFifoA <- mkFIFOF; | ||
FIFOF#(StreamWithPtr) prepareFifoB <- mkFIFOF; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
backend/verilog.tar
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this file, and make sure it doesn't go into git commit history.
Reorganize DmaC2HPipe and PCIe adapter interfaces
typedef 64 RQ_DESCRIPTOR_WIDTH; | ||
typedef TDiv#(TSub#(PCIE_AXIS_DATA_WIDTH, RQ_DESCRIPTOR_WIDTH), DWORD_WIDTH) MAX_DWORD_CNT_OF_FIRST; | ||
|
||
typedef Bit#(1) ReserveBit1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Reserved
package from std lib to represent reserved values.
Pass cocotb read tb Pass single path cocotb test
// 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 |
There was a problem hiding this comment.
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.
Reg#(Bool) roundRobinReg <- mkReg(False); | ||
|
||
function Bool hasStraddleSpace(DataStream sdStream); | ||
return !unpack(sdStream.byteEn[valueOf(STRADDLE_THRESH_BYTE_WIDTH)]); |
There was a problem hiding this comment.
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.
endfunction | ||
|
||
function Bool isValidShiftStream(DataStream shiftStream); | ||
Bool valid = !unpack(shiftStream.byteEn[0]) && unpack(shiftStream.byteEn[valueOf(STRADDLE_THRESH_BYTE_WIDTH)]); |
There was a problem hiding this comment.
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 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pay attention to align