Skip to content

Explicit packing of Command/Status #57

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions include/hlslib/xilinx/Axi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ struct Command {
Command(decltype(address) const &_address, decltype(length) const &_length)
: length(_length), address(_address) {}
Command() : length(0), address(0) {}
Command(ap_uint<addressWidth+bttWidth+17> const &cmd)
: length(cmd(22,0)), type(cmd(23,23)), dsa(cmd(29,24)), eof(cmd(30,30)), drr(cmd(31,31)), address(cmd(95,32)), tag(cmd(99,96)) {}
operator ap_uint<addressWidth+bttWidth+17>(){
ap_uint<addressWidth+bttWidth+17> ret;
ret(bttWidth-1,0) = length;
ret(bttWidth,bttWidth) = type;
ret(bttWidth+6,bttWidth+1) = dsa;
ret(bttWidth+7,bttWidth+7) = eof;
ret(bttWidth+8,bttWidth+8) = drr;
ret(addressWidth+bttWidth+8,bttWidth+9) = address;
ret(addressWidth+bttWidth+12,addressWidth+bttWidth+9) = tag;
ret(addressWidth+bttWidth+16,addressWidth+bttWidth+13) = 0;
return ret;
}
};

/// Implements the status bus interface for the DataMover IP
Expand All @@ -54,9 +68,25 @@ struct Status { // 8 bits
ap_uint<1> decodeError{0};
ap_uint<1> slaveError{0};
ap_uint<1> okay;
ap_uint<23> bytesReceived{0};
ap_uint<1> endOfPacket{0};

Status(bool _okay) : okay(_okay) {}
Status() : okay(true) {}
Status(ap_uint<32> sts)
: tag(sts(3,0)), internalError(sts(4,4)), decodeError(sts(5,5)), slaveError(sts(6,6)),
okay(sts(7,7)), bytesReceived(sts(30,8)), endOfPacket(sts(31,31)) {}
operator ap_uint<32>(){
ap_uint<32> ret;
ret(3,0) = tag;
ret(4,4) = internalError;
ret(5,5) = decodeError;
ret(6,6) = slaveError;
ret(7,7) = okay;
ret(30,8) = bytesReceived;
ret(31,31) = endOfPacket;
return ret;
}
};

} // End namespace axi
Expand Down