HDLbits---Verilog Language---module:Hierarchy

这篇具有很好参考价值的文章主要介绍了HDLbits---Verilog Language---module:Hierarchy。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.Module

module top_module ( input a, input b, output out );
    mod_a U1(.in1(a), .in2(b) , .out(out));
endmodule

2.Module pos

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

3.Module name

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

4.Module shift

module top_module ( input clk, input d, output q );
wire q1,q2;
    my_dff U1(.clk(clk),.d(d),.q(q1));
    my_dff U2(.clk(clk),.d(q1),.q(q2));
    my_dff U3(.clk(clk),.d(q2),.q(q));
endmodule

5.Module shift8

module top_module ( 
    input clk, 
    input [7:0] d, 
    input [1:0] sel, 
    output [7:0] q 
);
    wire[7:0] q1,q2,q3;
    my_dff8 U1(.clk(clk),.d(d),.q(q1));
    my_dff8 U2(.clk(clk),.d(q1),.q(q2));
    my_dff8 U3(.clk(clk),.d(q2),.q(q3));
    always@(*) begin
        case(sel)
            2'b11:q<=q3;
             2'b10:q<=q2;
             2'b01:q<=q1;
             2'b00:q<=d;
        endcase
    end
endmodule

6.Module add

module top_module(
    input [31:0] a,
    input [31:0] b,
    output [31:0] sum
);
    wire[15:0] sum1,sum2;
    wire n;
     add16 U1(.a(a[15:0]),.b(b[15:0]),.cin(0),.sum(sum1),.cout(n));
        add16 U2(.a(a[31:16]),.b(b[31:16]),.cin(n),.sum(sum2));   
            assign sum={sum2,sum1};
endmodule

7.Module fadd

module top_module (
    input [31:0] a,
    input [31:0] b,
    output [31:0] sum
);//

wire  [15:0]   sum1;
wire  [15:0]   sum2;
wire           cout;
 
add16 add16_inst_l(
    .a(a[15:0]),
    .b(b[15:0]),
    .cin('d0),
    .cout(cout),
    .sum(sum1)
    );
add16 add16_inst_h(
    .a(a[31:16]),
    .b(b[31:16]),
    .cin(cout),
    .sum(sum2)
    );
assign sum = {sum2,sum1};
endmodule
module add1 ( 
    input a, 
    input b, 
    input cin,   
    output sum, 
    output cout 
);
assign {cout,sum} = a+b+cin;

endmodule

8.Module cseladd

module top_module(
    input [31:0] a,
    input [31:0] b,
    output [31:0] sum
);
    wire[15:0] sum0,sum1,sum2;
    wire sel;
    add16 U1(.a(a[15:0]),.b(b[15:0]),.cin(0),.cout(sel),.sum(sum0));
    add16 U2(.a(a[31:16]),.b(b[31:16]),.cin(0),.sum(sum1));
    add16 U3(.a(a[31:16]),.b(b[31:16]),.cin(1),.sum(sum2));
    always@(*) begin
        case(sel)
            1'b0:sum={sum1,sum0};
            1'b1:sum={sum2,sum0};
        endcase
    end
endmodule

9.Module addsub

module top_module(
    input [31:0] a,
    input [31:0] b,
    input sub,
    output [31:0] sum
);
wire n;
    wire[15:0] sum0,sum1;
    wire [31:0] nb;
    assign nb={32{sub}}^b;
    add16 U1(.a(a[15:0]),.b(nb[15:0]),.cin(sub),.cout(n),.sum(sum0));
    add16 U2(.a(a[31:16]),.b(nb[31:16]),.cin(n),.sum(sum1));
    assign sum={sum1,sum0};
endmodule

文章来源地址https://www.toymoban.com/news/detail-551788.html

到了这里,关于HDLbits---Verilog Language---module:Hierarchy的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【HDLBits 刷题 2】Verilog Language(2)Vectors 部分

    目录 写在前面 Vectors Vector0 Vector1 Vector2 Vectorgates Gates4 Vector3 Vectorr  Vector4 Vector5 来到了 Verilog 语法的矢量部分,这部分仍然比较简单,所以只给出题目、代码和仿真结果,其他不多赘述。 构建一个具有一个3位输入的电路,然后输出相同的矢量,并将其拆分为三个单独的1位输

    2024年02月07日
    浏览(27)
  • HDLBits_第1章_Verilog Language(已完结)

    目录 1. Verilog Language 1.1 Basics 1.1.1 Simple wire 1.1.2 Four wires 1.1.3 Inverter  1.1.4 AND gate 1.1.5 NOR gate 1.1.6 XNOR gate 1.1.7 Declaring wires 1.1.8 7458 chip 1.2 Vectors 1.2.1 Vectors 1.2.2 Vectors in more detail  1.2.3 Vector part select  1.2.4 Bitwise operators  1.2.5 Four-input gates 1.2.6 Vector concatenation operator 1.2.7 Vector reve

    2024年02月08日
    浏览(26)
  • Verilog刷题[hdlbits] :Module add

    You are given a module add16 that performs a 16-bit addition. Instantiate two of them to create a 32-bit adder. One add16 module computes the lower 16 bits of the addition result, while the second add16 module computes the upper 16 bits of the result, after receiving the carry-out from the first adder. Your 32-bit adder does not need to handle carry-in (assu

    2024年02月06日
    浏览(33)
  • verilog学习 | HDLBits:在线学习答案

    HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真 Verilog 模块。 以下是各单元解法答案。希望可以帮助您了解 Verilog 的工作原理。 HDLBits 在提供 Verilog 基础语法教程的同时,还能够在线仿真 Verilog 模块。 ⚠️ 注意:顶层的模块名称和端口名称 top_module 不能更改,否

    2024年02月16日
    浏览(25)
  • hdlbits系列verilog解答(always块if语句)-31

    if 语句通常创建一个 2 对 1 多路复用器,如果条件为 true,则选择一个输入,如果条件为 false,则选择另一个输入。 always @(*) begin if (condition) begin out = x; end else begin out = y; end end 这等效于使用带有条件运算符的连续赋值: assign out = condition ? (x : y); 使用if语句不当时会产生不想

    2024年02月06日
    浏览(28)
  • hdlbits系列verilog解答(8位宽移位寄存器)-24

    这项练习是module_shift移位寄存器的延伸。模块端口不是只有单个引脚,我们现在有以向量作为端口的模块,您将在其上附加线向量而不是普通线网数据。与 Verilog 中的其他位置一样,端口的向量长度不必与连接到它的导线匹配,但这会导致向量的零填充或截断。本练习不使用

    2024年02月08日
    浏览(22)
  • Verilog单边沿检测和双边沿检测的方法(HDLBits例题)

    1.单边沿检测 边沿检测是用来检测某一信号是否发送了从0至1或者从1至0的变化,有同步和异步之分。 同步边沿检测:是使用一个基准时钟,即在同一个时钟下来检测一个信号的上升沿或者下降沿。 异步边沿检测:是利用D触发器来实现边沿检测。 HDLBits例题: 单边沿检测例题

    2024年02月11日
    浏览(29)
  • verilog1 HDLbits:12 hour clock(12小时计时器)

    HDL bit -12 hour clock题目地址 翻译:创建一组适合用作 12 小时制的计数器。计数器由一个快速运行的 clk 计时,每当时钟增加(即每秒一次)时,ena 就会有一个脉冲。 reset 将时钟重置为凌晨 12:00。pm 为 0 表示 AM,1 表示 PM。 hh、mm 和 ss 是两个 BCD(二进制编码十进制)数字,分别表示

    2024年02月19日
    浏览(28)
  • HDLbits:Dff16e

    Create 16 D flip-flops. It\\\'s sometimes useful to only modify parts of a group of flip-flops. The byte-enable inputs control whether each byte of the 16 registers should be written to on that cycle. byteena[1] controls the upper byte d[15:8], while byteena[0] controls the lower byte d[7:0]. resetn is a synchronous, active-low reset. All DFFs should be

    2024年02月07日
    浏览(25)
  • [HDLBits] Countbcd

    Build a 4-digit BCD (binary-coded decimal) counter. Each decimal digit is encoded using 4 bits: q[3:0] is the ones digit, q[7:4] is the tens digit, etc. For digits [3:1], also output an enable signal indicating when each of the upper three digits should be incremented. You may want to instantiate or modify some one-digit decade counters.

    2024年02月05日
    浏览(21)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包