1.  3线8线编码器CT74138的逻辑符号如图所示,A2、A1、A0是3线输入端,其中A2的权值最高,依次为A1和A0;S1、S2N、S3N是使能控制输入端,S1为高电平有效,S2N和S3N为低电平有效;YN0~YN7是8线输出端,低电平有效;用Verilog HDL编写CT74138的源程序。(Verilog HDL的关键字见附录)
附录Verilog HDL关键词
always and assign begin buf
bufff0 bufifl case casex casez
cmos deassign default defparam disable
edge else end endcase endfunction
endmodule endprimitive endspecify endtable endtask
event for force forever fork
function highz0 highz1 if initial
inout input integer join large
macromodule medium module hand negedge
nmos nor not notif0 nottifl
or output parameter pmos posedge
primitive pull0 pull1 pulldown pullup
rcmos real realtime reg release
repeat mmos rpmos rtran rtranif0
reranifl scalared sinall specify specparam
strength strong0 strong1 supply0 supply1
table task time tran tranif0
tranifl tri tri0 tril triand
trlor trirg vectored wait wand
weak0 weak1 while wire wor
xnot xor      
   
【正确答案】CT74138的Verilog HDL设计源程序CT74138.v如下:
   module CT74138(A0,A1,A2,S1,S2N,S3N,YN0,YN1,YN2,YN3,YN4,YN5,YN6,YN7);
   input
   A0,A1,A2,S1,S2N,S3N;
   output
   YN0,YN1,YN2,YN3,YN4,YN5,YN6,YN7;
   reg
   YN0,YN1,YN2,YN3,YN4,YN5,YN6,YN7;
   reg[7:0]
   Y_SIGNAL;
   always
   begin
   if(S1 &&~S2N &&~S3N)
   begin
   case({A2,A1,A0})
   3'b000:Y_SIGNAL<=8'b11111110;
   3'b001:Y_SIGNAL<=8'b11111101;
   3'b010:Y_SIGNAL<=8'b11111011;
   3'b011:Y_SIGNAL<=8'b11110111;
   3'b100:Y_SIGNAL<=8'b11101111;
   3'b101:Y_SIGNAL<=8'b11011111;
   3'b110:Y_SIGNAL<=8'b10111111;
   3'b111:Y_SIGNAL<=8'b01111111;
   default: Y_SIGNAL<=8'b11111111;
   endcase
   end
   else Y_SIGNAL <= 8'b 11111111 ;
   YN0 <= Y_SIGNAL[0];
   YN1 <= Y_SIGNAL[1];
   YN2 <= Y_SIGNAL[2];
   YN3 <= Y_SIGNAL[3];
   YN4 <= Y_SIGNAL[4];
   YN5 <= Y_SIGNAL[5];
   YN6 <= Y SIGNAL[6];
   YN7 <= Y_SIGNAL[7];
   end
   endmodule
【答案解析】