我找到了12位二进制到bcd转换的代码,但我似乎不能理解移位寄存器部分(只显示了状态机部分)。我需要帮助理解'&‘在移位寄存器中究竟是如何工作的,如果有人也能为移位寄存器部分生成一种不同的方式,让它看起来像下面的代码,因为它更容易理解数据流:
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;发布于 2019-04-16 18:48:35
&是一个连接运算符。例如,请查看此问题以了解更多讨论:Concatenating bits in VHDL
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。
对于你的另一个问题,我认为下面的操作也是可能的,并且没有&运算符的相等操作。
bcds_next(19 downto 1) <= bcds_reg(18 downto 0);
bcds_next(0) <= binary(11);https://stackoverflow.com/questions/55705562
复制相似问题