In a contitnuous assignment, a value is assigned to a net. The syntax of a continuous assignment is:

assign [delay] LHS_net = RHS_expression;

The right-hand side expression is evaluated and the value is assigned to the left-hand side net after the specified delay. If no delay is specified, the default is zero delay.

'timescale 1ns/1ns
module Decoder2*4(A, B, EN, Z);
    input A, B, EN;
    output [0:3] Z;
    wire Abar, Bbar;

    assign #1 Abar =~A;
    assign #1 Bbar =~B;
    assign #2 Z[0]=~(Abar&Bbar&EN);
    assign #2 Z[1]=~(Abar&B&EN);
    assign #2 Z[2]=~(A&Bbar&EN);
    assign #2 Z[3]=~(A&B&EN);

The compiler directive ‘timescale in the first statement sets the tiem unit in the module for all delays to be 1ns and the time precision to be 1ns. For instance, the delay value #1 and #2 in the continuous assignments correspond to delay values of 1ns and 2ns respectively.
See the waveforms in the following figure. When EN changes at 5ns, statements 10 to 13 are executed. Z[0] gets assigned to its new value, which is zero, at time 7ns.
When A changes at 15ns, line 10, 12 and 13 execute. Execution of line 12 causes Z[2] to change to 0 at 17ns. Execution of line 10 causes Abar to get its new value at time 16ns. Because Abar changes, this in turn causes Z[0] change value to 1 at time 18ns. Note that the continuous assignments execute concurrently, that is, they are order-independent.

News Reporter
Dr. Lu

Leave a Reply

Skip to toolbar