当前位置:网站首页>Verilog reg register, vector, integer, real, time register
Verilog reg register, vector, integer, real, time register
2022-07-02 03:08:00 【Da Xi】
register (reg)
register (reg) Used to represent a storage unit , It will keep the original value of the data , Until it is rewritten . Examples of statements are as follows :
example
reg clk_temp;
reg flag1, flag2 ;
For example, in always In block , Registers may be integrated into edge triggers , In combinatorial logic, it may be integrated into wire Type variable . The register does not require a drive source , You don't need a clock signal . In simulation , The value of the register can be rewritten by assignment at any time . for example :
example
reg rstn ;
initial begin
rstn = 1'b0 ;
#100 ;
rstn = 1'b1 ;
end
vector
When the bit width is greater than 1 when ,wire or reg Can be declared as a vector . for example :
example
reg [3:0] counter ; // Statement 4bit Bit wide register counter
wire [32-1:0] gpio_data; // Statement 32bit Bit width linetype variable gpio_data
wire [8:2] addr ; // Statement 7bit Bit width linetype variable addr, The bit width range is 8:2
reg [0:31] data ; // Statement 32bit Bit wide register variable data, The most significant bit is 0
For the above vector , We can specify one or several adjacent bits , Used as other logic . for example :
example
wire [9:0] data_low = data[0:9] ;
addr_temp[3:2] = addr[8:7] + 1'b1 ;
Verilog Support variable vector field selection , for example :
example
reg [31:0] data1 ;
reg [7:0] byte1 [3:0];
integer j ;
[email protected]* begin
for (j=0; j<=3;j=j+1) begin
byte1[j] = data1[(j+1)*8-1 : j*8];
// hold data1[7:0]…data1[31:24] Assign values to byte1[0][7:0]…byte[3][7:0]
end
end
Verillog It also supports specifying bit Vector field selection access with fixed bit width after bit .
- [bit+: width] : From start bit Bits begin to increment , The seat width is width.
- [bit-: width] : From start bit Bits begin to decrease , The seat width is width.
example
// below 2 Each assignment is equivalent
A = data1[31-: 8] ;
A = data1[31:24] ;
// below 2 Each assignment is equivalent
B = data1[0+ : 8] ;
B = data1[0:7] ;
When recombining signals into new vectors , You need braces . for example :
example
wire [31:0] temp1, temp2 ;
assign temp1 = {byte1[0][7:0], data1[31:8]}; // Data splicing
assign temp2 = {32{1'b0}}; // assignment 32 The number of bits 0
Integers , The set of real Numbers , Time register variables
Integers , The set of real Numbers , Data types such as time actually belong to register types .
Integers (integer)
Integer types use keywords integer To declare . Do not specify the bit width when declaring , The bit width is related to the compiler , It's usually 32 bit.reg Type variable is an unsigned number , and integer Type variable is a signed number . for example :
example
reg [31:0] data1 ;
reg [3:0] byte1 [7:0]; // An array variable , Follow up
integer j ; // Integer variables , Used to assist in the generation of digital circuits
[email protected]* begin
for (j=0; j<=3;j=j+1) begin
byte1[j] = data1[(j+1)*8-1 : j*8];
// hold data1[7:0]…data1[31:24] Assign values to byte1[0][7:0]…byte[3][7:0]
end
end
In this case ,integer The signal j As an auxiliary signal , take data1 The data of is assigned to the array in turn byte1. After synthesis, there is no in the actual circuit j This signal ,j It only helps to generate the corresponding hardware circuit .
The set of real Numbers (real)
Keywords for real numbers real To declare , Can be expressed in decimal or scientific notation . A real number declaration cannot have a range , The default value is 0. If you assign a real number to an integer , Only the integer part of the real number is assigned to the integer . for example :
example
real data1 ;
integer temp ;
initial begin
data1 = 2e3 ;
data1 = 3.75 ;
end
initial begin
temp = data1 ; //temp The size of the value is 3
end
Time (time)
Verilog Use a special time register time Type variable , Save the simulation time . Its width is generally 64 bit, By calling system functions $time Get the current simulation time . for example :
example
time current_time ;
initial begin
#100 ;
current_time = $time ; //current_time The size is 100
end
边栏推荐
- What is hybrid web containers for SAP ui5
- Set status bar color
- Connected block template and variants (4 questions in total)
- Missing numbers from 0 to n-1 (simple difficulty)
- MMSegmentation系列之训练与推理自己的数据集(三)
- Mathematical calculation in real mode addressing
- Feature query of hypergraph iserver rest Service
- 表单自定义校验规则
- AcWing 245. Can you answer these questions (line segment tree)
- Après le mariage
猜你喜欢

2022-2028 global human internal visualization system industry research and trend analysis report

Feature query of hypergraph iserver rest Service

QT implementation interface jump

Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
![[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials](/img/ae/7edbdf55795400166650c795c8bd58.jpg)
[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials

About DNS

Analysis of FLV packaging format

小米青年工程师,本来只是去打个酱油

使用 useDeferredValue 进行异步渲染

Framing in data transmission
随机推荐
Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
OSPF LSA message parsing (under update)
Stdref and stdcref
2022-2028 global aluminum beverage can coating industry research and trend analysis report
Set status bar color
2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
GB/T-2423. XX environmental test documents, including the latest documents
2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
/silicosis/geo/GSE184854_scRNA-seq_mouse_lung_ccr2/GSE184854_RAW/GSM5598265_matrix_inflection_demult
Systemserver service and servicemanager service analysis
venn圖取交集
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
How does proxy IP participate in the direct battle between web crawlers and anti crawlers
JS <2>
小米青年工程师,本来只是去打个酱油
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
自定义组件的 v-model
C shallow copy and deep copy
2022-2028 global deep sea generator controller industry research and trend analysis report