-3
數組我想創建一個名爲「A」的數組,並與任何二進制數如何使「的Verilog」(代碼中)
填補它和它的1-d陣列 我的代碼必須做的是SW在MIPS(存儲字) 'M',我想將其存儲在 'S'
謝謝你的價值,
module ALU(m,s,control,out,zeroflag,array);
input [31:0] m,s;
input [7:0] control;
output reg [31:0] out;
output reg zeroflag;
reg a [0:2]; // this is the array
a[2] = 4'b0000; // filled it..
a[1] = 4'b1001;
a[0] = 4'b0110;
always @(m,s,control,out,zeroflag,array)
begin
case(control)
8'h2B : if(s==8'h0) a[0] = m;
out = a[0];
else if(s==8'h1) a[1] = m;
out = a[1];
else a[2] = m;
out = a[2];
endcase
end
always @(out)
begin
if(out==0)
zeroflag <= 1;
else
zeroflag <= 0;
end
endmodule
////////////// ////////////////////////////
module test;
reg [31:0] m,s;
reg [7:0] control;
wire [31:0] outpt;
wire zeroflag;
ALU rtypeoperations(m,s,control,outpt,zeroflag);
initial
begin
m=32'b0000; s=8'h0; control=8'h2B; //stores m value in array[0] if s=8'h0, stores m value in array[1] if s=8'h1, stores m value in array[2] if s=8'h2,
end
initial
begin
$monitor("At time = %0t ,result = %b, zero flag = %b ",$time ,outpt,zeroflag);
end
endmodule
發生了什麼而不是您的預期? [數組上的這個問題](http://stackoverflow.com/questions/4846898/verilog-array-syntax)給你的解決方案? – giusti
你需要一個時鐘'存儲單詞' – Greg