我打算制作一个旋转优先级编码器,所以首先屏蔽并检查请求中哪个优先级最高,因此每个时钟周期都通过屏蔽输入req(我的代码中的valin
)进行检查,但是为什么我在temp2
变量中移位了2位
module priorityencoder2(clock,valin,enout);
input clock;
input wire[3:0]valin;
output reg[1:0]enout;
reg [3:0]prio;
initial prio = 4'b1000;
reg [3:0]temp2;
wire [3:0]temp;
initial temp2 = prio;
assign temp = prio & valin;
always @(posedge clock)
begin
case(temp)
4'b0000 : assign temp2 = {temp2[0],temp2[3:1]};
default : begin
assign temp2 = {temp2[0],temp2[3:1]};
case(prio)
4'b0001 : assign enout = 2'b11;
4'b0010 : assign enout = 2'b10;
4'b0100 : assign enout = 2'b01;
4'b1000 : assign enout = 2'b00;
endcase
prio = temp2;
end
endcase
end
endmodule