system verilog知识点总结

数据类型:

logic为四值逻辑表示为0、1、X、Z
bit为二值逻辑表示为0、1
四值逻辑类型:integer、reg、logic、net-type(wire、tri)
二值逻辑类型:byte、shortint、int、longint、bit
有符号类型:byte、shortint、int、longint、integer
无符号类型:bit、logic、reg、net-type

模块定义与例化

模块定义

module test(
input clk,
input rst,
input [3:0] data,
output [2:0] y
);
endmodule

模块例化

test u0(
.clk(clks),
.rst(rst),
.data(data_s),
.y(y_s)
);

参数化模块

module test
#(parameter int addr_width = 8,
   parameter int data_width = 32)
(
input clk,
input rst,
input [addr_width:0] data,
output [data_width:0] y
);
endmodule

宏定义

'define addr_width 8
'define data_width 32
module test
(
input clk,
input rst,
input ['addr_width:0] data,
output ['data_width:0] y
);
endmodule

接口

interface使用

interface regs_cr_if;
	logic clk;
	logic rst;
	initial begin
		clk<=0;
		forever begin
			#5ns clk<=!clk;
		end
	end
	initial begin
		#20ns;
		rst<=1;
		#40ns;
		rst<=0
		#40ns;
		rst<=1;
	end
endinterface: regs_cr_if

对interface例化

reg_cr_if cr_if();
test u0(
.clk(cr_if.clk),
.rst(cr_if.rst),
.......
)

任务与函数

Task与function可声明多个input、output、inout和ref类型

  • function
    • 默认数据类型是logic
    • 数组可以作为形式参数传递
    • 可以返回或不返回结果
    • 只有数据变量可以在形式参数列表中声明为ref类型
    • 不可内置耗时语句
    • 用function或者task均可调用
  • task
    • 无法通过return返回结果只能通过output、inout、或者ref参数返回
    • 可以内置耗时语句
    • 可能用于需要耗时信号采样或驱动场景
    • 若内含耗时语句只能用task调用

约束块

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值