Problem Solutions – Chapter 4
12
4-19.
c)
// Serial odd parity generator: Verilog Process Description
// problem 4–19 c, 5th edition
module serial_odd_parity_generator (CLK, RESET, X, Y, Z);
input CLK, RESET, X, Y;
output Z;
reg state, next_state;
parameter state0 = 1’b0, state1 = 1’b1;
reg Z;
// next state function: implements next state as function
// of X, Y and state
always @(X, Y or state)
begin
case (state)
state0: next_state = ({X,Y} == 2’b10) ? state1: state0;
state1: next_state = ({X,Y} == 2’b00) ? state1: state0;
endcase
Format: XY/Z (x = unspecified)
10/0
x1/x