2019年12月30日 星期一

Verilog Program for 8:3 Encoder

Verilog Program for 8:3 Encoder


module Encoder_8to3(I,O);
input [7:0]I;
output [2:0]O;
or(O[0],I[4],I[5],I[6],I[7]);
or(O[1],I[2],I[3],I[6],I[7]);
or(O[2],I[1],I[3],I[5],I[7]);
endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
reg [7:0]I = 8'b0000_0000;   //  暫存器資料初值為‘0000_0000’
wire [2:0]O;

integer j,k=1;

Encoder_8to3  UUT(.I(I) , .O(O) );
// initial程序結構區塊, 產生I輸入信號波形
initial begin
    $monitor(I,O);
    for (j=1; j<256;j=k) begin
        k=k<<1;
        {I} = j;
        #20;
    end
end

initial
begin
  #200;   // 模擬終止時間  200 ns
    $stop;
end

endmodule


沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...