HDLBitsLOG-Verilog Language

这个教程涵盖了Verilog的基础知识,包括简单 wire 的使用、基本门电路、向量操作以及模块化设计。内容包括基本的与非门、异或门、向量声明、位宽运算、多输入门、向量反转、复制操作、模块实例化等,还涉及了组合逻辑和时序逻辑的always块,以及条件三元运算符和减少运算符的使用。教程通过实例深入浅出地介绍了Verilog编程的各种技巧和应用。

目录

-1_Preview

0_Getting Started

001_Step One

002_Output Zero

1_Basic

003_Simple Wire

004_Four Wires

005_Inverter

006_AND Gate

007_Nor Gate

008_XNOR Gate

009_Declaring Wires

010_7458 Chip

2_Vectors

011_Vectors

012_Vectors IN More Detail

013_Vector Part Select

014_Bitwise Operators

015_Four-Input Gates

016_Vector Concatenation Operator

017_Vector Reversal 1

018_Replication Operator

019_More Replication

3_Modules:Hierarchy

020_Modules

021_Connection Port By Postion

022_Connect Nets By Name

023_Three Modules

024_Modules and Vectors

025_Adder1

026_Adder2

027_Carry-Select Adder

028_Adder-Subtractor

4_Procedures

029_Always Blocks(Combinational)

030_Always Blocks(Clocked)

031_If Statement

032_If Statement Latches(😕)​

033_Case Statement Latches

034_Priority Encoder

035_Priority Encoder With Casez

036_Avoiding Latches

5_More Verilog Features

037_Conditional Ternary Operator

038_Reduction Operators

039_Reduction: Even Wider Gates

040_Combinational For-Loop: Vector Reversal 2

041_Combination For-Loop: 255-bit Population Count

042_Generate For-Loop: 100-bit binary adder 2

043_Generate For-Loop: 100-digit BCD adder


​​​​​​​

-1_Preview

image-20210710103650027

0_Getting Started

001_Step One

module top_module( output one );
​
// Insert your code here
    assign one = 1'b1;
​
endmodule

image-20210707185458281

002_Output Zero

module top_module(
    output zero
);// Module body starts after semicolon
assign zero = 1'b0;
endmodule

image-20210709144936776

1_Basic

003_Simple Wire

module top_module( input in, output out );
    assign out = in;
endmodule

image-20210709145247891

004_Four Wires

module top_module( 
    input a,b,c,
    output w,x,y,z );
    assign w = a;
    assign x = b;
    assign y = b;
    assign z = c;
endmodule

image-20210709145534840

005_Inverter

module top_module( input in, output out );
    assign out = ~in;
endmodule

image-20210709145732301

006_AND Gate

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = a & b;
endmodule

image-20210709150001327

007_Nor Gate

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = ~(a|b);
endmodule

image-20210709150117997

008_XNOR Gate

module top_module( 
    input a, 
    input b, 
    output out );
    assign out = ~(a^b);
    //assign out = (a&b) | (~a&~b);
endmodule

image-20210709150341592

009_Declaring Wires

`default_nettype none
module top_module(
    input a,
    input b,
    input c,
    input d,
    output out,
    output out_n   ); 
    wire A1,A2,A3;
    assign A1 = a & b;
    assign A2 = c & d;
    assign A3 = A1 | A2;
    assign out = A3;
    assign out_n = ~A3;
endmodule

image-20210709150921612

010_7458 Chip

module top_module ( 
    input p1a, p1b, p1c, p1d, p1e, p1f,
    output p1y,
    input p2a, p2b, p2c, p2d,
    output p2y );
    assign p2y = (p2a&p2b)|(p2c&p2d);
    assign p1y = (p1a&p1b&p1c)|(p1d&p1e&p1f);
endmodule

image-20210709151817194

2_Vectors

011_Vectors

module top_module ( 
    input wire [2:0] vec,
    output wire [2:0] outv,
    output wire o2,
    output wire o1,
    output wire o0  ); // Module body starts after module declaration
    assign outv = vec;
    assign o2 = vec[2];
    assign o1 = vec[1];
    assign o0 = vec[0];
endmodule
​

image-20210709154519622

012_Vectors IN More Detail

`default_nettype none     // Disable implicit nets. Reduces some types of bugs.
module top_module( 
    input wire [15:0] in,
    output wire [7:0] out_hi,
    output wire [7:0] out_lo );
    assign out_hi = in[15:8];
    assign out_lo = in[ 7:0];
endmodule

image-20210709154918322

013_Vector Part Select

module top_module( 
    input [31:0] in,
    output [31:0] out );//
​
    // assign out[31:24] = ...;
    assign out[31:24] = in[ 7: 0];
    assign out[23:16] = in[15: 8];
    assign out[15: 8] = in[23:16];
    assign out[ 7: 0] = in[31:24];
    //assign out = {in[7:0], in[15:8], in[23:16], in[31:24]};
endmodule

image-20210709155420672

014_Bitwise Operators

module top_module( 
    input [2:0] a,
    input [2:0] b,
    output [2:0] out_or_bitwise,
    output out_or_logical,
    output [5:0] out_not
);
    assign out_or_bitwise = a | b;
    assign out_or_logical = a || b;
    assign out_not[5:0] = {~b,~a};
endmodule

image-20210709155947308

015_Four-Input Gates

module top_module( 
    input [3:0] in,
    output out_and,
    output out_or,
    output out_xor
);
    assign out_and = in[3] & in[2] & in[1] & in[0];
    assign out_or =  in[3] | in[2] | in[1] | in[0];
    assign out_xor = in[3] ^ in[2] ^ in[1] ^ in[0];
endmodule

image-20210709160518495

016_Vector Concatenation Operator

module top_module (
    input [4:0] a, b, c, d, e, f,
    output [7:0] w, x, y, z );//
​
    // assign { ... } = { ... };
    assign w = {a[4:0],b[4:2]};
    assign x = {b[1:0],c[4:0],d[4:4]};
    assign y = {d[3:0],e[4:1]};
    assign z = {e[0:0],f[4:0],2'b11};
    //assign {w, x, y, z} = {a, b, c, d, e, f, 2'b11};
endmodule

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值