RTL Basics: Filling Vectors Quickly

【Problem Description】

When designing with Verilog, it is often encountered that multi-bit vectors need to be filled with "1", "x" or "z", especially when the bit width is not specified, "'bx" or "'bz" " can fill to all bits of the vector, but "'b1" doesn't get the expected result of all bits "1". In view of this situation, this article explains the reason through a detailed example, and also gives how to correctly assign "1", "x" or "z" to when the number of digits in the vector is not a multiple of 2 or the number of digits is very large. Shortcut method for all bits corresponding to?

【Misunderstanding】

What if in the design you want to assign the same value to each bit of a multi-bit wide vector? Common code writing situations are as follows:    

【Solution】

The first method: use the spelling operator "{}" method

The second method: omit the data type method

【Precautions】

The first method: use the spelling operator "{}" method

Pay attention to the precautions for the use of repetition operators, please refer to the previous topic "Positioning Operations in Verilog".

The second method: omit the data type method

Note that after ignoring the data type, the operand can be of any width, and the specific object of the operation is each bit of the data.


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324650767&siteId=291194637