- 11
- 0
- 约2.56千字
- 约 28页
- 2016-07-20 发布于湖北
- 举报
ch046用VerilogHDL描述组合逻辑电路概述
4.6 用VerilogHDL描述组合逻辑电路;4.6 用VerilogHDL描述组合逻辑电路;行为描述方式:;end;Verilog 基本门级元件;1、多输入门;X;2、多输出门;bufif1真值表;4、设计举例;例2 用Verilog的门级元件进行
描述由三态门构成的2选1数据选择器 。;5、分层次的电路设计方法简介;module halfadder (S,C,A,B);
input A,B;
output S,C;
//Instantiate primitive gates
xor (S,A,B);
and (C,A,B);
endmodule;//Description of 1-bit full adder
module fulladder (S,CO,A,B,CI);
input A,B,CI;
output S,CO;
wire S1,D1,D2; //内部节点信号
//Instantiate the halfadder
halfadder HA1 (S1,D1,A,B);
halfadder HA2 (S,D2,S1,CI);
or g1(CO,D2,D1);
endmodule
;//Description of 4-bit full adder
module _4bit_adder (S,C3,A,B,C_1);
input [3:0] A,B;
input C_1;
output [3:0] S;
output C3;
wire C0,C1,C2; //内部进位信号
//Instantiate the fulladder
fulladder FA0 (S[0],C0,A[0],B[0],C_1),
FA1 (S[1],C1,A[1],B[1],C0),
FA2 (S[2],C2,A[2],B[2],C1),
FA3 (S[3],C3,A[3],B[3],C2);
endmodule ;4.6.2 组合逻辑电路的数据流建模;Verilog HDL的运算符;位运算符与缩位运算的比较;对同一个操作数的重复拼接还可以双重大括号构成的运算符{{}}
例如{4{A}}=4’b1111,{2{A},2{B},C}=8’;一般用法:
condition_expr?expr1:expr2;;2、数据流建模举例;//Dataflow description of a 2-to-4-line decoder,
module decoder_df (A1,A0,E,Y);
input A1,A0,E;
output [3:0] Y;
assign Y[0] = ~(~A1 ~A0 ~E);
assign Y[1] = ~(~A1 A0 ~E);
assign Y[2] = ~(A1 ~A0 ~E);
assign Y[3] = ~(A1 A0 ~E);
endmodule
;//Dataflow description of 2-to-1-line multiplexer
module mux2x1_df (A,B,SEL,L);
input A,B,SEL;
output L;
assign L = SEL ? A : B;
endmodule ;4.6.3 组合逻辑电路的行为级建模;if (condition_expr1) true_statement1;
else if (condition_expr2) true_statement2;
else if (condition_expr3) true_statement3;
……
else default_statement;;是一种多分支条件选择语句,一般形式如下:
case (case_expr)
item_expr1: statement1;
item_expr2: statement2;
……
default: default_statement; //default语句可以省略;//Behavioral description of 2-to-1-line multip
原创力文档

文档评论(0)