- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要移位 std_logic_vector
。
但是这段代码有一个错误:
architecture led_main of testing is
signal clk_cnt : std_logic_vector(64 DOWNTO 0) := (others => '0');
signal led_buf : std_logic_vector( 3 downto 0 ) := "0001";
begin
process(clk)
begin
if rising_edge(clk) then
clk_cnt <= clk_cnt + 1;
if clk_cnt >= 24999999 then
led_buf <= led_buf(0) & led_buf(3 downto 1);
end if;
end if;
end process;
ground <= '0';
end led_main;
我认为“0001”、“0010”、“0100”……
最佳答案
你的变速杆没问题。实际上,它是一个旋转器。
但是您的计数器太大(65 位)并且它不会在适当的时间翻转或重置为零。您当前的设计等待 25M 个周期,然后在每个周期中从 25M 转移到 2**64。
此外,您正在使用非标准 IEEE 包对 std_logic_vector
执行算术运算(加法)。请使用 numeric_std
包中的 unsigned
类型。
您的计数器所需的位数可以通过 log2
函数获得,如下所示:
function log2ceil(arg : positive) return natural is
variable tmp : positive;
variable log : natural;
begin
if arg = 1 then return 0; end if;
tmp := 1;
log := 0;
while arg > tmp loop
tmp := tmp * 2;
log := log + 1;
end loop;
return log;
end function;
来源:https://github.com/VLSI-EDA/PoC/blob/master/src/common/utils.vhdl
完整代码重写:
use IEEE.numeric_std.all;
architecture led_main of testing is
constant CNT_MAX : positive := 25000000;
signal clk_cnt : unsigned(log2ceil(CNT_MAX) - 1 downto 0) := (others => '0');
signal led_buf : std_logic_vector( 3 downto 0 ) := "0001";
begin
process(clk)
begin
if rising_edge(clk) then
clk_cnt <= clk_cnt + 1;
if clk_cnt = (CNT_MAX - 1) then
clk_cnt <= (others => '0');
led_buf <= led_buf(0) & led_buf(3 downto 1);
end if;
end if;
end process;
end led_main;
```
关于vhdl - 如何移动 std_logic_vector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45810449/
我有四个 std_logic_vectors (15 downto 0) 并想将它们堆叠成 std_logic_vector (63 downt 0) 到目前为止我已经找到了一种方法,但它是正确的
假设我有 2 个 std_logic_vectors: inputA : std_logic_vector(31 downto 0) inputB: std_logic_vector(31 down
我想要移位 std_logic_vector。 但是这段代码有一个错误: architecture led_main of testing is signal clk_cnt : std_lo
我正在用累加器编写一个 4 位二进制加法器: library ieee; use ieee.std_logic_1164.all; entity binadder is port(n,clk,
我有一个像这样的 std_logic_vector: cntrl_signals:out std_logic_vector(4 downto 0); 对该向量有索引的一种方法是为每个向量显式定义一个常
我正在VHDL中开发一个小东西,这是一个相当新的东西。我在弄清楚如何将较大的std_logic_vector切成较小的std_logic_vector时遇到麻烦。 例如,我有3个信号: signal
这是怎么回事?为什么我会收到“运算符参数类型不匹配”的消息,我该如何修复它? -- -- 32-bit counter with enable and async reset -- architect
我正在尝试减去 2 个标准逻辑向量并得到错误 p2 <= p1(11 downto 0)- idata(11 downto 0); Error (10327): VHDL error at sub.v
我想在 STD_LOGIC_VECTOR 类型的变量中输入一个数字,但编译器有问题。 signal cl_output_ChA : STD_LOGIC_VECTOR (16-1 downto 0)
我想知道是否可以将枚举类型(如 FSM 状态)转换为 std_logic_vector 或整数。我正在使用 OSVVM 为 FSM 做一个测试平台,我想使用记分板包自动将预期状态与实际状态进行比较。
在模拟中,这很完美。这是检查的最佳方式吗 可综合代码的零。会产生什么资源? signal vector_slv : std_logic_vector(2048 downto 0); ... if (v
我想要一个添加两个 std_logic_vectors 的简单模块。但是,在使用代码时 下面的 + 运算符不会合成。 library IEEE; use IEEE.std_logic_1164.all
我一直在尝试用 VHDL 代码为我在 Altera DE1 板上实现的简单 16 位处理器编写有限状态机。在有限状态机中,我有一个 CASE 语句来处理不同的 16 位指令,这些指令由 16 位 ST
我需要取结果的绝对值,并且我只对最高有效位感兴趣。这就是我所做的: data_ram_h (others => '0')); begin data_ram_h<= std_logic_vec
嘿,我想知道在 VHDL 中是否有可能与两个 STD_LOGIC_VECTORS一起。例如,我正在编写一个将字符输出到 VGA 监视器的 VHDL 程序。我有一个向量 PixelRow: IN STD
我有以下声明: signal count:STD_LOGIC_VECTOR (3 downto 0); signal txbuff:STD_LOGIC_VECTOR (7 downto 0); dou
我是 VHDL 新手,无法确定哪些数据类型适合在哪里使用。如果我理解正确,对于综合来说,所有顶级实体端口都应该声明为 std_logic_vector 或 std_logic ,而不是任何其他类型。
我正在尝试将十进制值添加到 10 位 std_logic_vector 而不必描述每一位。虽然在这种特殊情况下可能不值得麻烦,但我相信将来知道会很好。 到目前为止,我有: signal h_c
我有一个 std_logic_vector,我需要知道它何时发生一些变化。到目前为止,我是这样写的: process (cp, l1) begin if rising_edge(cp) the
如何检查 if (...) then ... end if;如果 std_logic_vector 变量包含负数的位,则构造?如果它是负数,我必须给它分配一个零值。 我有 : signal sum :
我是一名优秀的程序员,十分优秀!