如何使用串联将std

编程入门 行业动态 更新时间:2024-10-11 19:17:22
本文介绍了如何使用串联将std_logic_vector转换为std_logic_vector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

说我有2个std_logic_vectors:

Say I have 2 std_logic_vectors:

inputA : std_logic_vector(31 downto 0) inputB: std_logic_vector(31 downto 0)

如何转换 inputA 通过 inputB 使用串联?

How do I shift inputA by inputB using concatenation?

我知道如何向左或向右移动1个位置,但无法弄清楚如何将N个位置向右(或向左)移动。 注意:这是无时钟电路,不能使用标准的vhdl移位运算符。

I know how to shift left or right by 1 place but can't figure out how to shift N places to the right (or left). Note: this is a clockless circuit, and can't use standard vhdl shift operators.

除串联以外的其他技术或构想也将受到赞赏。

Other techniques or ideas other than concatenation would be appreciated as well.

推荐答案

我更喜欢wjl的方法,但是鉴于您专门要求使用串联的方法,请尝试以下方法:

I prefer wjl's approach, but given you asked specifically for a method using concatenation, try this:

function variable_shift(i : std_logic_vector, num_bits : integer) return std_logic_vector is constant zeros : std_logic_vector(num_bits-1 downto 0) := (others => '0'); begin return i(i'high-num_bits downto i'low) & zeros; end function;

(可以写成第二个 std_logic_vector 表示 num_bits 参数,但由于它基本上是数字,因此我总是使用基于数字的类型)

(It could be written to take a second std_logic_vector for the num_bits parameter, but as it's fundamentally a number, I'd always use a number-based type for it)

更多推荐

如何使用串联将std

本文发布于:2023-11-05 18:20:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561535.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   std

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!