在线Verilog编程网站学习
一、门电路实例
(一)与门
模块声明:
module top_module(
input a,
input b,
output out );
endmodule
时序图:
(二)或非门
创建一个实现“或非”门的模块。或非门是其输出取反的或门
模块声明:
module top_module(
input a,
input b,
output out );
endmodule
时序图
(三)XNOR门
模块声明:
module top_module(
input a,
input b,
output out );
endmodule
时序图:
(四)7458芯片
模块声明:
module top_module (
input p1a, p1b, p1c, p1d, p1e, p1f,
output p1y,
input p2a, p2b, p2c, p2d,
output p2y );
endmodule
时序图:
二、组合电路
(一)半加法器
模块声明:
module top_module(
input a, b,
output cout, sum );
endmodule
(二)全加器
module top_module(
input a, b, cin,
output cout, sum );
endmodule
(三)3位二进制加法器
模块声明:
module top_module(
input [2:0] a, b,
input cin,
output [2:0] cout,
output [2:0] sum );
endmodule
三、时序电路
(一)D触发器
模块声明:
module top_module (
input clk, // Clocks are used in sequential circuits
input d,
output reg q );//
// Use a clocked always block
// copy d to q at every positive edge of clk
// Clocked always blocks should use non-blocking assignments
endmodule
(二)边缘捕捉寄存器
模块:
module top_module (
input clk,
input reset,
input [31:0] in,
output [31:0] out
);
endmodule
(三)DFF
模块声明:
module top_module (
input clk,
input d,
input ar, // asynchronous reset
output q);
endmodule