Professional Documents
Culture Documents
input Hclk,
input Hresetn,
input Hwrite,
input Hwritereg,
input valid,
input [31:0] H_addr1,
input [31:0] H_addr2,
input [31:0] H_wdata1,
input [31:0] H_wdata2,
input wire [31:0] Prdata,
input [2:0] Temp_selx,
output reg [1:0] Hresp,
output reg Hreadyout,
output reg Pwrite,
output reg Penable,
output reg [2:0] Pselx,
output reg [31:0] Paddr,
output reg [31:0] Pwdata,
output reg [31:0] Hrdata
);
always@(posedge Hclk)
begin
Hrdata<=Prdata;
Hresp = 2'd0;
end
always@(*)
case(state)
ST_IDLE: if(valid == 1'b1 && Hwrite == 1'b1)
next_state = ST_WWAIT;
else if(valid == 1'b1 && Hwrite == 1'b0)
next_state = ST_READ;
else
next_state = ST_IDLE;
endcase
end
else
case(state)
ST_IDLE: begin
Pselx <= 3'd0;
Penable <= 1'b0;
Pwrite <= 1'bx;
Pselx_w<=Temp_selx;
Pselx_f<=3'd0;
Pselx_f1<=3'd0;
Paddr<=32'd0;
Pwdata<=32'd0;
H_addrw<=32'd0;
//Check for Pwrite
end
ST_READ: begin
Pwrite <= 1'b0;
Pselx<=Pselx_w;
Pselx_f <= Pselx_w;
Paddr<=H_addr1;
Pselx_f1<=3'd0;
Pselx_w<=3'd0;
Penable <= 1'b0;
Pwdata<=32'd0;
H_addrw<=32'd0;
end
ST_RENABLE: begin
Penable <= 1'b1;
Pselx<=Pselx_f;
Pselx_f<=3'd0;
Paddr<=H_addr2;
Pwrite <= 1'b0;
Pselx_w<=3'd0;
Pselx_f1<=3'd0;
Pwdata<=32'd0;
H_addrw<=32'd0;
//Modification for burst
end
ST_WWAIT: begin
Penable <= 1'b0; //Wait State for getting Hwdata
Pselx <= 3'd0;
Pselx_f<=Pselx_w;
Pselx_f1<=3'd0;
Pselx_w<=3'd0;
Pwrite <= 1'b1;
Paddr<=32'd0;
Pwdata<=32'd0;
H_addrw<=32'd0;
end
ST_WRITE: begin
Pselx <= Pselx_f;
Pselx_f1<=Pselx_f;
Pselx_f<=3'd0;
Pselx_w<=3'd0;
Pwrite <= 1'b1;
Penable <= 1'b0;
Paddr<=H_addr2;
H_addrw<=H_addr2;
Pwdata<=H_wdata1;
end
ST_WRITEP: begin
Pselx <= Pselx_f;
Pselx_f1<=Pselx_f;
Pselx_f<=3'd0;
Pselx_w<=3'd0;
Pwrite <= 1'b1;
Penable <= 1'b0;
//Padd pdata and haddr logic for burst
end
ST_WENABLE: begin
Penable <= 1'b1;
Pselx <= Pselx_f1;
Pselx_f<=0;
Pselx_f1<=3'd0;
Pselx_w<=3'd0;
Pwrite <= 1'b1;
Paddr<=H_addrw;
H_addrw<=32'd0;
Pwdata<=H_wdata2;
end
ST_WENABLEP:begin
Penable <= 1'b1;
Pselx <= Temp_selx;
Pwrite <= 1'b1;
//Pselx paddr pwdata haddr and hwdata logic for
burst
end
endcase
always@(*)
case(state)
ST_IDLE: Hreadyout = 1'b1;
ST_RENABLE: Hreadyout =1'b1;
ST_WENABLE: Hreadyout =1'b1;
ST_WENABLEP:Hreadyout =1'b1;
default:Hreadyout =1'b0;
endcase
endmodule