Verilog:使用基本模块与位运算符的实现

Verilog:使用基本模块与位运算符的实现,verilog,iverilog,Verilog,Iverilog,我正在阅读的教科书使用内置的基本模块实现了1位加法器: module yAdder1(z, cout, a, b, cin); output[0:0] z, cout; input[0:0] a, b, cin; wire[0:0] tmp, outL, outR; xor left_xor(tmp, a, b); xor right_xor(z, cin, tmp); and left_and(outL, a, b); a

我正在阅读的教科书使用内置的基本模块实现了1位加法器:

module yAdder1(z, cout, a, b, cin);
     output[0:0] z, cout;
     input[0:0] a, b, cin;
     wire[0:0] tmp, outL, outR;

     xor left_xor(tmp, a, b);
     xor right_xor(z, cin, tmp);
     and left_and(outL, a, b);
     and right_and(outR, tmp, cin);
     or my_or(cout, outR, outL);
endmodule
但是为什么不使用位运算符呢?似乎更简单

module yAdder1(z, cout, a, b, cin);
     output[0:0] z, cout;
     input[0:0] a, b, cin;

     assign z = (a ^ b) ^ cin;
     assign cout = (a & b) | ((a ^ b) & cin);
endmodule

除非位运算符隐式使用基元模块?

在门级模型中,内置基元是表示门的方便方法。通常由其他工具生成。除此之外,没有太多的理由在常规verilog中使用它们

你可能会遇到的缓冲区很少,主要是各种三态缓冲区,它们可以用来驱动公交车。但所有其他的都没有那么多使用


它们在模拟中不会隐式使用

这只是一种不同的写作风格。前者是结构形式,后者更倾向于行为/功能形式

再加上@Serge的观点,如果你试图单独地综合它们,你会看到一个非常相似(可能完全相同)的网表。 以结构化的方式编写代码将简化合成工具将RTL映射到现有原语(在特征库中)的工作——缺点是很难理解查看结构化代码的功能

啊,我明白了,门(结构)级抽象与功能和算法级(行为)抽象。每个人都有自己的优点和缺点。