下面两个程序分别用显式赋值语句和隐式赋值语句实现全加器,其中哪一个利用了显式赋值语句?
A: module fulladder(SUM,C_OUT,A,B,C_IN);input A,B,C_IN;output SUM,C_OUT;assign SUM=(A^B)^C_IN;assign C_OUT=(A&B)| (A^B)&C_IN;endmodule
B: module fulladder(SUM,C_OUT,A,B,C_IN);input A,B,C_IN;output SUM,C_OUT;wire SUM=(A^B)^C_IN;wire C_OUT=(A&B)| (A^B)&C_IN;endmodule
A: module fulladder(SUM,C_OUT,A,B,C_IN);input A,B,C_IN;output SUM,C_OUT;assign SUM=(A^B)^C_IN;assign C_OUT=(A&B)| (A^B)&C_IN;endmodule
B: module fulladder(SUM,C_OUT,A,B,C_IN);input A,B,C_IN;output SUM,C_OUT;wire SUM=(A^B)^C_IN;wire C_OUT=(A&B)| (A^B)&C_IN;endmodule
举一反三
- 下面哪种代码执行后是与其他结果不一样的? A: module mux2_1(a,b,sel,out); input a,b,sel; output out; assign out=(sel==1)?a:b; endmodule B: module mux2_1(a,b,sel,out); input a,b,sel; output out; reg out; always@(a or b or sel) begin case(sel) 0: out=a; 1: out=b; endcase end endmodule C: module mux2_1(a,b,sel,out); input a,b,sel; output out; reg out; always@(*) if(sel==0) out=a; else out=b; endmodule
- 下列Verilog HDL程序所描述电路是( )module TRI (EN, IN, OUT);input IN, EN;output OUT;assign OUT = EN ? IN : 1bZ;endmodule
- 在Verilog中宏定义‘define sum a+b+c,下列宏定义使用正确的是( )。 A: Out = sum + d; B: Out = ‘sum + d; C: Out = .sum + d; D: Out = `sum + d;
- 补充程序完成一个8位奇偶校验电路。module modelsim_test (even_bit,odd_bit,a);input[7:0] a;output even_bit,odd_bit;assign even_bit =;//偶校验位assign odd_bit =;//奇校验位endmodule A: &a,~&a B: ^a, ~^a C: &a, ^a D: ^a, !a
- 下列赋值语句( )是正确的。 A: sum = sum -1 B: x+2 = x + 2 C: x + y = sum D: last = y / 0