Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why does my pipeline take double the number clock cycles than expected?

Status
Not open for further replies.

ElVale

Newbie level 4
Newbie level 4
Joined
Mar 16, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
Hi, I have this generate block for an unrolled pipeline, notice the 0 to 63 range.
Code:
rounds: for i in 0 to 63 generate
	 begin
	 	process(clk)
	 	begin
		if (clk = '1' and clk'event) then 
			 T1(i) <= h(i)+ e1(e(i)) + ch(e(i), f(i), g(i)) + K(i) + W(i);
			 T2(i) <= e0(a(i)) + maj(a(i),b(i),c(i));
			 h(i+1) <= g(i);
			 g(i+1) <= f(i);
			 f(i+1) <= e(i);
			 e(i+1) <= d(i) + T1(i);
			 d(i+1) <= c(i);
			 c(i+1) <= b(i);
			 b(i+1) <= a(i);
			 a(i+1) <= T1(i) + T2(i);
		end if;
		end process;
	 end generate rounds;

                process(clk)
	        begin
		if (clk = '1' and clk'event) then 
			H1_out <= H1_in + a(64);
			H2_out <= H2_in + b(64);
			H3_out <= H3_in + c(64);
			H4_out <= H4_in + d(64);	
			H5_out <= H5_in + e(64);
			H6_out <= H6_in + f(64);
			H7_out <= H7_in + g(64);
			H8_out <= H8_in + h(64);	
		end if;
	        end process;

When I simulate I get 128 clock cycles, when I was expecting 64, I'm using a 100MHz clock and I get 1280 ns in total. Am I missing something here? thanks a lot for your help.
 

The loop looks okay to me. Are you absolutely sure the clock is correctly defined and really has a 10 ns period? It's pretty easy to forget to divide the clock period by two in the testbench for generating a clock.

Regards,
 

I'm totally positive, I'm using:
Code:
CLK_GEN: process
	begin
		clk <= '0';
		wait for 5 ns;
		clk <= '1';
		wait for 5 ns;
	end process;

I'll try with another simulator and see, thanks for confirming.
 

T1, T2 should be variables or placed outside of the process. It currently takes one cycle to update T1/T2, and 1 cycle for the logic after these. I'm assuming the logic is also incorrect for some cases that you haven't tested yet.
 

T1, T2 should be variables or placed outside of the process. It currently takes one cycle to update T1/T2, and 1 cycle for the logic after these. I'm assuming the logic is also incorrect for some cases that you haven't tested yet.

I made T1 and T2 variables and BAM! 64 cycles only, yet I don't quite understand what's the theory behind this, anyway thanks a lot!
 

look up blocking vs non-blocking assignments. There are many threads on this subject. (or use google on the same subject)

short version ":=" evaluates and assigns immediately. "<=" evaluates the expression, but assigns at the end of the process. (or wait)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top