2013年11月30日 星期六

Parity Encoder using conditional operator , using if else statement

// File        : Parity Encoder using conditional operator.v


module parity_encoder ( din ,dout );

output [2:0] dout ;
wire [2:0] dout ;

input [7:0] din ;
wire [7:0] din ;

assign dout = din[7] ?  0 :
  din[6] ?  1 :
  din[5] ?  2 :
  din[4] ?  3 :
  din[3] ?  4 :
  din[2] ?  5 :
  din[1] ?  6 :
  din[0] ?  7 : 1'bzzz ;


endmodule




// File        : Parity Encoder using if else statement.v


module parity_encoder ( din ,dout );

output [2:0] dout ;
reg [2:0] dout ;

input [7:0] din ;
wire [7:0] din ;


always @ (din) begin
if (din[7])
dout = 0;
else if (din[6])
dout = 1;
else if (din[5])
dout = 2;
else if (din[4])
dout = 3;
else if (din[3])
dout = 4;
else if (din[2])
dout = 5;
else if (din[1])
dout = 6;
else if (din[0])
dout = 7;
else
dout = 3'bZZZ;
end

endmodule

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...