I am beginner in Verilog. So my question may seem easy to you, but I have difficulty in understanding structure of Verilog. I have one module which works in two modes: read and write. In write mode, it must assign value on positive edge of clock. In read mode, it must give output in any time without clock. Can I use always statement in case?
module EncodedRAM (input EncodingMode, input [2:0] EncodingIndex, input [7:0] EncodingNumber,
input [7:0] EncodingMask, input CLK, output [7:0] EncodingResult);
initial begin
EncodingNumbers[0]=8'b00000000;
EncodingNumbers[1]=8'b00000000;
EncodingNumbers[2]=8'b00000000;
EncodingNumbers[3]=8'b00000000;
EncodingNumbers[4]=8'b00000000;
EncodingNumbers[5]=8'b00000000;
EncodingNumbers[6]=8'b00000000;
EncodingNumbers[7]=8'b00000000;
end
case(EncodingMode)
0:
always @(posedge CLK)
EncodingNumbers[EncodingIndex]=EncodingNumber ^ Masks[EncodingIndex];
1:
EncodingResult=EncodingNumbers[EncodingIndex];
endcase
endmodule