Tuesday, December 25, 2012

Timescale in Verilog

`timescale is an important compiler directive in Verilog. It is written at the beginning of each module. The directive is used to specify the unit and precision used for simulation of the delay time specified in the verilog specification.

Syntax:
`timescale <time_unit> / <precision>

time_unit : This value specifies the unit of time for the delays used in the verilog code
For example, for a design with specification `timescale 10ns/1ns, a delay #100 is interpreted as a delay of 100*10ns = 1000ns

precision : It specifies the precision to which the delays are rounded off.
For example, in a design with specification `timescale 1ns/1ps, the minimum delay of 1ps will be considered for simulation. Any delay smaller than that will be rounded off to the greatest valid value less than that. In this example,
  • #1.001 is considered as a valid delay
  • #1.0009 will be rounded off to 1ns, since 0.0009ns < 1ps

The valid units for timescale specification are s, ms, us, ns, ps and fs (femto-second).

Saturday, December 22, 2012

Diodes in Parallel

Suppose you have a circuit which has a current requirement of 2 Amp, but the input diode has a current capacity of 1 Amp. What do you do then? Put two diodes in parallel as shown?



This is not advisable. The reason is as follows:

When current passes through a diode, it heats up and it's resistance decreases. So if the two diodes are not matched properly, which is usually the case, the diode with the smaller resistance ends up taking more current. As a result, it heats up more and the resistance decreases further. This is an endless cycle and soon the other diode will be effectively cut-off from the circuit. If provided sufficient current, the active diode would end up burning out.

If pairing diodes is inevitable, then the most common way out is to calculate the V-I characteristics of diodes and take only the ones that match. Further, the diodes must be coupled with the same heat sink so as to reduce the effect of difference in heating.

It's always advisable to replace the combination with a diode with a higher current rating rather than multiple smaller ones in parallel. As a general rule, each diode or LED in parallel should have it's own bias resistor.