0

サブレジスタの各シフト後に値を格納するシフトレフトレジスタの Verilog コードを書いています。出力レジスタをこのような配列として定義できますか?提供されているコードは、私のコードではなく概念を示すための単純な例です。

module test(a,b,c);
input a,b;
output [7:0] c [3:0];
endmodule

それ以外の

module test(a,b,c1,c2,c3,c4);
input a,b;
output [7:0] c1,c2,c3,c4;
endmodule

そして、最初の方法で c[i] を呼び出す方法

4

1 に答える 1

1

...はい、最初の例のように、出力で2D配列を非常に使用できます。Stuart Sutherland 自身によるこの論文のセクション 5 をチェックしてください。セクションのタイトルはModule Ports.

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC4QFjAA&url=http%3A%2F%2Fwww.sutherland-hdl.com%2Fpapers%2F2006-SNUG-Europe_SystemVerilog_synthesis_paper. pdf&ei=7KmYUNKPN6GyigKDnoHwDA&usg=AFQjCNGmr3flHrARC-w40xveo8zitcdjfg&cad=rja

また、最初の例を詳しく説明すると、わかりやすくするためにモジュールを次のように定義できます。

module lshift(clk, reset, a, c);
input wire clk, reset;
input wire [7:0] a;
output reg [7:0] c [0:3]; // <-- defining the unpacked dimension as [0:3] for clarity

always@(posedge clk) begin
   if(reset) begin
       c[0] <= 8'd0;
       ...
       c[3] <= 8'd0;
   end
   else begin
       c[0] <= a;
       c[1] <= c[0];
       c[2] <= c[1];
       c[3] <= c[2];
   end
end
endmodule

...これで、配列にスライスできます。c[0], c[1] .. c[3]それぞれが Byte を表しc[0][3:0]、最初のバイトの下位ニブルを意味します。

... お役に立てれば!

于 2012-11-06T06:30:44.290 に答える