Answer:
The inputs are only four different types [0, 1, z, x]. Assume inputs are A and B, C as output. The truth table are as following:
Input A | Input B | Output C | Comments |
0 | 0 | 1 | |
0 | 1 | 1 | |
1 | 0 | 1 | |
1 | 1 | 0 | |
0 | Z | 1 | The p-gate turn on with "0" input, the "z" input has no effect on n-gate. |
Z | 0 | 1 | The p-gate turn on with "0" input, the "z" input has no effect on n-gate. |
1 | Z | X | The p-gate is off with "1" input, but the "z" input has no effect on n-gate. The result is unknown. |
Z | 1 | X | The p-gate is off with "1" input, but the "z" input has no effect on n-gate. The result is unknown. |
Z | Z | X | The "z" input has no effect on both p-gate and n-gate. The result is unknown. |
0 | X | X | The p-gate turn on with "0" input, the "X" input has unknown effect on n-gate. The result is unknown. |
X | 0 | X | The p-gate turn on with "0" input, the "X" input has unknown effect on n-gate. The result is unknown. |
Can we put Z on the output C?
Answer:
For this circuit, it's impossible. Both inputs A and B are tied with p-gate and n-gate. There's no way to put both "0" and "1" in the same input A or input B.
2) Write the verilog code to create the following patterns:
000->001->010->100->000->001.......
Answer:
reg [0:2] result;
reg [0:3] temp;
always@(posedge clk or reset)
begin
if(!reset)
begin
temp= 4'b0001;
result = 3'b000;
end
else
begin
result <= temp[2:0];
temp << 1; // shift 1 bit to the left
temp[3] = temp[0]; // make the chain connected
end
end
3) Given the following FIFO and rules, how deep does the FIFO need to be to
prevent underflowing or overflowing?
c
RULES: 1) frequency(clk_A) = frequency(clk_B) / 4 2) period(en_B) = period(clk_A) * 100 3) duty_cycle(en_B) = 25%
Answer:
Assume clk_B is 100Mhz ( 10ns )
From rule 1, clk_A = clk_B/4 = 25MHz ( 40ns )
From rule 2, period (en_B) = clk_A*100 = 40ns * 100 = 4000ns
From rule 3, duty_cycle(en_B) is 25%, so it's only 1000ns. 3000ns does not output anything.
Therefore, the FIFO size = 3000ns/40ns = 75 entries.
4) Draw a state diagram to detect the sequence "0110" ( the leading 0s cannot be used in more than one sequence).
Answer:
State machine
always (@posedge clk or reset_n)
begin
if(!reset_n)
begin
reset statement
end
else
begin
case(state)
S0:
S1:
default:
end
end
No comments:
Post a Comment