我使用的是UVVM AXI-Stream VVC。它将AxiStream接口定义为一个记录类型,为了简洁起见,在这个问题中简称为 "记录类型"。
所以,给定这个记录类型,它包含两个方向的信号。
type t_axistream_if is record
tdata : std_logic_vector; -- Going in
tvalid : std_logic; -- Going in
tready : std_logic; -- Going out
end record;
我想要一个可重用的方法,可以对 tdata
并将该记录的两个实例相互连接。
这就是我正在寻找的功能。下面的VHDL是功能性的。
-- dutInput and axisMasterIf are constrained instances of the record.
dutInput.tData <= reverseBytes(axisMasterIf.tData);
dutInput.tValid <= axisMasterIf.tValid;
axisMasterIf.tReady <= dutInput.tReady;
我想要的是像这样的东西(因为记录要大得多)。
dutInput <= reverse(axisMasterIf);
axisMasterIf.tReady <= dutInput.tReady;
-- or using a procedure
-- reverse(axisMasterIf, dutInput)
当使用程序时,信号似乎并没有被连续分配。当使用函数时,我为没有赋值dutInput.tReady而苦恼。
下面是一些,非工作的尝试。
-- If I set outIf <= reverse(inIf) this function will drive the
-- TReady-signal and I will get U due to multiple drivers.
-- When I set TReady as open, it just doesn't compile.
function reverse(inIf : t_axistream_if) return t_axistream_if is
begin
return (
tData => reverseBytes(inIf.tData),
tValid => inIf.tValid,
tReady => open -- This doesn't compile.
);
end function;
-- This compiles, but the signals don't seem to become continually assigned when the procedure is called from within a process.
procedure reverse(
signal inIf : inout t_axistream_if;
signal outIf : inout t_axistream_if
) is
begin
outIf.tData <= reverseBytes(inIf.tData);
outIf.tValid <= inIf.tValid;
inIf.tReady <= outIf.tReady;
end procedure;
这段代码不需要合成。我使用的是VHDL2008。
关于这块:
-- This compiles, but the signals don't seem to become continually assigned when the procedure is called from within a process. procedure reverse( signal inIf : inout t_axistream_if; signal outIf : inout t_axistream_if ) is begin outIf.tData <= reverseBytes(inIf.tData); outIf.tValid <= inIf.tValid; inIf.tReady <= outIf.tReady; end procedure;
...具体来说..:
...但这些信号似乎并没有成为... 连轴转 当过程被从流程中调用时
(时钟)过程中的所有赋值都会变成倒装。 使用您的程序 reverse
在一个过程中,将通过增加一个额外的时钟周期的延迟来改变信号的时间。 这是预期的行为。
然而,这很可能不是您想要的。 您将希望在任何进程之外使用该过程,以确保它没有任何延迟地通过。