RAM書き込みにはどのコードが優れていますか?VerilogでのRAMコーディングの改善方法
always
ブロック内data_out
を割り当てる:module memory( output [7:0] data_out, input [7:0] address, input [7:0] data_in, input write_enable, input clk ); reg [7:0] memory [0:255]; always @(posedge clk) begin if (write_enable) begin memory[address] <= data_in; end end assign data_out = memory[address]; endmodule
どれ勧告:
module memory(
output reg [7:0] data_out,
input [7:0] address,
input [7:0] data_in,
input write_enable,
input clk
);
reg [7:0] memory [0:255];
always @(posedge clk) begin
if (write_enable) begin
memory[address] <= data_in;
end
data_out <= memory[address];
end
endmodule
がassign
ステートメントを使用してdata_out
を割り当てますか?
256のメモリ位置にアクセスするのに16アドレスビットは必要ありません。あなたは 'input [7:0] address;'を使うべきです。 – toolic