cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zhangzq71
Visitor
Visitor
2,091 Views
Registered: ‎12-02-2019

what's wrong with this logic?

Jump to solution

Here is my program, 

	always @(posedge M_AXI_ACLK)
	begin
		if (M_AXI_ARESETN == 0 || LOCAL_RESET == 1'b1)
		begin
			start_write_addr <= 1'b0;
			fifo_read_en <= 1'b0;

			wr_ddr_en <= 1'b0;
			state_sm2ddr[2:0] <= S_WR_IDLE;

			run_cnt1 <= 0;
			run_cnt2 <= 0;
		end
		else
		begin
			case (state_sm2ddr)
				S_WR_IDLE:
				if (SM2DDR_FIFO_WR_COUNT >= C_M_AXI_BURST_LEN)
				begin
					if (~burst_write_active && ~start_write_addr)
					begin
						run_cnt2 <= run_cnt2 + 1'b1;
						fifo_read_en <= 1'b1;
						state_sm2ddr[2:0] <= S_WR_WAIT_FIFO;
					end
					else
					begin
						fifo_read_en <= 1'b0;
						state_sm2ddr[2:0] <= S_WR_IDLE;
					end
				end
				else
				begin
					fifo_read_en <= 1'b0;
					state_sm2ddr[2:0] <= S_WR_IDLE;
				end

				S_WR_WAIT_FIFO:
                begin
					fifo_read_en <= 1'b0;
					start_write_addr <= 1'b1;
					state_sm2ddr[2:0] <= S_WR_WAIT_WLAST;
                end

				S_WR_WAIT_WLAST:
                begin
					fifo_read_en <= 1'b0;
					start_write_addr <= 1'b0;

					if (axi_wlast)
					begin
						state_sm2ddr[2:0] <= S_WR_NULL_STEP;
					end
					else
					begin
						state_sm2ddr[2:0] <= S_WR_WAIT_WLAST;
					end
                end

				S_WR_NULL_STEP:
				begin
					run_cnt1 <= run_cnt1 + 1'b1;
					fifo_read_en <= 1'b0;
					start_write_addr <= 1'b0;

					state_sm2ddr[2:0] <= S_WR_IDLE;
				end

				default:
				begin
					state_sm2ddr[2:0] <= S_WR_IDLE;
				end
			endcase
		end
	end

As you can see run_cnt1 + 1 must occurs after run_cnt2 + 1, so run_cnt1 must be equal run_cnt2, but in my test run_cnt1 is greater than run_cnt2, what is wrong?

0 Kudos
36 Replies
zhangzq71
Visitor
Visitor
372 Views
Registered: ‎12-02-2019

Great! You must be an AXI expert, and made som many IP cores. I think AXIS2MM and AXIMM2S will be useful to me.

I am very glad to know you and thank you very much showing me your very useful cores.

0 Kudos
hgleamon1
Teacher
Teacher
363 Views
Registered: ‎11-14-2011

I don't understand what you mean by "second" or "third" time. How are these different to running "first" time after power up?

What happens in between "first", "second" and "third"?

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos
zhangzq71
Visitor
Visitor
348 Views
Registered: ‎12-02-2019

Sorry to make you so confused.

What I want to say is,

1. after upload the bitstream to PCIe card, I turn off the computer

2. turn on the computer

3. load the PCIe driver in linux

4. then run a program to send 0x80000 to a register in PCIe to tell it needs to process 0x80000 bytes data

5. then code I sent you will be executed

6. I checked the result, everything is ok, run_cnt* are all correct. This is first time.

7. I repeat step 3-6, that is the second time. the same error occured as before. then I turn of the computer.

 

I repeat step 2-7 for 3 times, everytime the result is OK in step 6 and failed in step7. 

Do you understand what I say? 

0 Kudos
hgleamon1
Teacher
Teacher
341 Views
Registered: ‎11-14-2011

Yes, I understand your method. thank you for the clarification.

Why do you reload the driver in Linux? What happens if you simply rerun the program without reloading the driver?

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos
zhangzq71
Visitor
Visitor
339 Views
Registered: ‎12-02-2019

sorry, my mistake, it should be "I repeat step 4-7 for 3 times"

0 Kudos
zhangzq71
Visitor
Visitor
336 Views
Registered: ‎12-02-2019

Sorry,

"I repeat step 2-7 for 3 times, everytime the result is OK in step 6 and failed in step7." is correct, because the computer had been turn off at step 7.

so I must need to load the driver again after the system boot up.

0 Kudos
zhangzq71
Visitor
Visitor
334 Views
Registered: ‎12-02-2019

Oh, sorry, I am confused.  :-)

"7. I repeat step 3-6, that is the second time. the same error occured as before. then I turn of the computer.", it should be "7. I repeat step 4-6, that is the second time. the same error occured as before. then I turn of the computer."

That means it did not reload the driver in the second time.

0 Kudos