一、门电路
目录
1、和门
模块代码
module top_module(
input a,
input b,
output out );
endmodule
实验结果:
2、无门
模块代码
module top_module(
input a,
input b,
output out );
endmodule
实验结果
3、XNOR门
模块代码:
module top_module(
input a,
input b,
output out );
endmodule
实验结果:.
二、组合电路
1、半加器全加器
模块代码:
module top_module(
input a, b,
output cout, sum );
assign cout=a&b;
assign sum=a^b;
endmodule
实验结果:
2、7420芯片
模块代码:
module top_module (
input p1a, p1b, p1c, p1d,
output p1y,
input p2a, p2b, p2c, p2d,
output p2y );
endmodule
实验结果:
3、全加器
模块代码:
module top_module(
input a, b, cin,
output cout, sum );
assign sum = a^b^cin;
assign cout = (a&b)|(a&cin)|(b&cin);
endmodule
实验结果:
三、时序电路
1、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
实验结果:
2、8位D触发器
模块代码:
module top_module (
input clk,
input [7:0] d,
output [7:0] q
);
always@(posedge clk) begin
q <= d;
end
endmodule
实验结果:
3、四位二进制计数器
模块代码
module top_module (
input clk,
input reset, // Synchronous active-high reset
output [3:0] q);
endmodule
实验结果:
总结
通过这些实验,我不仅学会了如何使用Verilog来描述各种类型的数字电路,还深入理解了数字电路的基本原理和设计方法。