1

私は VHDL を学んでいる学生で、かなり基本的な質問があります。

シグナルの割り当てがすぐに行われないことを読みました。したがって、以下は期待どおりに機能しません。

x <= y;
z <= not x;

したがって、割り当てが即時に行われない/順番に発生しないことは理解していますが、エンティティにシグナルを渡すことについて質問があります。次のコードがあるとします。

architecture struct of mips is
begin
    controller: entity work.controller port map(opD         => instrD(31 downto 26),          
                                                functD      => instrD(5 downto 0));   

    datapath:   entity work.dataPath port map(opD         => instrD(31 downto 26),                      
                                              functD      => instrD(5 downto 0));

end;

私はコードの重複や他の言語でのハードコーディングを避けることに慣れているため、上記のコードのopDfunctDの値をハードコーディングするのは面倒です。

私が疑問に思っているのは、これらの値を次のように内部信号に割り当てることができるかどうかです:

architecture struct of mips is
    signal opD:    STD_LOGIC;
    signal functD: STD_LOGIC;
begin
    signal opD    <= instrD(31 downto 26);
    signal functD <= instrD(5 downto 0);

    controller: entity work.controller port map(opD         => opD,          
                                                functD      => functD);

    datapath:   entity work.dataPath port map(opD         => opD,                      
                                              functD      => functD);    
end;

それは期待どおりに動作しますか (つまり、上記のコード ブロックとまったく同じように動作します)、または 2 つのコード ブロックの機能を異なるものにするシグナルの使用によって何らかの「遅延」が発生しますか?

4

1 に答える 1

5

シグナルの割り当てがすぐに行われないことを読みました。

これは本当ですが、重要な点、つまり、それらがいつ行われるかを知ることを見逃していると思います. シグナルは、シグナルを生成するプロセスが wait ステートメントに遭遇したとき、または終了したときに更新されます (プロセスの終了時にプロセス センシティビティ リストに暗黙の待機があるため)。

したがって、あなたの例は、クロックプロセスに入れても期待どおりに機能しませんが、正しいセンシティビティリストを使用した組み合わせプロセスでは完全に有効です。

architecture rtl of example is
    signal y_r : std_logic;
    signal z_r : std_logic;
    signal y   : std_logic;
    signal z   : std_logic;
 begin
    y <= x; -- immediately updated when x changes
    z <= not y; -- immediately updated when y changes, equivalent to z <= not x

    process(clk)
    begin
        if rising_edge(clk) then
            y_r <= x; -- y is updated when the clock rise, once this process finishes
            z_r <= not y_r; -- y still have the value it had when the process started executing
         end if;
    end process;
end architecture rtl;

したがって、構文エラーを除いて、最後の例は意図したとおりに機能します。ただし、そのためのより優れた私見であるきちんとした構文があります。

architecture struct of mips is
    alias opD is instrD(31 downto 26);
    alias functD is instrD(5 downto 0);
begin

    controller: entity work.controller port map(opD         => opD,          
                                                functD      => functD   

    datapath:   entity work.dataPath port map(opD         => opD,                      
                                              functD      => functD;     
end;
于 2015-04-26T17:18:21.170 に答える