开发流程:
(1)设计规范
(2)文本编辑
(3)功能仿真
(4)逻辑综合
(5)布局布线
(6)时序仿真
(7)编程烧板
基本结构:
模块:
module<模块名>(<端口列表>)
端口说明(input,output等)
参数定义
数据类型定义
连续赋值语句(assign)
过程块(initial,always)
底层模块实例
任务和函数
延时说明块
endmodule
模块的描述方式:
举例:
4个T触发器级联,每一级T触发器的输出作为下一级T触发器的时钟输入。

解释:
在数字电路中,凡在CP时钟脉冲控制下,根据输入信号T取值的不同,具有保持和翻转功能的电路,即当T=0时能保持状态不变,T=1时一定翻转的电路,都称为T触发器。
T触发器的特性方程
Q*=TQ‘+T’Q (Q为当前的值,Q*是输出)

(1)行为级或算法级的描述
可以按照要求的设计算法来实现,不用关心硬件实现的细节。类似C语言
module cnt_4bit( q, clr, clk);
output [3:0] q;
input clr, clk;
reg [3:0] q;
always @ (posedge clr or negedge clk) begin
if (clr)
q = 4'd0;
else
q = (q + 1) % 16;
end
endmodule
(2)数据流描述方式(数据流级建模)
也称为RTL(寄存器传输级)描述方式。
需要知道数据是如何在寄存器之间传输的以及将被如何处理。
module cnt_4bit_1(q, clr, clk);
output [3:0] q;
input clr, clk;
T_ff tff0(q[0], clr, clk);
T_ff tff0(q[1], clr, q[0]);
T_ff tff0(q[2], clr, q[1]);
T_ff tff0(q[3], clr, q[2]);
end module
module T_ff(q, clr, clk);
output q;
input clr, clk;
edge_dff ff1(q, , ~q, clr, clk);
endmodule
module edge_dff(q, qbar, d, clr, clk);
output q, qbar;
input d, cle, clk;
wire s, sbar, r, rbar, cbar;
assign cbar = ~clr;
//输入锁存器;锁存器是电平敏感的。二一个边沿敏感的触发器需要使用3个RS锁存器来实现
assign sbar = ~(rbar & s),
s = ~(sbar & cbar & ~clk),
r = ~(rbar & ~clk & s),
rbar = ~(r & cbar & d);
//输出锁存
assign q = ~(s & qbar),
qbar = ~(q & r & cbar);
endmodule
(3)门级描述方式(门级建模)
按照逻辑门和它们之间的互联来实现的。
负边沿触发D触发器:
module edge_dff_1(q, qbar, d, clr, clk);
output q, qbar;
input d, clr, clk;
wire cbar, clkbar, sbar, s, r, rbar;
not N1(cbar, clr),
N2(clkbar, clk);
nand NA1(sbar, rbar, s),
NA2(s, sbar, cbar, clkbar),
NA3(r, s, clkbar, rbar),
NA4(rbar, r, cbar, d),
NA5(q, s, qbar),
NA6(qbar, q, cbar, r);
endmodule
(4)开关级描述方式(开关级建模)
output out;
input a,b;
wire c;
supply1 pwr;
supply0 gnd;
pmos(c, pwr, b);
pmos(out, c, a);
nmos(out, gnd, a);
nmos(out, gnd, b);
endmodule
(1)设计规范
(2)文本编辑
(3)功能仿真
(4)逻辑综合
(5)布局布线
(6)时序仿真
(7)编程烧板
基本结构:
模块:
module<模块名>(<端口列表>)
端口说明(input,output等)
参数定义
数据类型定义
连续赋值语句(assign)
过程块(initial,always)
底层模块实例
任务和函数
延时说明块
endmodule
模块的描述方式:
举例:
4个T触发器级联,每一级T触发器的输出作为下一级T触发器的时钟输入。
解释:
在数字电路中,凡在CP时钟脉冲控制下,根据输入信号T取值的不同,具有保持和翻转功能的电路,即当T=0时能保持状态不变,T=1时一定翻转的电路,都称为T触发器。
T触发器的特性方程
Q*=TQ‘+T’Q (Q为当前的值,Q*是输出)
(1)行为级或算法级的描述
可以按照要求的设计算法来实现,不用关心硬件实现的细节。类似C语言
module cnt_4bit( q, clr, clk);
output [3:0] q;
input clr, clk;
reg [3:0] q;
always @ (posedge clr or negedge clk) begin
if (clr)
q = 4'd0;
else
q = (q + 1) % 16;
end
endmodule
(2)数据流描述方式(数据流级建模)
也称为RTL(寄存器传输级)描述方式。
需要知道数据是如何在寄存器之间传输的以及将被如何处理。
module cnt_4bit_1(q, clr, clk);
output [3:0] q;
input clr, clk;
T_ff tff0(q[0], clr, clk);
T_ff tff0(q[1], clr, q[0]);
T_ff tff0(q[2], clr, q[1]);
T_ff tff0(q[3], clr, q[2]);
end module
module T_ff(q, clr, clk);
output q;
input clr, clk;
edge_dff ff1(q, , ~q, clr, clk);
endmodule
module edge_dff(q, qbar, d, clr, clk);
output q, qbar;
input d, cle, clk;
wire s, sbar, r, rbar, cbar;
assign cbar = ~clr;
//输入锁存器;锁存器是电平敏感的。二一个边沿敏感的触发器需要使用3个RS锁存器来实现
assign sbar = ~(rbar & s),
s = ~(sbar & cbar & ~clk),
r = ~(rbar & ~clk & s),
rbar = ~(r & cbar & d);
//输出锁存
assign q = ~(s & qbar),
qbar = ~(q & r & cbar);
endmodule
(3)门级描述方式(门级建模)
按照逻辑门和它们之间的互联来实现的。
负边沿触发D触发器:
module edge_dff_1(q, qbar, d, clr, clk);
output q, qbar;
input d, clr, clk;
wire cbar, clkbar, sbar, s, r, rbar;
not N1(cbar, clr),
N2(clkbar, clk);
nand NA1(sbar, rbar, s),
NA2(s, sbar, cbar, clkbar),
NA3(r, s, clkbar, rbar),
NA4(rbar, r, cbar, d),
NA5(q, s, qbar),
NA6(qbar, q, cbar, r);
endmodule
(4)开关级描述方式(开关级建模)
nor门:
output out;
input a,b;
wire c;
supply1 pwr;
supply0 gnd;
pmos(c, pwr, b);
pmos(out, c, a);
nmos(out, gnd, a);
nmos(out, gnd, b);
endmodule