设计理论
1.设计输入
2.写代码
3.编译(语法错误)
4.仿真(理想状态下)
5.下板
6.时序
设计思想:模块化
设计代码:module(模块) 文件名 (端口);
端口类型(input output
inoutput)
数据类型:(reg wire)
功能模块
endmodule
Field Programmable Gate Array 实现一个与门
在电路里,理解为两个开关串联
verilog
module and_gate(
input a,
input b,
output s
);
assign s = a & b;
endmodule
vhdl
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY and2 IS
PORT(a,b:IN STD_LOGIC;
c:OUT STD_LOGIC);
END and2;
ARCHITECTURE and2_behavior OF and2 IS
BEGIN
c<= a AND b;
END and2_behavior;
verilog tb
module and_gate_tb;
// Inputs
reg a;(语法规定,人为定义)
reg b;(语法规定,人为定义)
// Outputs
wire s;(语法规定)
// Instantiate the Unit Under Test (UUT)
and_gate and_gate_inst ( //实例化
.a(a),
.b(b),
.s(s)
);
initial begin(赋值开始)
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 0;
b = 1;
#100;
a = 1;
b = 0;
#100;
a = 1;
b = 1;
#100;
// Add stimulus here
end
endmodule
注:基于ise平台