K
Kausi
Guest
I need to implement a memory for my design. I have used-
reg [3:0] mem[0:3];
The snipet of my code is shown below-
always @(count)
begin
case(count)
3'b000 : begin Seg1<=7'b1000000; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
3'b001 : begin Seg1<=7'b1111001; mem[0]=Code;mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
3'b010 : begin Seg1<=7'b0100100; mem[0]=mem[0];mem[1]=Code;mem[2]
=mem[2];mem[3]=mem[3];end
3'b011 : begin Seg1<=7'b0110000; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=Code;mem[3]=mem[3];end
3'b100 : begin Seg1<=7'b0011011; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=Code;end
default : begin Seg1<=7'b0101010; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
endcase
end
assign Done= ((count==3'b100)|(!(count==3'b000)));
always @(posedge Done)
begin
if(Done) begin
if(((mem[0]==4'b1100)&(mem[1]==4'b1010)&(mem[2]==4'b0010)&(mem[3]
==4'b0111)))
Success=1'b1;
else Success=1'b0;
end
end
----------------------------------------------------------------------------------
The memory elements are forming a latch. Any workaround ?
Regards,
Kauser.
reg [3:0] mem[0:3];
The snipet of my code is shown below-
always @(count)
begin
case(count)
3'b000 : begin Seg1<=7'b1000000; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
3'b001 : begin Seg1<=7'b1111001; mem[0]=Code;mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
3'b010 : begin Seg1<=7'b0100100; mem[0]=mem[0];mem[1]=Code;mem[2]
=mem[2];mem[3]=mem[3];end
3'b011 : begin Seg1<=7'b0110000; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=Code;mem[3]=mem[3];end
3'b100 : begin Seg1<=7'b0011011; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=Code;end
default : begin Seg1<=7'b0101010; mem[0]=mem[0];mem[1]=mem[1];mem[2]
=mem[2];mem[3]=mem[3];end
endcase
end
assign Done= ((count==3'b100)|(!(count==3'b000)));
always @(posedge Done)
begin
if(Done) begin
if(((mem[0]==4'b1100)&(mem[1]==4'b1010)&(mem[2]==4'b0010)&(mem[3]
==4'b0111)))
Success=1'b1;
else Success=1'b0;
end
end
----------------------------------------------------------------------------------
The memory elements are forming a latch. Any workaround ?
Regards,
Kauser.