實驗現象:
在本實驗中,將工程中的D觸發器、JK觸發器例項化,對應其真值表,用signal對其進行
檢驗,利用SignaTap II觀察分析波形。
核心程式碼:
module D( input CLK, input rst_n, input Data, output Q, output Qn ); //-----------------------D---------------------------// reg q,qn; always@(posedge CLK) begin if(!rst_n) begin q <= 1'd0; qn <= 1'd1; end else begin q <= Data; qn <= ~Data; end end assign Q = q; assign Qn =qn; //-------------------endmodule-----------------------// endmodule
module J_K( input CLK, input rst_n, input J, input K, output Q, output Qn ); //---------------------J_K---------------------------// reg q,qn; always@(posedge CLK) begin if(!rst_n) begin q <= 1'd0; qn <= 1'd1; end else begin case({J,K}) 2'b00: begin q <= q; qn <= qn; end 2'b01: begin q <= 1'd0; qn <= 1'd1; end 2'b10: begin q <= 1'd1; qn <= 1'd0; end 2'b11: begin q <= ~q; qn <= ~qn; end default : begin q <= 1'd0; qn <= 1'd1; end endcase end end assign Q = q; assign Qn = qn; //-------------------endmodule-----------------------// endmodule
實驗方法及指導書:
連結:http://pan.baidu.com/s/1nv82r7j 密碼:d2qp