microe_victor
Junior Member level 2

Help me this typical APB writing process
which is described like the pic below
please use verilog to write this, thank you
PS:
Here is my code , i did not implement all the function. It is my first time to write RTL code, so I think there might be some misunderstanding to the APB protocol
always @(posedge PCLK)
begin
if(PRESET)
begin
state <= INI;
tag_addr <= 0;
data <= 32'b0;
end
else
begin
case(state)
INI :
begin
if((PSELE==1'b1) && (PENABLE == 1'b0))
state <= SELECT;
else
state <= INI;
end
SELECT :
begin
if((PSELE==1'b1) && (PENABLE==1'b1))
begin
state <= ENABLE;
if(addr == ADDRESS )
tag_addr <= 1'b1;
else
tag_addr <= 1'b0;
end
else
begin
state <= INI;
end
end
ENABLE:
begin
if(tag_addr)
data <= PDATA;
else
data <= data;
if((PSELE==1'b1) && (PENABLE==1'b0))
state <= SELECT;
else
state <= INI;
end
default :
state <= INI;
endcase
end
end
which is described like the pic below
please use verilog to write this, thank you
PS:
Here is my code , i did not implement all the function. It is my first time to write RTL code, so I think there might be some misunderstanding to the APB protocol
always @(posedge PCLK)
begin
if(PRESET)
begin
state <= INI;
tag_addr <= 0;
data <= 32'b0;
end
else
begin
case(state)
INI :
begin
if((PSELE==1'b1) && (PENABLE == 1'b0))
state <= SELECT;
else
state <= INI;
end
SELECT :
begin
if((PSELE==1'b1) && (PENABLE==1'b1))
begin
state <= ENABLE;
if(addr == ADDRESS )
tag_addr <= 1'b1;
else
tag_addr <= 1'b0;
end
else
begin
state <= INI;
end
end
ENABLE:
begin
if(tag_addr)
data <= PDATA;
else
data <= data;
if((PSELE==1'b1) && (PENABLE==1'b0))
state <= SELECT;
else
state <= INI;
end
default :
state <= INI;
endcase
end
end