以下代码-1和代码-2在Verilog中是等效的,这是真的吗?
代码1
always@(posedge Clock or B or C)
begin
if (B)
A <= 0;
else if (C)
A <= 1;
end
代码2
always@(posedge Clock or B or C)
begin
if (B)
A <= 0;
else if (C)
A <= 1;
else
A <= A;
end
同样的事情在VHDL中也是如此吗?
代码-3
process
我在我的主组件中有进程a,在另一个子组件中有进程b(在主组件中实现)。进程A和B在它们的敏感度列表中都只有时钟:进程A被称为ready的可控制信号,如果进程B可以工作,则进程B将什么也不做。问题是在进程A中,当进程A将使能信号的值更改为0时,它必须进入下一个时钟周期才能改变,因此进程B结束并运行额外的时钟周期。
a:process(clk)
begin
if(rising_edge(clk)) then
if(output/=old_output) then
enable<='0';
end if;
end if;
end process;
b:proc
我的VHDL代码怎么了?以下是代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity main is
port(
-- 50 MHz clock
cp : in std_logic;
-- Reset signal
reset : in std_logic;
-- PS/2 data and clock lines
library ieee;
use ieee.std_logic_1164.all;
entity ccou is
port(clk2 : in bit;
qc: out bit_vector(3 downto 0);
qnc: out bit_vector(3 downto 0));
end entity;
architecture a_ccou of ccou is
component dfff
port(d,clk1:in bit;
qd,qnd:out bit);
end component;
signal tqc
有时我在Xilinx中收到警告:
锁存可以从不完整的大小写或if语句中生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能导致计时问题。
但是,如果我使用rising_edge()函数,那么即使我有一个不完整的情况,也没有任何警告,例如:
process (clk, rst)
begin
if (rst = '1') then
test <= '0';
elsif (rising_edge(clk)) then
test <= '1';
end if;
我在一个学校的项目中工作,我必须设计一台售票机。有许多需求,我处理了其中的许多需求,但我有一个小问题。我,设计师决定机器的初始票数是多少。然后,在客户一次购买一张门票后,这个数字应该减少一个单位。事实并非如此。怎么啦?(当涉及到用VHDL编写代码时,我是一个初学者)。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity bilete is
port(en1,en2: in std_logic;
init:
我试图理解VHDL中的状态机,以便在VHDL中检测信号的边缘。在下一种情况下,我不明白为什么我们把:"next_etat<= reg_etat“,因为我认为它可以工作,没有任何问题,即使没有它。当我们刚刚运行程序时,我想知道reg_etat和next_etat的默认值是什么,因为它们不是真正的默认值,比如在c中,例如int var=0;
entity machine_etat is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
entree : in STD_LOGIC;
tc
我已经用VHDL写了一个简单的RS锁存器,并试图用ISE来综合它。合成器增加了一个D触发器,其中D输入接地,我的(S)et和(R)eset输入被视为预置和清除输入。我以为只会看到NAND门。为什么在不需要触发器的情况下添加触发器?另外,为什么D输入连接到地?
entity rs is
Port ( r : in STD_LOGIC;
s : in STD_LOGIC;
q : inout STD_LOGIC);
end rs;
architecture Behavioral of rs is
begin
process( r, s )
begin
我试图用一个带有启用信号的NAND门的NEXYS2板来编程SR锁存。我的输入是(S、R、C)和输出 are <code>E 110</code>(q,Qbar)。下面是我尝试过的一些VHDL代码,但是一直有错误。另外,如果这能帮助任何人理解我的问题的话,图表就在下面。如果你在verilog知道的话,那也没关系。提前谢谢你
process(S,R,C,Q,Qbar)
begin
if (C = '1') then
Q <= (R nand Qbar);
Qbar <= (S nand Q);
en
我对语句always_ff和always_latch的用法感到困惑。前者将被用作:
always_ff @ (posedge clk)
begin
a <= b;
end
而后者:
always_latch
begin
a <= b;
end
第一个被时钟的正边缘激活,再加上非阻塞分配,产生一个FF。
显然,always_latch被认为是一个锁存器,但是为什么要使用非阻塞分配呢?
使用带有阻塞分配的always_comb不是更好吗?
我的问题强调了结构元素的修正!
struct packed {
logic word;
logic [31:0] test;
} a;
logic [32:0] a_input;
logic a_ff;
always_latch begin
if (enable) begin
a = a_input; // map the bus `a_input` to the struct `a`
a.test = a.test[1:0]; // change the `test` child
end
end
enable