How to write code to reduce the number of logical units used?

The following are the problems I found during programming. To sum up, I am afraid that I will forget it later. I don’t understand the similar critical path at my current level. What is the combination of the high-level theory? This is what I learned from the actual situation. Impressed much. Come slowly, I think I will understand those advanced things in the future!

One.... Try not to use judgment statements such as "greater than" and "less than", which will significantly increase the number of logical units used. Look at the report, the resource usage is very different.

Routine: always@(posedge clk)
Feng=1; //no_ring
Else if(count1==90000000)
Feng=0; //ring
End //This will use 107 logical units

// If the sentence if(count1==10000000) is changed to be greater than or smaller, 135 logical units are used in the report.

Two..... must try to reduce the length of the reg register

Last time I changed [30:0] to [50:0], the logic unit in the report went from more than 100 to more than 2,000! It was too scary, as for why I didn't know it! statement must be added to the default if you must add else

If it is the design of combinatorial logic, without default or else, there is no guarantee that all cases will be assigned, and a latch will be formed inside. It is no longer a pure combinatorial logic, and the circuit performance will drop.

For example: case({a,b})

2'b11 e=b;

2'b10 e=a;


//Do not add default, although only care about the result of a=1, but when a=0, e will save the original value until a becomes 1

/ / Then e to save the original value, it is necessary to generate a latch inside.

4.. Try to use the Case statement instead of the if--else statement

Complex if--else statements typically generate priority-decoding logic, which increases the combined delay on these paths. Case statements used to generate complex logic typically generate parallel logic that does not have too much latency.

In the always block of the combination logic, note that all the inputs are placed in the sensitive variable table.

For example: always@(a or b)



86 Type Face Plate

86x86mm low Profile White Faceplate

Ideal for Solid Cat 5 or Cat 6 cable

This faceplate could be include or exclude the Keystone Jack

Provided with fixtures and fittings

could be supply 1 port, 2 ports, 3 ports, 4 ports, 6 ports, 8 ports for your choice

White is the common color, we also supply the ivory, black, and other colors customized

86 Type Face Plate,Brush Wall Faceplates,Wall Face plates