Advertisement
Guest User

Verilog Array init

a guest
Mar 22nd, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. reg [6:0] expected[0:15];
  2.  
  3. // This throw an error:
  4. // error: syntax error in reg variable list.
  5. // reg [6:0] expected[0:15] = {
  6. //         7'h3F, 7'h06, 7'h5B, 7'h4F,
  7. //         7'h66, 7'h6D, 7'h7D, 7'h07,
  8. //         7'h7F, 7'h67, 7'h7A, 7'h7C,
  9. //         7'h39, 7'h5E, 7'h79, 7'h71
  10. // };
  11.  
  12. initial begin
  13.  
  14.     // Verilog system tasks
  15.  
  16.     // $dumpfile genera un archivo
  17.     // donde se almacenan todas las
  18.     // variables del diseño
  19.     $dumpfile("bcd2segments.vcd");
  20.     $dumpvars(0, bcd2segments_tb);
  21.  
  22.     // This throw an error:
  23.     // Cannot assign to array expected. Did you forget a word index?
  24.     // expected = {
  25.     //     7'h3F, 7'h06, 7'h5B, 7'h4F,
  26.     //     7'h66, 7'h6D, 7'h7D, 7'h07,
  27.     //     7'h7F, 7'h67, 7'h7A, 7'h7C,
  28.     //     7'h39, 7'h5E, 7'h79, 7'h71
  29.     // };
  30.  
  31.     // This is fine
  32.     expected[4'd0] = 7'h3F;
  33.     expected[4'd1] = 7'h06;
  34.     expected[4'd2] = 7'h5B;
  35.     expected[4'd3] = 7'h4F;
  36.     expected[4'd4] = 7'h66;
  37.     expected[4'd5] = 7'h6D;
  38.     expected[4'd6] = 7'h7D;
  39.     expected[4'd7] = 7'h07;
  40.     expected[4'd8] = 7'h7F;
  41.     expected[4'd9] = 7'h67;
  42.     expected[4'd10] = 7'h7A;
  43.     expected[4'd11] = 7'h7C;
  44.     expected[4'd12] = 7'h39;
  45.     expected[4'd13] = 7'h5E;
  46.     expected[4'd14] = 7'h79;
  47.     expected[4'd15] = 7'h71;
  48.  
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement