Download presentation
Presentation is loading. Please wait.
1
Greatest Common Divisor ---最大公约数
2
主要内容 算法描述 电路模块 Verilog描述 Modesim仿真结果与结论 综合结果
3
算法描述 begin A=0 orB=0 B=0 A>=B END Swap A B A=A-B yes no
4
电路模块 load 1 mux A_hold D > Q 1 mux 1 mux A[7:0] Compare A< B
1 mux A_hold D > Q 1 mux 1 mux A[7:0] Compare A< B Y[7:0] A-new Rest_N 1 mux — A-B 1 mux D > Q clock B_hold 1 mux B[7:0] B_hold Compare B=0 done
5
Verilog description1/3 //description the D_regs of A_hlod and B_hold
(posedge clock) begin if(reset) A_hold<=8'h00; B_hold<=8'h00; end else if(load) A_hold<=A; B_hold<=B; if(A_lessthan_B) A_hold<=B_hold; B_hold<=A_new; A_hold<=A_new; B_hold<=B_hold;
6
Verilog description 2/3 what is the A_new and A_lessthan_B
(A_hold or B_hold) begin if(A_hold<B_hold) A_lessthan_B=1'b1; A_new=A_hold; end else A_lessthan_B=1'b0; A_new=A_hold-B_hold;
7
Verilog description 3/3 //GCD and done always @ (A_hold or B_hold)
begin if(B_hold) done=1'b0; GCD=8'h00; end else done=1'b1; GCD=A_hold;
8
Modesim仿真结果 采用以下三组数据对电路的行为功能模拟 A B GCD 21 49 7 25 5 250 150 10
9
A=21,B=49,GCD=7
10
A=25,B=25 GCD=5
11
A=250,B=190 GCD=10
12
结果讨论 计算所用的时间不一样,且差距很大,是GCD的最大的问题。
Similar presentations