1、一、行为描述设计采用行为描述风格分别完成所给的三种同步器电路的设计,设计平台选择Quartus Prime Standard 17.1。经过综合以后,所得的门级电路分别如图 1 中的(a) 、 (b) 、 ( c)所示。(a )(b)(c )图 1 经平台综合后所给出的三种同步器的门级电路二、功能仿真编写测试文件,通过 Modelsim-Altera 仿真平台对设计得到的电路进行行为级仿真。所得结果分别如图 2 的 (a) 、 (b) 、 (c )所示。分析波形可以得知,第一个同步器实现了将输入波形延迟两个时钟再输出的功能,其中 reset 信号为高表示系统复位。第二个同步器实现了检测输入信号
2、是否有高电平出现的功能,只要输入信号出现了高电平,则输出将一直为高。第三个同步器实现了当 reset 信号有效时输出低电平,否者当输入信号为高电平时输出为高电平,当输入为低电平时输出为时钟的 1/2 分频信号。同时输出相对于输入有两个时钟周期的延时。(a )(b)(c )图 2 三种同步器分别进行门级仿真的结果三、时序仿真分别对三个同步器进行时序仿真所得结果如图 3 的 (a) 、 (b) 、 (c )所示。可以很清楚的发现,时序仿真中的输出相比于功能仿真会有一个延时。而且这还导致了第三个同步器的一个输出错误,本来应该输出分频信号,却输出了低电平。(a )(b)(c )图 3 三种同步器分别进
3、行时序 仿真的结果附件:同步器一:module HomeWorkOne(input Asynch_in ,input clock ,input reset ,output regSynch_out);reg temp = 1b0;always(posedge clock) beginif(reset) beginSynch_out = 1b0 ;endelse beginSynch_out = temp ;temp = Asynch_in ;endendendmodule测试代码:timescale 1 ns/ 1 psmodule HomeWorkOne_test();/ test vect
4、or input registersreg Asynch_in;reg clock;reg reset;/ wires wire Synch_out;/ assign statements (if any) HomeWorkOne i1 (/ port map - connection between master ports and signals/registers .Asynch_in(Asynch_in),.Synch_out(Synch_out),.clock(clock),.reset(reset);initial begin clock = 1b0 ;reset = 1b1 ;A
5、synch_in = 1b0 ;#100 reset = 1b0 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 reset = 1b1 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 $stop ;$display(“Running testbench“); end always begin#10 clock = clock ;end endmodule同步器二:module HomeWorkTwo(input clock ,input Asynch_in ,output reg Synch_out)
6、;reg q1 = 1b0 ;reg q2 = 1b0 ;wire reset ;assign reset = Synch_outalways(posedge clock) beginSynch_out = q2 ;q2 = q1 ;endalways(posedge Asynch_in) beginif(reset) beginq1 = 1b0 ;endelse beginq1 = 1b1 ;endendendmodule测试代码:timescale 1 ns/ 1 psmodule HomeWorkTwo_test();/ test vector input registersreg As
7、ynch_in;reg clock;/ wires wire Synch_out;/ assign statements (if any) HomeWorkTwo i1 (/ port map - connection between master ports and signals/registers .Asynch_in(Asynch_in),.Synch_out(Synch_out),.clock(clock);initial begin clock = 1b0 ;Asynch_in = 1b0 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40
8、 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 $stop ;$display(“Running testbench“); end always begin#10 clock = clock ;end endmodule同步器三:module HomeWorkThree(input Asynch_in ,input clock ,input reset ,output reg Synch_out);reg q1 = 1b0 ;reg q2 = 1b0 ;wire temp ;wire temp2 ;wire clrq1 ;wire clrq2 ;assig
9、n temp1 = Synch_outassign temp2 = Synch_outassign clrq1 = reset|temp1 ;assign clrq2 = reset|temp2 ;always(posedge clock) beginif(reset) beginSynch_out = 1b0 ;endelse beginSynch_out = q2 ;endendalways(posedge clock) beginif(clrq2) beginq2 = 1b0 ;endelse beginq2 = q1 ;endendalways(posedge Asynch_in) b
10、eginif(clrq1) beginq1 = 1b0 ;endelse beginq1 = 1b1 ;endendendmodule测试代码:timescale 1 ns/ 1 psmodule HomeWorkThree_test();/ test vector input registersreg Asynch_in;reg clock;reg reset;/ wires wire Synch_out;/ assign statements (if any) HomeWorkThree i1 (/ port map - connection between master ports an
11、d signals/registers .Asynch_in(Asynch_in),.Synch_out(Synch_out),.clock(clock),.reset(reset);initial begin clock = 1b0 ;reset = 1b1 ;Asynch_in = 1b0 ;#100 reset = 1b0 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 Asynch_in = 1b0 ;#40 Asynch_in = 1b1 ;#40 reset = 1b1 ;#40 Asynch_in = 1b1 ;#40 Asynch_in = 1b0 ;#40 $stop ;$display(“Running testbench“); end always begin#1 clock = clock ;end endmodule