I'm at the beginning of learning verilog and some things are unclear. Also, I'm just looking for synthesizable code.

  1. What are the differences between this types of assignation: Which of them is synthesizable?

     reg [3:0] data_reg = 4'b1; // what kind of assignment is this? blocking, non blocking?
     reg [3:0]data_reg;
     initial data_reg = 4'b1;  
     reg [3:0]data_reg;
     initial data_reg <= 4'b1;
  2. Can I assign reg value to a wire, like:

    module foo (output wire [3:0] led); 
    reg [3:0] data_reg = 4'b1; 
    assign led = data_reg; 

For the code above I get the following error: ERROR:NgdBuild:604 in ALTIUM and in XILINX ISE I get Using initial value of led since it is never assigned.

  • \$\begingroup\$ I think the first thing is realize that your not assigning anything, your connecting wires together. You can put registers inbetween and delay the value of one wire to the other by a clock or a latched value. The biggest hurdle to learning HDL's are realizing that your code is only assigning gates and MUX's in an FPGA \$\endgroup\$
    – Voltage Spike
    Nov 29, 2016 at 17:05

2 Answers 2


In verilog, reg does not represent synthesisable storage, it is more of a software construct in the language - its also used in case statements.

If you want an actual flip-flop, you need to follow this pattern:

always @(posedge clk or negedge reset_n)
data_reg <= 4'b0000;
else data_reg <= data_input;

and, yes, you can assign any wire (output or not) from a reg (combinatorial or sequential).

Wherever you have initial, it is very likely you have something which is not synthesisable. Silicon has no concept of when initial should occur, so with initial you are maybe anticipating an earlier operation (like writing an image to FLASH memory), or relying on an FPGA synthesis flow inserting some reset initialisation for you.

  • 1
    \$\begingroup\$ Having an initial block does not immediately make something non-synthesizable. You can use an initial block to infer the contents of a ROM or initial (after configuration) contents of a RAM. You can also use it to infer the power on value of a register. \$\endgroup\$ Jan 2, 2017 at 15:39

Answer to the first question:

Blocking and Non-Blocking assignments only work in behavioral modeling. Remember the initial block is not synthesizable.


reg X, y, z;
reg [15:0] reg-a, reg-b;
integer count;
//All behavioral statements must be inside an initial or always bloc1
    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)

  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)


     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)

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

Here you can find which Verilog constructs are synthesizable and which are not.


Answer to the second question:

YES you can assign reg value to wire type, but in your code the synthesizer doesn't find any input to the logic and this line reg [3:0] data_reg = 4'b1; is like using initial which is not recognized by the synthesizer. So, you have to modify your code to this:

module foo (input [3:0]a, output wire [3:0] led); 
   reg [3:0] data_reg; 
        data_reg = a;
   assign led = data_reg; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.