2020年4月12日 星期日

divided by 8 with shif right operator ">>"

divided by 8 with shif right operator ">>"

// divided by 8 with shif right operator ">>"
//filename : divid_8
module divide8(quot, div);

input  [7:0] div;   //dividend
output [7:0] quot;  //quotient

parameter sh_bit = 3; //define the number of bits for shifting

assign quot = div >> sh_bit;

endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps 
module TB;
/*
module divide8(quot, div);
input  [7:0] div;   //dividend
output [7:0] quot;  //quotient
*/

reg [7:0] div;
wire[7:0] quot;

integer i;
 
divide8 UUT(quot, div);
 
initial begin  
   for ( i=150;i<=256;i=i+7) 
        begin
            div  = i;
            #10;
        end
end
endmodule



沒有留言:

張貼留言

MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構

MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 這張圖片展示了一個 結合 MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 (主要透過 Node-RED 進行資料整合)。 系統包含三個核心部分,其運作功能說明如下: 1. ESP32 終端設備(硬體控制層...