Search code examples
excelexcel-formulahdl

Formatting Excel Cells for Binary


I'm currently trying to use a table in excel to automatically generate some code in a Hardware Description Language for me.

I've formatted the cells O5:O20 to a custom format so that when it pulls the value from my table for the '0' charecter it will display all the 0's in front as well. However I'm trying to have my HDL code automatically generate based off of the table so in cells R5:R19 I have the following code running:

=("assign wire_"&N5&" = 4'b"&TEXT(O5, 0000000)&";")

This defaults to:

 =("assign wire_"&N5&" = 4'b"&TEXT(O5, 0)&";")

Ideally the first code should work to create the output

=assign wire_0=4'b0000001;

But because the Excel code forces the text formatting of O5 to be '0' instead of what I type in as '0000000', any bit bus with zeros in front will be lost.

My question is if there is a way to force the 'TEXT(cell, format)' command to accept the 7 0 format in the formula, as it was accepted when I placed it on cells O5:O20.

enter image description here


Solution

  • put the seven 0 in quotes:

    =("assign wire_"&N5&" = 4'b"&TEXT(O5, "0000000")&";")