research_vlsi
Advanced Member level 4
synthesis doubt
Dear friends
am having a doubt regarding synthesis of RAM.. i given the code below.
in the case am trying to reset the RAM to zero before i read/write.
module ram(reset,clk,read,var1,var2,address1,datain,wr_en,address2,dataout);
parameter width = 32, depth = 64 , state0=1'b0, state1=1'b1;
input reset,clk,read,wr_en;
input [15:0] var1, var2;
input [31:0] address1,address2;
input signed [31:0] datain;
output reg signed [31:0] dataout;
reg signed [width-1:0] mem [0:depth-1];
reg [15:0] temp;
reg state;
always @ (posedge clk)
begin
if(reset)
begin
state<=state0;
temp<=0;
dataout <=0;
end
else
begin
case(state)
state0:begin
if(temp<depth)
begin
mem[temp]<=0;
temp<=temp+1;
state<=state0;
end
else
state<=state1;
end
state1:begin
if(var1==0 && var2==1)
begin
state<=state0;
temp<=0;
end
else
state<=state1;
end
default: state<=state0;
endcase
if(read && ~wr_en)
dataout <= mem[address2];
else if(wr_en && ~read)
mem[address1] <= datain;
end
end
endmodule
tool am using is xilinx XST demo, the code is synthesizing but am not able to infer RAM in schematic, its coming fully registers/FF.
without that case logic for reseting am able to get RAM in schematic, but i want to reset the RAM to Zero before read/write. any alternate logic is there?. also i tried that case logic in separate always block, am getting fatal error. so any solution?
thanks
Dear friends
am having a doubt regarding synthesis of RAM.. i given the code below.
in the case am trying to reset the RAM to zero before i read/write.
module ram(reset,clk,read,var1,var2,address1,datain,wr_en,address2,dataout);
parameter width = 32, depth = 64 , state0=1'b0, state1=1'b1;
input reset,clk,read,wr_en;
input [15:0] var1, var2;
input [31:0] address1,address2;
input signed [31:0] datain;
output reg signed [31:0] dataout;
reg signed [width-1:0] mem [0:depth-1];
reg [15:0] temp;
reg state;
always @ (posedge clk)
begin
if(reset)
begin
state<=state0;
temp<=0;
dataout <=0;
end
else
begin
case(state)
state0:begin
if(temp<depth)
begin
mem[temp]<=0;
temp<=temp+1;
state<=state0;
end
else
state<=state1;
end
state1:begin
if(var1==0 && var2==1)
begin
state<=state0;
temp<=0;
end
else
state<=state1;
end
default: state<=state0;
endcase
if(read && ~wr_en)
dataout <= mem[address2];
else if(wr_en && ~read)
mem[address1] <= datain;
end
end
endmodule
tool am using is xilinx XST demo, the code is synthesizing but am not able to infer RAM in schematic, its coming fully registers/FF.
without that case logic for reseting am able to get RAM in schematic, but i want to reset the RAM to Zero before read/write. any alternate logic is there?. also i tried that case logic in separate always block, am getting fatal error. so any solution?
thanks