首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >移位寄存器如何在二进制到bcd转换中工作

移位寄存器如何在二进制到bcd转换中工作
EN

Stack Overflow用户
提问于 2019-04-16 18:03:59
回答 1查看 218关注 0票数 1

我找到了12位二进制到bcd转换的代码,但我似乎不能理解移位寄存器部分(只显示了状态机部分)。我需要帮助理解'&‘在移位寄存器中究竟是如何工作的,如果有人也能为移位寄存器部分生成一种不同的方式,让它看起来像下面的代码,因为它更容易理解数据流:

代码语言:javascript
复制
    ishiftRegister(7) <= Rxd;

    ishiftRegister(6 downto 0) <= iShiftRegister(7 downto 1);


     -- State Machine
    process(present_state, binary, binary_in, bcd_temp, bcds_reg, shift_counter)
    begin
        next_state <= present_state;
        bcds_next <= bcd_temp;
        binary_next <= binary;
        shift_counter_next <= shift_counter;

        case present_state is

            when st_start =>
               next_state <= st_shift;
               binary_next <= binary_in;
               bcds_next <= (others => '0');
               shift_counter_next <= 0;

            when st_shift =>
                if shift_counter = 12 then
                    next_state <= st_stop;
                else
                    binary_next <= binary(10 downto 0) & 'L';
                    bcds_next <= bcds_reg(18 downto 0) & binary(11);
                    shift_counter_next <= shift_counter + 1;
                end if;

            when st_stop=>
                next_state <= st_start;

        end case;
    end process;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-16 18:48:35

&是一个连接运算符。例如,请查看此问题以了解更多讨论:Concatenating bits in VHDL

代码语言:javascript
复制
bcds_next <= bcds_reg(18 downto 0) & binary(11);

使用bcds_reg(18 downto 0),您可以获取bcds_reg向量的19个最低有效位(并去掉最高有效位)。即寄存器向左移位。binary(11)是12位矢量binary的最高有效位。将19位向量和单个位与&连接起来,可以创建一个20位向量,然后可以计算出20位向量bcds_next

对于你的另一个问题,我认为下面的操作也是可能的,并且没有&运算符的相等操作。

代码语言:javascript
复制
bcds_next(19 downto 1) <= bcds_reg(18 downto 0);
bcds_next(0) <= binary(11);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55705562

复制
相关文章

相似问题

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