题解 | #移位运算与乘法#
移位运算与乘法
https://www.nowcoder.com/practice/1dd22852bcac42ce8f781737f84a3272
`timescale 1ns/1ns module multi_sel( input [7:0]d , input clk, input rst, output reg input_grant, output reg [10:0]out ); //*************code***********// reg [1:0] ind; //状态编号; reg [7:0] d_tmp; //设置寄存器缓存d数据; always @(posedge clk or negedge rst) begin if(~rst) begin input_grant <= 1'b0; out <= 11'b0; ind <= 2'b0; d_tmp <= 8'b0; end else begin case(ind) //设置状态机; 2'b01: begin input_grant <= 1'b0; out <= d_tmp*3; ind <= 2'b10; end 2'b10: begin input_grant <= 1'b0; out <= d_tmp*7; ind <= 2'b11; end 2'b11: begin input_grant <= 1'b0; out <= d_tmp*8; ind <= 2'b0; end default: begin //这里需要给二者赋值; input_grant <= 1'b1 ; d_tmp <= d ; out <= d ; ind <= 2'b01; end endcase end end //*************code***********// endmodule#你觉得今年春招回暖了吗#