1 /********************************************************************************* 2 * Company : 3 * Engineer : 空气微凉 4 * 5 * Create Date : 00:00:00 22/03/2013 6 * Design Name : 7 * Module Name : 8 * Project Name : 9 * Target Devices : 10 * Tool versions : 11 * Description : 12 * http://www.cnblogs.com/kongqiweiliang/ 13 * Dependencies : 14 * 15 * Revision : 16 * Revision : 0.01 - File Created 17 * Additional Comments : 基础实验_04_优先编码器:8位输入3位输出高位优先 18 ********************************************************************************/ 19 `timescale 1ns/1ps 20 `define UD #1 21 /*******************************************************************************/ 22 module ENCODE_8_3 23 ( 24 //Interface package 25 input [7:0] iDAT ,// 26 output reg [2:0] oCODE // 27 ); 28 //------------------------------------------------------------------------------- 29 always@(*)begin 30 if(iDAT[7]) oCODE = 3'h7; 31 else if(iDAT[6]) oCODE = 3'h6; 32 else if(iDAT[5]) oCODE = 3'h5; 33 else if(iDAT[4]) oCODE = 3'h4; 34 else if(iDAT[3]) oCODE = 3'h3; 35 else if(iDAT[2]) oCODE = 3'h2; 36 else if(iDAT[1]) oCODE = 3'h1; 37 else if(iDAT[0]) oCODE = 3'h0; 38 else oCODE = 3'hz; 39 end 40 //------------------------------------------------------------------------------- 41 endmodule