<一>建立一個工程
注:Xilinx ISE的安裝在此不再過多說明,網上有參考資料
1.打開軟件進入如下界面
2.創建工程
File-->New Project
3.創建文件(我取名為firstTry)
右鍵選擇New Source;
設置參數
4.編寫代碼
module half_add( input a, input b, output sum, output cout );
assign sum = a^b;
assign cout = a&b;
endmodule
5.測試代碼
選擇項目並且右鍵(New Source)
測試代碼如下:
module half_addtest;
// Inputs
reg a;
reg b;
// Outputs
wire sum;
wire cout;
// Instantiate the Unit Under Test (UUT)
half_add uut ( .a(a), .b(b), .sum(sum), .cout(cout) );
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
//#100; 這句最好暫時不用
// Add stimulus here
#0.001 a = ~a;
#0.001 b = ~b;
#0.001 a = ~a;
#0.001 b = ~b;
#0.001 a = ~a;
#0.001 b = ~b;
#0.001 a = ~a;
#0.001 b = ~b;
end
endmodule
測試步驟:
6.測試代碼分析
#0.001 a = ~a;
注意:#N中的N是以ns為單位的,而在測試截圖中的時間單位是ps,其中 1ns = 1000 ps;
說到這里也知道測試代碼中的#100為什么不要了的原因
這句話2就是從執行這句代碼起,等待0.001ns后a取反,然后結合測試截圖就可以理解了。
7.生成頂層文件
雙擊Synthesize中的View RTL Schematic