2020年4月16日 星期四

BCD(8421) to Excess-3 Dataflow Level in Verilog

BCD(8421) to Excess-3  Dataflow Level in Verilog 




module BCD_EX3_Dataflow(B,Y);

input  [3:0]B;  // B  4位元輸入
output [3:0]Y;   // Y    4位元輸出
reg [3:0]Y;

always@(*)
begin
 Y[3] = B[3] | (B[2]&B[1]) | (B[2]&B[0]);
 Y[2] = (~B[2]&B[1]) | (~B[2]&B[0]) | (B[2] & ~B[1] & ~B[0]) ;
 Y[1] = ( B[1 ]& B[0]) | ( ~B[1] & ~B[0]) ;
 Y[0] =  ~B[0];
end

endmodule



// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps 
module TB;
/*
module BCD_EX3_Dataflow(B,Y);
input  [3:0]B;  // B  4位元輸入
output [3:0]Y;   // Y    4位元輸出
*/
reg [3:0]B= 4'b0000;   //  暫存器資料初值為‘0’

wire [3:0]Y;

integer i;

//DEVICE UNDER TEST (DUT) .
BCD_EX3_Dataflow DUT(B,Y);

initial begin
    for (i=0; i<16; i=i+1) begin
         B = i;
         #20;
    end
    #20
     $stop;
end

endmodule


沒有留言:

張貼留言

ESP32-Flutter-MQTT-IoT-Controller

 ESP32-Flutter-MQTT-IoT-Controller 這套系統包含了 Flutter 跨平台 App 、 ESP32 韌體 與 MQTT 雲端傳輸機制 。 專案中採用的 功能命名原則與對應關係 整理如下: 1. 核心功能名稱對照表 功能區塊 Python / ...