1.Verilog代码实现
//file name not_gate
//file function : 实现非门的逻辑运算
//file version : 1.0v
//date : 2023/3/30
//Author : ZihangNie
//********************************************************************
module not_gate (
// input signal
input a , //输入信号a
//output signal
output y //输出信号y
) ;
assign y = ~ a ;
endmodule
2 test_bench文件仿真
//file name : tb_not_gate
//file funciton : 非门的仿真文件
//file version : 2023/3/30
//Author :ZihangNie
//*********************************
`timescale 1ns/1ps
module tb_not_gate ();
//input define
reg a;
reg sys_clk;
reg sys_rst_n;
//output define
wire y ;
//初始化操作
initial begin
//先对信号进行初始化
sys_clk = 1'b0 ;
sys_rst_n = 1'b0 ;
a = 1'b0 ;
#200
sys_rst_n = 1'b1;
a = 1'b1;
#200
a= 1'b0;
$stop ;
end
always #10 sys_clk = ~sys_clk;
//对模块进行例化
not_gate u_not_gate(
.a(a),
.y(y)
);
endmodule
time_scale 后面跟的是时间单位和仿真的精度
实现预期的功能