簡體   English   中英

在 VHDL 中為 D 觸發器復位設置獨立的 if 子句是否合法?

[英]Is it legal to have an independent if-clause for the D flip-flop reset in VHDL?

我有以下代碼描述了一些寄存器:

    DCR_WR_REGS_P: process (CLK)
    begin
        if rising_edge(CLK) then
            if DCR_WRITE = '1' then
               if C_BASEADDR(0 to 6) = DCR_ABUS(0 to 6) then
                    case to_integer(unsigned(DCR_ABUS(7 to 9))) is
                       when REG_DMA_RD_ADDR_OFFS =>
                            dma_rd_addr_reg <= DCR_WR_DBUS (0 to DMA_RD_ADDR_SZ-1);                              
                       when REG_DMA_RD_LENG_OFFS =>
                            dma_rd_leng_reg <= DCR_WR_DBUS (0 to DMA_RD_LENG_SZ-1);
                            rd_dma_req <= '1';
                       -- more registers here...
                       when

                       when
                       ----------------------
                       when others =>
                    end case;
                end if;
            else
                if clear_rd_dma_req='1' then
                    rd_dma_req <='0';
                end if;
            end if;
        end if;
    end process DCR_WR_REGS_P;

除了當 DCR_WRITE 處於活動狀態時會忽略 clear_rd_dma_req 之外,此代碼有效。 那么,我可以以某種方式使“if clear_rd_dma_req='1'”子句成為一個獨立的子句嗎? 我意識到我可以為 rd_dma_req 位創建一個單獨的進程,但我試圖避免這種情況,因為我有一些這樣的位。

這是一個具有單獨過程的版本:

DCR_WR_REGS_P: process (CLK)
begin
    if rising_edge(CLK) then
        if DCR_WRITE = '1' then
           if C_BASEADDR(0 to 6) = DCR_ABUS(0 to 6) then
                case to_integer(unsigned(DCR_ABUS(7 to 9))) is
                   when REG_DMA_RD_ADDR_OFFS =>
                        dma_rd_addr_reg <= DCR_WR_DBUS (0 to DMA_RD_ADDR_SZ-1);                              
                   when REG_DMA_RD_LENG_OFFS =>
                        dma_rd_leng_reg <= DCR_WR_DBUS (0 to DMA_RD_LENG_SZ-1);
                   -- more registers here...
                   when

                   when
                   ----------------------
                   when others =>
                end case;
            end if;
        end if;
    end if;
end process DCR_WR_REGS_P;

RD_DMA_REQ_P: process (CLK)
begin
    if rising_edge(CLK) then
        if clear_rd_dma_req='1' then
            rd_dma_req <='0';
        elsif DCR_WRITE = '1' then
            if C_BASEADDR(0 to 6) = DCR_ABUS(0 to 6) then
                if to_integer(unsigned(DCR_ABUS(7 to 9))) = REG_DMA_RD_LENG_OFFS then
                    rd_dma_req <= '1';
                end if;
            end if;
        end if;
    end if;
end process RD_DMA_REQ_P;

這是一個帶有獨立 if 子句的版本,這可能是非法的:

    DCR_WR_REGS_P: process (CLK)
    begin
        if rising_edge(CLK) then
            if DCR_WRITE = '1' then
               if C_BASEADDR(0 to 6) = DCR_ABUS(0 to 6) then
                    case to_integer(unsigned(DCR_ABUS(7 to 9))) is
                       when REG_DMA_RD_ADDR_OFFS =>
                            dma_rd_addr_reg <= DCR_WR_DBUS (0 to DMA_RD_ADDR_SZ-1);                              
                       when REG_DMA_RD_LENG_OFFS =>
                            dma_rd_leng_reg <= DCR_WR_DBUS (0 to DMA_RD_LENG_SZ-1);
                            rd_dma_req <= '1';
                       -- more registers here...
                       when

                       when
                       ----------------------
                       when others =>
                    end case;
                end if;
            end if;
            if clear_rd_dma_req='1' then
                rd_dma_req <='0';
            end if;
        end if;
    end process DCR_WR_REGS_P;

謝謝

是的,您可以將其if rising_edge(clk)獨立的(仍在if rising_edge(clk)語句中)。 是什么讓您認為此版本(修改后的問題中的最后一個)應該是非法的?

由於“最后一次分配獲勝”規則,它所做的任何事情都將覆蓋由if DCR_Write語句對相同信號if DCR_Write分配。

然而,為什么不簡單地顛倒優先順序並整理它,像這樣呢?

if clear_rd_dma_req='1' then
   ...
elsif DCR_Write = '1' then
   ... 
end if;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM