HDLbits上一些刷题心得

 第三章有关模块化的问题

模块用位置命名

模块用名字进行命名

此问题与上一个问题类似(模块).您将获得一个名为的模块,该模块按此顺序具有 2 个输出和 4 个输入。您必须按位置将 6 个端口连接到您的 顶级模块的端口 、 和 ,按该顺序排列。mod_aout1out2abcd

您将获得以下模块:

module mod_a ( output, output, input, input, input, input );

预期解决方案长度:大约 1 行。

模块声明

module top_module ( 
    input a, 
    input b, 
    input c,
    input d,
    output out1,
    output out2
);
module top_module ( 
    input a, 
    input b, 
    input c,
    input d,
    output out1,
    output out2
);
   
    mod_a instance2 (out1,out2,a,b,c,d);

endmodule

    

 

module_pos — Compile and simulate

Running Quartus synthesis. Show Quartus messages...
Running ModelSim simulation. Show Modelsim messages...

Status: Success!

You have solved 20 problems. See my progress...

注明: 模块有两种命名方式,一种是用位置进行引用,一种是用名称进行引用;

模块

模块名称

module_pos以前
下一个module_shift

此问题类似于模块.您将获得一个名为的模块,该模块按某种顺序具有 2 个输出和 4 个输入。您必须按名称将 6 个端口连接到您的 顶级模块的端口:mod_a

端口在mod_a端口在top_module
output out1out1
output out2out2
input in1a
input in2b
input in3c
input in4d

您将获得以下模块:

module mod_a ( output out1, output out2, input in1, input in2, input in3, input in4);

预期解决方案长度:大约 1 行。

模块声明

module top_module ( 
    input a, 
    input b, 
    input c,
    input d,
    output out1,
    output out2
);

 

名(连接端口1

信号名,连接端口信号名2,连接端口信号名3,。。。。)

​
module top_module ( 
    input a, 
    input b, 
    input c,
    input d,
    output out1,
    output out2
);
    mod_a instance3 (
        .out1(out1),
        .out2(out2),
        .in1(a),
        .in2(b),
        .in3(c),
        .in4(d)
    );
endmodule

​

注明本题引用模块名称进行引用,格式如下

模块名(.端口1名(连接信号1名称),.端口2名(连接信号2名称),。。。。。)

"."引用符类似于中文里的含义,说明名称:

这种引用方法的好处在于可以用端口名与被引用的模块端口相对应,不必严格按照端口顺序进行对应,提高程序的可移植性

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值