使两个 8 位信号相互连接成 VHDL 中的 16 位信号
Make two 8 bits signal join eachother to a 16 bit signal in VHLD
我在组合 2 个信号时遇到问题。 RS232 向我发送一个数字 4(8 位),然后是 5(8 位),合起来就是数字 45。我的问题是如何将这些数字 4 和 5 组合成一个 16 位信号与 vhdl 中的数字 45?我还尝试对两个 8 位信号进行计数并调整其大小,但随后我得到一个 16 位信号,数字为 9。
如果您的想法是在一个信号中收集两个数字,类似下面状态机的东西可能会对您有所帮助。
process(clk, rst)
begin
if (rst = '1') then
current_state <= FIRST_N;
this_register <= (others => '0');
elsif rising_edge(clk) then
case current_state is
when FIRST_N =>
this_register <= RS232_input * 10;
current_state <= SECOND_N;
when FIRST_N =>
this_register <= RS232_input + this_register;
current_state <= FIRST_N ;
end case;
end if;
end process;
这样的事情能解决您的问题吗?
我在组合 2 个信号时遇到问题。 RS232 向我发送一个数字 4(8 位),然后是 5(8 位),合起来就是数字 45。我的问题是如何将这些数字 4 和 5 组合成一个 16 位信号与 vhdl 中的数字 45?我还尝试对两个 8 位信号进行计数并调整其大小,但随后我得到一个 16 位信号,数字为 9。
如果您的想法是在一个信号中收集两个数字,类似下面状态机的东西可能会对您有所帮助。
process(clk, rst)
begin
if (rst = '1') then
current_state <= FIRST_N;
this_register <= (others => '0');
elsif rising_edge(clk) then
case current_state is
when FIRST_N =>
this_register <= RS232_input * 10;
current_state <= SECOND_N;
when FIRST_N =>
this_register <= RS232_input + this_register;
current_state <= FIRST_N ;
end case;
end if;
end process;
这样的事情能解决您的问题吗?