If statement 无elsif和else条件的if语句的VHDL综合
我试图更好地理解合成是如何在这样一个没有指定其他条件的过程中工作的 我假设这不是编码的方式,因为我没有考虑其他选项,但我的问题是如何解释这段代码If statement 无elsif和else条件的if语句的VHDL综合,if-statement,vhdl,If Statement,Vhdl,我试图更好地理解合成是如何在这样一个没有指定其他条件的过程中工作的 我假设这不是编码的方式,因为我没有考虑其他选项,但我的问题是如何解释这段代码 process(clock) begin if (clock'event and clock ='1') then if sel0 = '1' then qout <= A - B; end if; if sel1 = '1' then qout <= qout sra 2; end if; end if;
process(clock)
begin
if (clock'event and clock ='1') then
if sel0 = '1' then qout <= A - B; end if;
if sel1 = '1' then qout <= qout sra 2; end if;
end if;
end process;
进程(时钟)
开始
如果(clock'event和clock='1'),则
如果sel0='1',则qout如果执行了if
语句,则qout
保持其当前值。最初,对于bit
,它将是其类型声明“0”中最左边的元素;对于std\U ulogic
,它将是最左边的元素。合成器可能会抱怨缺少有效的初始化或默认设置为“0”或“1” 基本上,您将获得一个mux和一个寄存器(当然,除了处理每个输入的计算的逻辑之外)。不需要锁存器,因为寄存器将启用时钟,因此输入网络可以是纯组合的
也不需要2个多路复用器。由于VHDL中信号分配的工作方式,以下代码段:
if sel0 = '1' then
qout <= A - B;
end if;
if sel1 = '1' then
qout <= qout sra 2;
end if;
如果sel0='1',则
qout要显示和了解合成工具如何实现设计,您可以使用Altera Quartus II进行合成,然后使用内置RTL查看器显示结果设计的高级表示
该代码使用1位向量简化结构,给出如下结果
这显示了一个触发器,每个周期都会更新,值为:
qout\u sra\u 2
ifsel1='1'
- 如果
sel1='0'
和sel0='1'
- 如果
sel1='0'
和sel0='0'
因此相当于:
if clock'event and clock ='1' then
if sel1 = '1' then
qout <= qout sra 2;
elsif sel0 = '1' then
qout <= A - B;
else
qout <= qout;
end if;
end if;
if clock'event and clock ='1' then
if not ((sel0 = '0') and (sel1 = '0')) then -- (sel0 = '1') or (sel1 = '1')
if sel1 = '1' then
qout <= qout sra 2;
else
qout <= A - B;
end if;
end if;
end if;
好的,那么要综合它的逻辑呢?级联两个多路复用器,一个减法器和一个D锁存器,带有反馈,用于保持当前值或使算术移位?+1以进行尝试。Xilinx的实现正是我所期望的——它似乎更有效。@fru1tbat:而且Altera在后期演示中也没有启用FF时钟。
if clock'event and clock ='1' then
if not ((sel0 = '0') and (sel1 = '0')) then -- (sel0 = '1') or (sel1 = '1')
if sel1 = '1' then
qout <= qout sra 2;
else
qout <= A - B;
end if;
end if;
end if;