HDL report 3
HDL report 3
HDL report 3
Ex 5.22
a)
0 10 15 20 40 50 70 85
w
b)
Ex 5.23
a) b)
Ex 5 . 27
S0 : begin y_out = 0;
if (x_in) next_state = S1; else next_state = S0;
end
endcase
endmodule
Ex 5 . 28
module ex5_28_a (output reg A, input x, y, clk, reset);
parameter S0 = 1’b0, S1 = 1b’1;
reg state, next_state ;
assign A = state ;
always @ (posedge clk , negedge reset)
if (~reset) state <= s0; else state <= next_state;
always @ (state, x, y)
case (state)
S0:
case ({x, y})
2'b00, 2'b11: next_state = S0;
2'b01, 2'b10: next_state = S1;
endcase
S1:
endcase
endmodule
wire y_xor_x , w ;
xor
G1 (y_xor_x , x , y ) , w
G1 G2
Y_xor_x
G2 (w , y_xor_x , A ) ;
endmodule
// rest of exercise 5.28 b
module DFF ( output reg Q , input D , clk , reset ) ;
always @ (posedge clk , negedge reset)
wire A1 , A2 ;
repeat (20)
end
initial fork
#5 reset = 1 ;
begin x = 0 ; y = 0 ; end // 00
#20 y = 1 ; //01
#50 y = 1 ; // 11
#65 reset = 0 ;
begin x = 0 ; y = 0 ; end // 00
#70 y = 1 ; //01
# 100 y = 1 ; // 11
join
endmodule
Ex 5 .30
Ex 5.35
always @ (state , x , y )
case (state )
S0:
case ( {x,y})
2’b00 , 2’b01 : next_state = S0 ;
2’b10 : next_state = S3 ;
2’b11 : next_state = S1 ;
endcase
S1 :
State table for circuit of
case ( {x,y}) exercise 5.6
2’b00 , 2’b01 : next_state = S0 ;
2’b10 , 2’b11 : next_state = S2 ;
endcase
S2 :
case ( {x,y})
2’b00 , 2’b01 : next_state = S0 ;
2’b10 : next_state = S3 ;
2’b11 : next_state = S1 ;
endcase
S3 :
case ( {x,y})
2’b00 , 2’b01 : next_state = S0 ;
2’b10 , 2’b11 : next_state = S3 ;
endcase
endcase
endmodule