顯示具有 Cadence NC-Verilog 標籤的文章。 顯示所有文章
顯示具有 Cadence NC-Verilog 標籤的文章。 顯示所有文章

2020年11月30日 星期一

使用MakeFile執行NC-Verilog

  使用 NCLaunch編譯時在操作滑鼠點選要編譯的Verilog檔案與選取Testbench檔案比較花時間,改用MakeFile會比較節省時間。

1. 在Verilog與Testbench檔案的下增加一個MakeFile檔案。


2. 開啟並輸入。
VLOG =ncvlog
ELAB =ncelab
SIM =ncsim -gui

SRC =Test.v testbench.v
TP =testbench

VLOG_CONF =-update -linedebug -status
ELAB_CONF =-access +wc -status
SIM_CONF =-status

RM =-rm -rf
TMPFILE =*.log *.key INCA_libs waves.shm

all ::clean compile elab sim 

compile:
<TAB>$(VLOG) $(SRC) $(VLOG_CONF)

elab:
<TAB>$(ELAB) $(TP) $(ELAB_CONF)

sim:
<TAB>$(SIM) $(TP) $(SIM_CONF)

clean:
<TAB>$(RM) $(TMPFILE)


3. 開啟Terminal,在MakeFile路徑中輸入"make all",按"Enter"鍵後,就會自動編譯並開啟模擬視窗。

4. 開啟模擬視窗,其它操作與之前相同。

2018年12月23日 星期日

NC Verilog與ModelSim的模擬結果不一致

(1). 上圖為ModelSim模擬的結果,下圖為NC Verilog模擬的結果,一模一樣的Verilog code卻產生不同的結果。


















(2). 主要是因為module的input輸入值,需要先宣告一個reg接受並且給予初始值。

module PureBus(
.....
input [2:0]Mode,
.....
);

reg [2:0]mode_set;

always@(posedge Clk or negedge Reset)
begin
if(!Reset)
begin
        ........
r_mode_set <= 0;
end
else
begin
                 .......
                 r_mode_set <= Mode;
        end
end
endmodule

修改完成,再用NC Verilog模擬,結果就與ModelSim模擬的結果一樣。有使用Active HDL測試,發現Active HDL與NC Verilog模擬的結果是一樣的,Active HDL與NC Verilog相對於ModelSim對於電路初始值得要求比較嚴謹。

2018年12月21日 星期五

NC-Verilog(3) - 模擬

(1). 選擇"Tools" > "Elaborator..."。

(2). 勾選"Other Options",輸入"-timescale 1ns/1ns",設定模擬 的(單位)/(精度),設定完成按"OK"。
**如果所有的Verilog程式碼開頭都有加入"-timescale 1ns/1ns",可以省去此項步驟。

(3). 點選"testbench",再點選"Elaborator"。

(4). 點選"worklib.testbench.module",再點選"Simulator"。

(5). 開啟"SimVision"視窗。

(6). 點選"testbench",再點選"Send"。

(7). 開啟"Waveform"視窗,點選"Run"視窗執行並顯示模擬結果。


NC-Verilog(2) - 執行NCLaunch與編譯

 (1). 開啟Linux作業系統中的"Terminal",輸入"nclaunch -new &",開啟NCLaunch。

(2). 點選"Multiple Step"。

(3). 點選"...",選擇上個章節Verilog的程式路徑,之後按"OK"。

(4). 新的專案要建立Library,點選"Yes"。

(5). 點選"OK"。

(6). 點選"OK"。

(7). 點選需要編譯的Verilog程式,再點選"Verilog compiler",開始編譯。

NC-Verilog(1) - 硬體描述語言撰寫

NC-Verilog下的三個工具:
ncvlog (Compiles the Verilog source files.)
ncelab (Elaborates the design and generates a simulation snapshot.)
ncsim (Simulates the snapshot.)

(1). 先產生Verilog程式,如下所示。

/////////////////////////////Schematic
module Test(a, b, c, d, En, Sel, f);
input  a, b, c, d, En, Sel;
output f;

wire   f;
wire   g, h, i, j;

assign g = a | b;
assign i = g & En;
assign h = c | d;
assign j = h & En;
assign f = (Sel==1'b0) ? i : j;

endmodule

/////////////////////////////Testbench
module testbench;

reg a, b, c, d, En, Sel;

wire f;

Test UUT(
  .a(a),
  .b(b),
  .c(c),
  .d(d),
  .En(En),
  .Sel(Sel),
  .f(f) );

initial

begin
 a   = 1'b0; // Time = 0
 b   = 1'b1;
 c   = 1'b0;
 d   = 1'b1;
 En  = 1'b0;
 Sel = 1'b0;

 #20;    // Time = 20
 a  = 1'b1;
 #10;    // Time = 30
 b  = 1'b0;
 c  = 1'b1;
 #10;    // Time = 40
 a  = 1'b0;
 #10;    // Time = 50
 En = 1'b1;
 #10;    // Time = 60
 c  = 1'b0;
 #10;    // Time = 70
 a  = 1'b1;
 d  = 1'b0;
 #20;    // Time = 90
 c  = 1'b1;
 #20;    // Time = 110
 a  = 1'b0;
 #10;    // Time = 120
 a  = 1'b1;
 #10;    // Time = 130
 c  = 1'b0;
 Sel= 1'b1;
 #10;    // Time = 140
 a  = 1'b0;
 #30;    // Time = 170
 a  = 1'b1;
 #10;    // Time = 180
 c  = 1'b1;
 #20;    // Time = 200
 a  = 1'b0;
end

endmodule

(2). 在Linux作業系統中建立一個目錄,並將Schematic與Testbench,複製至目錄中。