CCIE 发表于 2010-6-28 09:47:20

学习了!!!!!!!!!!!!!!!!!!!!!!!!

CHANG 发表于 2010-6-28 09:53:04

公司里的规范是这样啊。<br>
不错,感谢11楼的。

CHANG 发表于 2010-6-28 11:20:34

因为看得书也不是很多,见过的testbench都是定义类型和赋初值分开的,<br>
而且觉得这一段<br>
wire temp={dout,dout};<br>
always @(posedge clk or negedge nrst)<br>
if (~nrst)&nbsp; &nbsp;&nbsp; &nbsp; dout&lt;=0;<br>
else if (sel==1) dout&lt;=din;<br>
else&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; dout&lt;=temp;<br>
很别扭!<br>
多谢给位,尤其是11# !!!<br>
比较习惯这样写:<br>
`define clk_cycle 10<br>
module ex2_6;<br>
//test bench<br>
<br>
reg clk;<br>
reg nrst;<br>
reg sel;<br>
reg din;<br>
reg temp;<br>
wire dout;<br>
<br>
always `clk_cycle clk=~clk;<br>
<br>
assign dout=temp;<br>
<br>
initial begin<br>
&nbsp; &nbsp; &nbsp; &nbsp; clk=0;<br>
&nbsp; &nbsp; &nbsp; &nbsp; nrst=1;<br>
&nbsp; &nbsp; &nbsp; &nbsp; sel=0;<br>
&nbsp; &nbsp; &nbsp; &nbsp; din=0;<br>
end<br>
<br>
initial begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#50 nrst=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#70 nrst=1;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#80 sel=1;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;#15 sel=0;<br>
end<br>
<br>
integer seed=4;<br>
<br>
always@(posedge clk)<br>
din&lt;=#1 $random(seed);<br>
<br>
always @(posedge clk or negedge nrst)<br>
if (~nrst)&nbsp; &nbsp;&nbsp; &nbsp; temp&lt;=0;<br>
else if (sel==1) temp&lt;=din;<br>
else&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; temp&lt;={temp,temp};<br>
<br>
endmodule<br>
<br>
[ 本帖最后由 bonesoul 于 2006-8-14 20:05 编辑 ]

AAT 发表于 2010-6-28 12:06:33

受教了,继续学习

VVC 发表于 2010-6-28 12:22:17

感谢11楼提供的代码书写规范,哈哈,由长知识了。
        http://bbs.vibesic.com/images/smilies/default/biggrin.gif

ATA 发表于 2010-6-28 12:47:03

没看出不规范的

FFT 发表于 2010-6-28 13:03:10

有所收获!

ANG 发表于 2010-6-28 14:04:47

just so so...

UFP 发表于 2010-6-28 15:40:34

没什么问题

usb 发表于 2010-6-28 17:03:59

多谢大侠指教
页: 1 [2] 3
查看完整版本: testbench的写法,这样写是规范的么?