-1

I have a memory array which consists of series of valid values, starting from location 0. Rest of the values are 'XX'.

I want to count the number of valid values in the memory. One way I can think of is by looking out for 'XX' for the first time using '==='. But it can't be synthesized.

Please suggest some other way to do the same.

  • use valid bits? – wilcroft Sep 16 '16 at 18:05
  • XX is not synthesizable. What is your definition of a valid value? – dave_59 Sep 16 '16 at 20:10
  • 1
    Your bits will not be X in real hardware. X is a placeholder for unknown. It will be a value, you just won't know which value it will be in hardware. It could come up 1 or 0. You need to get rid of X's with a proper reset sequence. – Ross Rogers Sep 16 '16 at 20:12
  • By valid bits, I meant valid data. The data which I have stored in the memory. – Anurag Goyal Sep 16 '16 at 20:14
  • Thanks @RossRogers This would have surely solve the problem. – Anurag Goyal Sep 16 '16 at 20:16
  • Yeah, it is your job to bring the entire machine into a known state with the pertinent bits in a known state. Anything that isn't set by you is being set by chaos. This may not mean that you need to de-X the entire machine, but anytime you see x's infecting your simulation, you likely need to trace the upstream invalid x value propagation. – Ross Rogers Sep 16 '16 at 20:21

1 Answers1

1

Based on what you have described, I would suggest that you design in a register that indicated the address of the last valid value in your memory, that you can set when the memory is loaded with the values.

As mentioned in the comments, once synthesized, you have no way of knowing the values passed those you have set explicitly (1'bx is simply a simulation placeholder for "dont care", meaning the value could be 1'b1 or 1'b0 during the actual run). Thus, you can either have a special value for uninitialized memory addresses that the entire memory is filled with at boot and DOESNT appear in your valid data, or, better, use the register concept suggested above to keep track of the size/address of your last valid entry.

Unn
  • 4,775
  • 18
  • 30