首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将奇偶校验位附加到给定的4位std_logic_vector?

如何将奇偶校验位附加到给定的4位std_logic_vector?
EN

Stack Overflow用户
提问于 2019-04-23 03:36:36
回答 1查看 220关注 0票数 1

Image of the DUT

我正在尝试写一个由奇偶校验位保护的内部半字节传输。为此,我想写一个发送器/接收器逻辑,如附件中的图像所示。

所以我有一个4位的输入向量,并为它生成一个奇偶校验位,我的问题来了。我想将奇偶校验位附加到输入向量。但是输入向量只有4位。有没有一种方法可以通过简单地将奇偶校验位附加到输入向量来调整其大小,或者我必须单独传输奇偶校验位?作为与整个实现相关的一个小问题:我是必须像在代码中那样为接收器和发射器创建单独的进程,还是只需编写一个包含这两个进程的进程?

我的第一个想法是简单地使用一个具有5位的内部向量来附加奇偶校验位,但问题是我最终只想要给定的输入作为输出,并且也存在同样的问题。在奇偶校验的过程中,我必须用内部的5位向量填充4位的输出向量,并且不知道这是否像我在代码中尝试的那样工作。

我希望你能理解这个问题。谢谢。

代码语言:javascript
运行
复制
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;
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55800107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档