= !PicoBlazeOutputPort =
PicoBlazeのユーザーガイド(UG129)日本語版のp54には、8個以下のポートならばワンホットのポートアドレス(80,40,20,10,08,04,02,01)を使うのが最適と書かれています。
ただ、8個では足りないこともありますし、ワンホットを使うとしてもPORT_ID![n]とWRITE_STROBEをANDするので、1ポートあたり1個のLUTを消費します。
そこで、1ポートあたり1個の4入力LUTに収まる範囲で、もっと出力ポート数を増やすアドレス割りあてを考えてみました。
||2進数||16進数||
||100000??||80~83||
||010000??||40~43||
||001000??||20~23||
||000100??||10~13||
||000010??||08~0B||
||000001??||04~07||
こうすれば、合計'''24個'''の出力ポートを使用できます。
ライトイネーブル信号を作る回路記述は、以下のようになるでしょう。
{{{ code vhdl
signal WE : boolean;
WE <= true when WRITE_STROBE = '1' else false;
WE_PORT80 <= '1' when WE and PORT_ID(7) = '1' and PORT_ID(1 downto 0) = "00" else '0';
WE_PORT81 <= '1' when WE and PORT_ID(7) = '1' and PORT_ID(1 downto 0) = "01" else '0';
WE_PORT82 <= '1' when WE and PORT_ID(7) = '1' and PORT_ID(1 downto 0) = "10" else '0';
WE_PORT83 <= '1' when WE and PORT_ID(7) = '1' and PORT_ID(1 downto 0) = "11" else '0';
WE_PORT40 <= '1' when WE and PORT_ID(6) = '1' and PORT_ID(1 downto 0) = "00" else '0';
WE_PORT41 <= '1' when WE and PORT_ID(6) = '1' and PORT_ID(1 downto 0) = "01" else '0';
...
}}}
また、ポートアドレスの一部をデータとして扱うような出力ポートも容易にサポートできます。
たとえば、
{{{ code vhdl
signal R_DATA : std_logic_vector(9 downto 0);
process (CLK) begin
if CLK'event and CLK = '1' begin
if WRITE_STROBE = '1' and PORT_ID(7) ='1' begin
R_DATA <= PORT_ID(1 downto 0) & OUT_PORT;
end if;
end if;
end process;
}}}
のような10bit出力ポートをPicoBlazeに接続しても、消費するのは80~83だけなので、あと20個の出力ポートを付ける余裕があります。