12
十
Posted by linex0816 as FPGA
module my_encode1(
I, //输入由开关决定,0:按下,1:未按下
Y //输入由开关决定,0:按下,1:未按下
);
input [3:0] I; //输入
output [1:0] Y; //输出
reg [1:0] Y; //输出
always @(I) //一旦I变化就执行
begin
casex(I) //优先编码器需要用casex来描述
4′bxxx1: Y = 2′b00; //I[0]为1的时候编码为0
4′bxx1x: Y = 2′b01; //I[1]为1的时候编码为1
4′bx1xx: Y = 2′b10; //I[2]为1的时候编码为2
4′b1xxx: Y = 2′b11; //I[3]为1的时候编码为3
default: Y = 2′b00; //其它状态的处理
endcase
end
endmodule
RSS feed for comments on this post · TrackBack URI
Leave a reply