Phần 4: Verilog HDL và mạch tổ hợp (1/11)
Bài giải:
module dahop (input [7:0] in0, in1, in2, in3, input [1:0] select, output [7:0] out);
assign out = (select==2’b00) ? in0 :
(select==2’b01) ? in1 :
(select==2’b10) ? in2 : in3 ;
endmodule
kq:
2/ Đề:
Giải:
module led7doan (input [3:0] Q, output [0:6] HEX) ;
assign HEX = (Q == 4’d0) ? 7’b0000001 :
(Q == 4’d1) ? 7’b1001111 :
(Q == 4’d2) ? 7’b0010010 :
…………………………………………
(Q == 4’d9) ? 7’b0000100 : 7’b1111111 ;
Endmodule
3/
Giải:
Out= 1 (true)
Out= 0 (false)
4/
Giải:
1)
2)
3)
4)
5/
Giải:
Out = 0
Out = 1
Out = unknow (không so sánh được giá trị x, chỉ so sánh được 2 giá trị 0,1)
Out = 1 (so sánh dc x)
Module test (A, B, AlonB, AbangB) ;
Input [3:0] A, B ;
Output AlonB, AbangB;
assign AlonB = A > B;
assign AbangB = A==B;
endmodule
6/
Giải:
Out = 1101
Out = 0011
7/
Giải:
Module add_sub_4bit (A, B, control, S) ;
Input [3:0] A, B; input control;
Output [3:0] S;
assign S = (control == 1’b0) ? A+B : A-B;
endmodule
8/
Giải:
Module test (input [0:0] nhiphan, output [3:0] tram, chuc, donvi ;
assign tram= nhiphan/7’d100;
assign chuc=(nhiphan/ 4’d10)%4’d10;
assign donvi=nhiphan %4’10;
endmodule
9/
Giải:
Out=1111
Out=101x
Out=000010
10/
Giải:
Out = 0010
Out = 0000
Out=1110
11/
Giải:
module test (input CLX, output reg Q);
always @ ( posedge CLK)
Q <= ~Q;
Endmodule
12/
Giải:
50 000 000 / ( 2^n) =1Hz n = 26 hoặc 25