Verilog的三種描述方式(結(jié)構(gòu)化描述、數(shù)據(jù)流描述、行為級描述對電路功能的描述有三種方式:結(jié)構(gòu)化描述、數(shù)據(jù)流描述、行為級描述。三種描述方式抽象級別不同,各有優(yōu)缺點(diǎn),相輔相成,需要配合使用。
目錄
一、結(jié)構(gòu)化描述
1、概念
2、特點(diǎn)
3、示例
真值表:
電路抽象:
實現(xiàn)代碼:
測試文件:
仿真結(jié)果:
實現(xiàn)電路:
二、數(shù)據(jù)流描述
1、概念
2、特點(diǎn)
3、示例
實現(xiàn)代碼:
實現(xiàn)電路:
三、行為級描述
1、概念
2、特點(diǎn)
3、示例
實現(xiàn)代碼:
電路實現(xiàn):
一、結(jié)構(gòu)化描述
1、概念
結(jié)構(gòu)化描述的抽象級別最低,是最接近實際硬件結(jié)構(gòu)的描述方式。
2、特點(diǎn)
直接采用結(jié)構(gòu)化描述語句描述,需要描述實現(xiàn)功能所需數(shù)字電路的邏輯關(guān)系,及其復(fù)雜;
結(jié)構(gòu)化描述語句常用于層次化模塊間的調(diào)用、以及ip核的例化等;
3、示例
為簡單起見,以3人投票表決器為例,按照結(jié)構(gòu)化描述方式實現(xiàn)功能:
————————————————
真值表:
3人投票表決器,只有2人及兩人以上同一,輸出才為1
電路抽象:
要按照結(jié)構(gòu)化描述來實現(xiàn)這一功能,首先應(yīng)進(jìn)行電路抽象。即先抽象出用何種電路實現(xiàn)這一功能,才能進(jìn)行隨后的描述。
經(jīng)過卡諾圖化簡,擬采用與、非組合邏輯實現(xiàn)這一功能,即:
O = AB+AC+BC
實現(xiàn)代碼:`timescale 1ns / 1ps
//
// Company:
// Engineer: CLL guoliang
//
// Create Date: 2020/04/22 17:53:51
//
//
module vote(
);
wire A;
wire B;
wire C;
reg [2:0]cnt;
wire O;
// 激勵設(shè)置
initial
begin
cnt = 3’b000;
repeat(10) #10 cnt = cnt+3’b1;
end
assign {C,B,A} = cnt;
//實例化
vote1 minst(
.A(A),
.B(B),
.C?,
.O(O)
);
endmodule
`timescale 1ns / 1ps
//
// Company:
// Engineer: CLL guoliang
//
// Create Date: 2020/04/22 17:53:51
//
//
module vote(
);
wire A;
wire B;
wire C;
reg [2:0]cnt;
wire O;
// 激勵設(shè)置
initial
begin
cnt = 3’b000;
repeat(10) #10 cnt = cnt+3’b1;
end
assign {C,B,A} = cnt;
//實例化
vote1 minst(
.A(A),
.B(B),
.C?,
.O(O)
);
endmodule
`timescale 1ns / 1ps
//
// Company:
// Engineer: CLL guoliang
//
// Create Date: 2020/04/22 17:53:51
//
//
module vote(
);
wire A;
wire B;
wire C;
reg [2:0]cnt;
wire O;
// 激勵設(shè)置
initial
begin
cnt = 3’b000;
repeat(10) #10 cnt = cnt+3’b1;
end
assign {C,B,A} = cnt;
//實例化
vote1 minst(
.A(A),
.B(B),
.C?,
.O(O)
);
endmodule
仿真結(jié)果:實現(xiàn)電路:
可以看出,功能的電路實現(xiàn)與設(shè)計符合;
二、數(shù)據(jù)流描述
1、概念
數(shù)據(jù)流描述抽象級別較高,不再需要清晰的刻畫具體的數(shù)字電路,而比較直觀的表達(dá)底層邏輯。其又稱為寄存器傳輸級(RTL)描述。
2、特點(diǎn)
從數(shù)據(jù)的變換和傳送角度描述模塊
抽象級別適中,即顯示的表達(dá)了模塊的行為,又隱式的刻畫了模塊的電路結(jié)構(gòu);
3、示例
同樣以3人投票表決器為例,按照數(shù)據(jù)流描述方式實現(xiàn)功能:
實現(xiàn)代碼:
`timescale 1ns / 1ps
//
// Company:
// Engineer: CLL
// //
module vote2(
input A,
input B,
input C,
output O
);
// vote
assign O = A&B | A&C | B&C;
endmodule
實現(xiàn)電路:三、行為級描述
1、概念
行為級描述抽象級別最高,概括能力最強(qiáng)。
2、特點(diǎn)
概括能力及強(qiáng),不關(guān)注電路實現(xiàn),只描述數(shù)據(jù)邏輯。
抽象級別高,綜合效率低,電路可控性差;
3、示例
同樣以3人投票表決器為例,按照數(shù)據(jù)流描述方式實現(xiàn)功能:
實現(xiàn)代碼:
`timescale 1ns / 1ps
//
// Company:
// Engineer:
//
// Create Date: 2020/04/22 18:25:40
// Design Name:
// Module Name: vote3
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
module vote3(
input A,
input B,
input C,
output reg O
);文章來源:http://www.zghlxwxcb.cn/news/detail-444612.html
// vote
always@(*)
begin
case({A,B,C})
3’b000:begin
O = 1’b0;
end
3’b001:begin
O = 1’b0;
end
3’b010:begin
O = 1’b1;
end
3’b011:begin
O = 1’b1;
end
3’b100:begin
O = 1’b0;
end
3’b101:begin
O = 1’b1;
end
3’b110:begin
O = 1’b1;
end
3’b111:begin
O = 1’b1;
end
default:begin
O = 1’b0;
end
endcase
end
endmodule
電路實現(xiàn):文章來源地址http://www.zghlxwxcb.cn/news/detail-444612.html
到了這里,關(guān)于Verilog的三種描述方式(結(jié)構(gòu)化描述、數(shù)據(jù)流描述、行為級描述對電路功能的描述有三種方式:結(jié)構(gòu)化描述、數(shù)據(jù)流描述、行為級描述的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!