我正在尝试写一个由奇偶校验位保护的内部半字节传输。为此,我想写一个发送器/接收器逻辑,如附件中的图像所示。
所以我有一个4位的输入向量,并为它生成一个奇偶校验位,我的问题来了。我想将奇偶校验位附加到输入向量。但是输入向量只有4位。有没有一种方法可以通过简单地将奇偶校验位附加到输入向量来调整其大小,或者我必须单独传输奇偶校验位?作为与整个实现相关的一个小问题:我是必须像在代码中那样为接收器和发射器创建单独的进程,还是只需编写一个包含这两个进程的进程?
我的第一个想法是简单地使用一个具有5位的内部向量来附加奇偶校验位,但问题是我最终只想要给定的输入作为输出,并且也存在同样的问题。在奇偶校验的过程中,我必须用内部的5位向量填充4位的输出向量,并且不知道这是否像我在代码中尝试的那样工作。
我希望你能理解这个问题。谢谢。
architecture rtl of odd parity is
signal rxdat_s : out std_logic_vector(3 downto 0);
signal ok_s : out std_logic;
signal txdat_s : in std_logic_vector(3 downto 0);
signal secured_s : std_logic_vector (4 downto 0);
begin
odd_parity_gen: process ( txdat_s, clk ) is
variable txdat_v : std_logic_vector(3 downto 0);
variable secured_v : std_logic_vector(4 downto 0);
variable odd_parity_v : integer;
begin
txdat_v := txdat_s;
odd_parity_v := xnor txdat_v;
secured_v := txdat_v + odd_parity_v;
secured_s <= secured_v;
end process odd_parity_gen;
odd_parity_check: process () is
variable ok_v : integer;
variable rxdat_v : std_logic_vector(3 downto 0);
variable secured_v : std_logic_vector(4 downto 0);
begin
rxdat_v := rxdat_s;
secured_v := secured_s;
ok_v := ok_s;
ok_v := xnor secured_v;
rxdat_v := secured_v;
ok_s <= ok_v;
rxdat_s <= rxdat_v;
reg: process ( clk ) is
begin
if rising_edge (clk) then
if nres = '0' then
--reset all signals
else
--main logic
end if;
end if;
end process;
https://stackoverflow.com/questions/55800107
复制相似问题