- UID
- 1023229
- 来自
- 中国
|
module mul(reset,shang,yushu,error,chushu,beichu);input reset;input[3:0] chushu; input[3:0] beichu; output[3:0] shang; output[3:0] yushu; output error; reg[7:0] shift_beichu; reg[3:0] chushu_a; reg[3:0] shang; reg[3:0] yushu; wire error=(chushu==4'b0); always @(chushu or beichu) begin if(!reset||error) begin shang=4'b0; yushu=4'b0; chushu_a=4'b0; shift_beichu=4'b0; end else if(chushu>beichu) begin shang=4'b0; yushu=beichu; end else if(chushu==4'b1) begin shang=beichu; yushu=4'b0; end else begin shang=4'b0; chushu_a=chushu; shift_beichu=beichu; shift_beichu=shift_beichu<<1; repeat(3) begin shang=shang<<1; shift_beichu=shift_beichu<<1; if(chushu_a<=shift_beichu[7:4]) begin shift_beichu[7:4]=shift_beichu[7:4]-chushu_a; shang=shang+1; end end yushu=shift_beichu[7:4; endendendmodule转载自:移动空间站 |
|