1
\$\begingroup\$

I want to implement a blocking read to read the data as soon as it is written. I am trying to implement a MIPS 1 pipeline and i need the data to be available in the same clock it is written. The flips flops for intermediate variables between different stages work on positive clock edge. The write is on the negative clock edge. If I want to read on a negative or positive i'll have to wait to the next cycle. I am trying to write on the first half of the cycle and read on the second half. But if i read on the positive the FFs from the next stage won't get the value.

module registers#(
)(
input clk,
input reset,
input regwrite,
input [4 : 0] wr,
input [4 : 0] rr1,
input [4 : 0] rr2,
input [31 : 0] wd,
output[31 : 0] rd1,
output[31 : 0] rd2
);
reg [31 : 0] registers [31 : 0];
integer i;
initial
begin
for(i = 0; i < 32; i = i + 1)
 registers[i] = 0;
end
//READ
assign rd1 = registers[rr1];
assign rd2 = registers[rr2];
always@(negedge clk)
begin
if(reset)
 begin
 for(i = 0; i < 32; i = i + 1)
 registers[i] = 0;
 end
else 
 begin
 if(regwrite)
 registers[wr] <= wd;
 end
end
endmodule
MadHatter
3,5961 gold badge22 silver badges48 bronze badges
asked Jul 8, 2019 at 18:41
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Ok i fixed it...

Turns out the error message was from a typo.

I changed:

if(reset)
begin
 for(i = 0; i < 32; i = i + 1)
 registers[i] = 0;
end

To:

if(reset)
begin
 for(i = 0; i < 32; i = i + 1)
 registers[i] <= 0;
end
answered Jul 8, 2019 at 18:50
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.