Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Coding style to minimize combinational path delay?

I'm tuning my logic to meet timing. I have a long continuous assignment statement that outputs a signal based on the current state in my FSM. The below implementation results in a long mux chain. Is there an alternative coding style that results in smaller path delay?

	assign tx_tlp_dword_offset = 
		(curstate == HANDLE_BAR1_READ_1_STATE) ? 7'h4 : 
		(curstate == HANDLE_BAR1_READ_2_STATE) ? 7'h0 : 
		(curstate == HANDLE_BAR1_READ_3_STATE) ? 7'h1 : 
		(curstate == HANDLE_BAR1_READ_4_STATE) ? 7'h2 : 
		(curstate == HANDLE_BAR1_READ_5_STATE) ? 7'h5 : 
		(curstate == HANDLE_BAR1_READ_6_STATE) ? 7'h5 : 
		(curstate == H2D_DMA_INIT_MEMRD_DW0_STATE) ? 7'h0 : 
		(curstate == H2D_DMA_INIT_MEMRD_DW1_STATE) ? 7'h1 : 
		(curstate == H2D_DMA_INIT_MEMRD_DW2_STATE) ? 7'h2 : 
		(curstate == H2D_DMA_INIT_MEMRD_DW3_STATE) ? 7'h3 : 
		(curstate == H2D_DMA_SEND_MEMRD_TLP_STATE) ? 7'h3 : 
		(curstate == H2D_DMA_SEND_MEMRD_TLP2_STATE) ? 7'h3 : 
		(curstate == D2H_DMA_INIT_MEMWR_DW0_STATE) ? 7'h0 : 
		(curstate == D2H_DMA_INIT_MEMWR_DW1_STATE) ? 7'h1 : 
		(curstate == D2H_DMA_INIT_MEMWR_DW2_STATE) ? 7'h2 : 
		(curstate == D2H_DMA_INIT_MEMWR_PL_STATE) ? reg_tx_tlp_dword_offset : 
		(curstate == D2H_DMA_SEND_MEMWR_TLP_STATE) ? reg_tx_tlp_dword_offset : 
		(curstate == D2H_DMA_SEND_MEMWR_TLP2_STATE) ? reg_tx_tlp_dword_offset : 
		7'h0;

I have attached the TimeQuest path information as well as the output from the RTL viewer.

20 Replies