組合邏輯電路設計入門 ——Verilog HDL語言
三人表決電路
module JG3(ABC,X,Y);
//input Port(s)
input [2:0] ABC;
//output Port(s)
output X, Y;
reg X, Y;
//Additional Module Item(s)
always@(ABC)
// 請在下面添加代碼,實作滿足三人表決器真值表;
/********** Begin *********/
case(ABC)
3'b000:{X,Y} = 2'b01;
3'b001:{X,Y} = 2'b00;
3'b010:{X,Y} = 2'b00;
3'b011:{X,Y} = 2'b00;
3'b100:{X,Y} = 2'b00;
3'b101:{X,Y} = 2'b10;
3'b110:{X,Y} = 2'b10;
3'b111:{X,Y} = 2'b10;
endcase
/********** End *********/
endmodule
多路選擇器
module mux21(a,b,s,y);
input a,b,s;
output y;
reg y;
always @(a,b,s)
// 請在下面添加代碼,實作當選擇信号S為0時選中a,為1時選中b;
/********** Begin *********/
begin
if(s == 1'b0) y = a;
if(s == 1'b1) y = b;
/********** End *********/
end
endmodule