0

我正在尝试在 vhdl 中制作移位寄存器。

我的问题是当我尝试将值存储在寄存器中时。这是引起麻烦的代码:

architecture behave of chan_mod is
signal adc_shfreg : std_logic_vector(15 DOWNTO 0);
signal dac_shfreg : std_logic_vector(15 DOWNTO 0);

begin
    Rcv_adc:
    process(mclk, reset)
    begin
        if rising_edge(mclk) then
            if (reset = '0') then
                adc_out <= "0000000000000000";
            elsif(chan_on = '1' AND subcycle_cntr = "01" AND chan_sel = '0' AND bit_cntr < 16) then
                adc_shfreg <= adc_shfreg(14 DOWNTO 0) & adcdat;
            end if;
        end if;
    end process;
    adc_out <= adc_shfreg;  --compilation error here

我得到的错误是:

错误 (10028):无法在 chan_mod.vhd(40) 解析网络“adc_out[13]”的多个常量驱动程序

不知道您是否需要查看我的端口,但它们是:

entity chan_mod is
    Port ( mclk : in std_LOGIC;
             reset : in std_logic;
             chan_on : in std_logic;
             chan_sel : in std_logic;
             adcdat : in std_logic;
             dacdat : out std_logic;
             bit_cntr : in std_logic_vector(4 DOWNTO 0);
             subcycle_cntr : in std_logic_vector(1 downto 0);
             dac_in : in std_logic_vector(15 DOWNTO 0);
             adc_out : out std_LOGIC_vector(15 DOWNTO 0);
             rd : in std_logic;
             wr : in std_logic);
end chan_mod;

(正如您可能猜到的,其中一些会在后面的代码中使用,因此不在我的代码示例中)

4

1 回答 1

2

您的问题是您正在推动adc_out在此过程中以及使用并发分配。您应该将重置情况下对adc_out的分配替换为对adc_shfreg的分配。

architecture behave of chan_mod is
signal adc_shfreg : std_logic_vector(15 DOWNTO 0);
signal dac_shfreg : std_logic_vector(15 DOWNTO 0);

begin
    Rcv_adc:
    process(mclk, reset)
    begin
        if rising_edge(mclk) then
            if (reset = '0') then
                adc_out <= "0000000000000000"; <--- BAD! Replace adc_out with adc_shfreg
            elsif(chan_on = '1' AND subcycle_cntr = "01" AND chan_sel = '0' AND bit_cntr < 16) then
                adc_shfreg <= adc_shfreg(14 DOWNTO 0) & adcdat;
            end if;
        end if;
    end process;
    adc_out <= adc_shfreg;  --compilation error here
于 2012-09-21T11:30:36.227 回答