I want to make an array called 'a' and fill it with any binary numbers
and It's 1-D array my code must do as sw in mips (store word) 'm' the value that I want to store it in 's'
Thank you,
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