仮想マシン:VMware -14.0.0.24051
環境:ubuntu 18.04.1スクリプト
:makefile(クリックして移動)
ユーティリティ:vcsおよびverdi
記事ディレクトリ
1.需要
- 2つの入力バイトと3つの出力ポートのサイズを比較します。aがbより大きい場合、re = 1、残りは0です。aがbより小さい場合、reb = 1、残りは0です。aが等しい場合〜b、eq = 1、残りは0です。
- 動作レベルの説明ステートメントと継続的な割り当てステートメントで実装されます
二、Block Diagram
三、設計および機能検証
(1)RTL
//-- Solution 1
//-- modified by xlinxdu, 2022/04/25
module compare(
//-- interface
input wire [7:0] a ,
input wire [7:0] b ,
output reg re ,
output reg reb,
output reg eq
);
/*-----------------------------------------------\
-------------- compare a with b --------------
\-----------------------------------------------*/
always @ (*)begin
if(a > b)begin
{
re,reb,eq} = {
1'b1,1'b0,1'b0};
end
else if(a < b)begin
{
re,reb,eq} = {
1'b0,1'b1,1'b0};
end
else if(a == b)begin
{
re,reb,eq} = {
1'b0,1'b0,1'b1};
end
else begin
{
re,reb,eq} = {
1'bx,1'bx,1'bx};
end
end
endmodule
//-- Solution 2
//-- modified by xlinxdu, 2022/04/25
module compare(
//-- interface
input wire [7:0] a ,
input wire [7:0] b ,
output reg re ,
output reg reb,
output reg eq
);
wire re_s,reb_s,eq_s;
assign re_s = (a > b) ? 1'b1:1'b0;
assign reb_s = (a < b) ? 1'b1:1'b0;
assign eq_s = (a == b)? 1'b1:1'b0;
always @ (*) begin
{
re,reb,eq} = {
re_s,reb_s,eq_s};
end
endmodule
(2)テストベンチ
//-- modified by xlinxdu, 2022/04/25
module tb_compare;
reg [7:0] a ;
reg [7:0] b ;
wire re ;
wire reb;
wire eq ;
initial begin
a = 8'b0;
b = 8'b0;
end
always begin
#100;
a = {
$random}%255;
b = {
$random}%255;
end
compare tb_compare(
.a (a ),
.b (b ),
.re (re ),
.reb(reb),
.eq (eq )
);
initial begin
#10000 $finish;
$fsdbDumpfile("compare.fsdb");
$fsdbDumpvars ;
$fsdbDumpMDA ;
end
endmodule
4.結果
(1)解決策1
(2)解決策2
上記の結果から、同じテストプラットフォームを使用した場合、動作レベルの記述ステートメントであろうと連続代入ステートメントであろうと、結果は同じであることがわかります。結果から、モジュールのデータパスは正常であり、機能検証に合格していることがわかります。
著者:xlinxdu
著作権:この記事は元の著者であり、著作権は著者に帰属します。
転載:著者の許可なしに転載することは禁じられています。転載はこの声明を保持し、元のテキストへのリンクを記事に記載する必要があります。