Respuesta a la primera pregunta:
Las asignaciones de bloqueo y no bloqueo solo funcionan en modelos de comportamiento.
Recuerde que el bloque inicial no es sintetizable.
Sin bloqueo :
reg X, y, z;
reg [15:0] reg-a, reg-b;
integer count;
//All behavioral statements must be inside an initial or always bloc1
initial
begin
x = 0; y = 1; z = 1; //Scalar assignments
count = 0; //Assignment to integer variables
rega = 16'bO; regb = rega; //Initialize vectors
rega[2] <= #l5 l'bl; //Bit select assignment with delay
regb[15: 13] <= #l0 {x, y, z) ; //Assign result of concatenation
//to part select of a vector
count <= count + 1; //Assignment to an integer (increment)
end
In this example the statements x = 0 through regb = rega are executed
sequentially at time 0.
Then, the three nonblocking assignments are processed at the same simulation time.
1. rega[2] = 1'b1 is scheduled to execute after 15units (i.e., time = 15)
2. regb[15:13]= {x, y, z} is scheduled to execute after 10 time units
(i.e., time = 10)
3. count = count + 1 is scheduled to be executed without any delay(i.e., time = 0)
Bloqueo:
initial
begin
x = O ; y = l ; z = 1; //Scalar assignments
count = 0; //Assignment to integer variables
rega = 16'bO; regb = rega; //initialize vectors
#l5 rega[2] = 1'b0; //Bit select assignment with delay
#l0 regb[15:13] = { x , y, z) //Assign result of concatenation to
// part select of a vector
count = count + 1; //Assignment to an integer (increment)
end
In , the statement y = 1 is executed only after X = 0 is executed.
The behavior in a particular block is sequential in a begin-end block if blocking
statements are used, because the statements can execute only in sequence. The
statement count = count + 1 is executed last. The simulation times at which the
statements are executed are as follows:
1. All statements X = 0 through regb = rega are executed at time 0
2. Statement rega[2] = 0 at time = 15
3. Statement regb[15:13] = {x, y, zl at time = 25
4. Statement count = count + 1 at time = 25
Since there is a delay of 15and 10 in the preceding statements, count = count
+ 1 will be executed at time = 25 units
Aquí puede encontrar qué construcciones Verilog son sintetizables y cuáles no.
enlace
Responda a la segunda pregunta:
SÍ, puede asignar el valor reg
al tipo de cable, pero en su código el sintetizador no encuentra ningún input
en la lógica y esta línea reg [3:0] data_reg = 4'b1;
es como usar initial
que no reconoce el sintetizador. Entonces, tienes que modificar tu código para esto:
module foo (input [3:0]a, output wire [3:0] led);
reg [3:0] data_reg;
always@(a)
data_reg = a;
assign led = data_reg;
endmodule