我想创建一个名为“a”的数组并用任何二进制数填充它
它是一维数组,我的代码必须像 mips 中的 sw 一样(存储字)'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