• 2021-04-14
    根据下列真值表,采用case语句描述一个8-3编码器,输入信号:x[7..0]时,输出y[2..0]。输入X输出YX0X1X2X3X4X5X6X7Y2Y1Y01000000000001000000001001000000100001000001100001000100000001001010000001011000000001111
  • module encode8_3(x,y);input[7:0] x;output[2:0] y;reg[2:0] y;always @(x)begincase (x[7:0])8'b00000001:y[2:0] = 3'b000;8'b00000010:y[2:0] = 3'b001;8'b00000100:y[2:0] = 3'b010;8'b00001000:y[2:0] = 3'b011;8'b00010000:y[2:0] = 3'b100;8'b00100000:y[2:0] = 3'b101;8'b01000000:y[2:0] = 3'b110;8'b10000000:y[2:0] = 3'b111;endcaseendendmodule

    内容

    • 0

      int main()执行结果是(){int x=2,y=1; switch(x) { case 1: y=x ; break; case 2: y=-x ; case 3: y=x*3 ; break; case 4: y=4*x; } printf(“%d\n”,y);}

    • 1

      1、main(){ int x=2,y;switch(x){ case 1: y=x ; break;case 2: y=-x ;case 3: y=x*3 ; break;case 4: y=4*x;}printf(“%d\n”,y);}程序运行结果:__________________

    • 2

      【单选题】分段函数: ,下面程序段中正确的是__________。 A. If x < 0 Then y = 0 If x < 1 Then y = 1 If x < 2 Then y = 2 If x >= 2 Then y = 3 B. If x >= 2 Then y = 3 If x >= 1 Then y = 2 If x > 0 Then y = 1 If x < 0 Then y = 0 C. If x < 0 Then y = 0 ElseIf x > 0 Then y = 1 ElseIf x > 1 Then y = 2 Else y = 3 End If D. If x > =2 Then y = 3 ElseIf x > =1 Then y = 2 ElseIf x > =0 Then y = 1 Else y = 0 End If

    • 3

      x+y=8()x-y=4()求x和y各等于几?A.()x=6()y=2()B.()x=5()y=3()C.()x=7()y=1()D.()x=3()y=5

    • 4

      以下程序的输出结果是( )。main(){ int x=1,y=2; void swap(int x,int y); swap(x,y); printf("x=%d,y=%d\n",x,y);}void swap(int x,int y){ x=3,y=4;} A: x=3,y=4 B: x=1,y=2 C: x=3 y=4 D: x=1 y=2