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
举一反三
- 以下语言是数据流建模方式吗? A: xor x1(a,b,c): B: assign adder_out = mult_out + out; C: always @ (a or b or sel) begin if (sel) c = a; else c = b;?end D: and a1(out,in1,in2);
- 下列Verilog HDL程序所描述电路是( )module TRI (EN, IN, OUT);input IN, EN;output OUT;assign OUT = EN ? IN : 1bZ;endmodule
- 在语句assign Y = sel ? 0 : 1;中,当sel=0时,Y的值为( )? z|x|0|1
- 在存储过程中,参数的模式有( )。 A: IN、OUT B: IN、OUT、IN OUT C: INPUT、OUTPUT D: OUT、INOUT
- 中国大学MOOC: 在语句assign Y = sel ? 0 : 1;中,当sel=0时,Y的值为( )
内容
- 0
定义一个模块时,若要声明一个8位的输出端OUT,则下列语句合适的是 。 A: output [7:0]OUT B: output [8:0]OUT; C: output [8]OUT; D: output OUT[8];
- 1
判断以下Verilog代码片段,在modelsim软件里仿真时,out输出是否有正常的波形?module unit(……);reg clk;reg [3:0] out ;always @(posedge clk)beginout <= out + 1;endendmodule A: 是 B: 否
- 2
下面是四选一数据选择器的部分代码,要补全代码可以选择( )。(?)always@(*)begin if (s==2'b00) y=p0; else if (s==2'b01) y=p1; else if (s==2'b10) y=p2; else y=p3;end A: module mux4_1 (p3,p2,p1,p0,s,y);input p3,p2,p1,p0;input[1:0] s;output y;... ...endmodule B: module mux4_1 (p3,p2,p1,p0,s,y);input p3,p2,p1,p0;input[1:0] s;output y;reg y;... ...endmodule C: module mux4_1 ( input p3,p2,p1,p0; input[1:0] s; output reg y;)... ...endmodule D: module mux4_1 (input p3,p2,p1,p0;input[1:0] s;output y )... ...endmodule
- 3
指出下面信号的最高位和最低位。reg [1:0] SEL
- 4
下列代码描述中,不能产生时序逻辑的( ) A: always (*)begainif (a&b) rega=c;elserega=0;end B: always (*)begainif (a&b) rega=c;y=rega;end C: always @(a)begainCase(a)2’b00: out=4’b0001;2’b01: out=4’b0010; 2’b10: out=4’b0100;endcaseend