Verilog学习笔记之HDLBITS

Verilog学习笔记之HDLBITS

Three modules

题目是:在顶层模块中例化3个模块
在这里插入图片描述

module top_module (
	input clk,
	input d,
	output q
);

	wire a, b;	// Create two wires. I called them a and b.

	// Create three instances of my_dff, with three different instance names (d1, d2, and d3).
	// Connect ports by position: ( input clk, input d, output q)
	my_dff d1 ( clk, d, a );
	my_dff d2 ( clk, a, b );
	my_dff d3 ( clk, b, q );

endmodule

这种实例化方法,在名称后面的括号里面全都是连接的信号,而没有端口名称。端口默认按顺序

Module add

在这里插入图片描述

module top_module(
    input [31:0] a,
    input [31:0] b,
    output [31:0] sum
);
    wire [15:0] low16,high16;
    wire cout1,cout2;

    add16 add16_1 (a[15:0],b[15:0],1'b0,low16,cout1);
    add16 add16_2 (a[31:16],b[31:16],cout1,high16,cout2);

    assign sum = {high16,low16};

endmodule

module add1 ( input a, input b, input cin,   output sum, output cout );

    assign {cout,sum} = a + b + cin;
// Full adder module here

endmodul

总结

首先是例化的括号里面,可以在信号后面加[]里面代表位数,并且没有的信号可以直接写1’b0;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值