Verilog学习札记(1):Structural models of combinational logic

本文是Verilog学习的第一部分,主要介绍Verilog的结构化视图(类似绘制电路图)和行为视图,以及如何使用预定义的逻辑门(primitive)进行组合逻辑设计。以half adder为例,展示了如何通过Verilog的结构化方式实现,并讨论了实际端口和形式端口的关联方式,以及数据类型wire的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Verilog所描述的I-O关系可以分为两类:

structural view: similar to creating a schematic

behavior view: could be a simple boolean equation model, a register transfer level (RTL) model or an algorithm

Verilog包含了26组预先定义好的组合逻辑门(no sequential primitive),称为primitive,包括:

and, nand, or, nor, xor, xnor, buf, not...

利用primitive写half adder为例(structural view):


module add_half (output c_out, sum, input a,b);

xor(sum,a,b); //output port of a primitive must be first in the list of ports!

and(c_out,a,b);

endmodule


attention: verilog is a case sensitive language


data type wire: used to establish connectivity in design, just as a physical wire establishes connectivity between gates


Actual ports and formal port: can be associated by position in port lists

这个方法在书上的example 4.2里用到,但是显然非常不方便,要将其一一对齐来写,所以在port lists的写法上有所改进,且不需要注意位置关系:

.formal_name(actual name)

formal_name: given in the declaration of the instantiated module

actual_name: used in the instantiation of the module

例如在写full adder时需要用到half adder:

Add_half M1  (.b(b),

.c_out(w2),

.a(a),

.sum(w1)

);



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值