Close

More microcode compiler capabilities!

zpekiczpekic wrote 09/15/2021 at 06:48 • 14 min read • Like

I have been fairly busy with the microcode compiler, mostly because the new HEX IO project has brought new ideas about useful features.

In addition to various bug fixes, the main one is addition of new .sym directive. Here is an example:

.symbol 7, 256, hex2mem_sym.mif, hex2mem_sym.cgf, hex2mem_sym.coe, h2m:hex2mem_sym.vhd, hex2mem_sym.hex, hex2mem_sym.bin, 32;

.symbol 7, 256, hex2mem_sym.mif, hex2mem_sym.cgf, hex2mem_sym.coe, h2m:hex2mem_sym.vhd, hex2mem_sym.hex, hex2mem_sym.bin, 32;

This will do the following:

  1. Create internally a memory block 7 address lines deep (128 locations) and 256-bits wide
  2. Initialize the block with source code of the microcode (8-bit ASCII, everything on the line beyond byte 32 will be truncated)
  3. Export the memory block into file names / formats specified (for example, hex2mem_sym.hex file) 
  4. Generate .vhdl template file that can be directly included into project if needed

The vhdl template file can be consumed by a component built into the project during debug and development phase to provide tracing of source code at each microinstruction being executed. Here is an example of such a tracer. For each microinstruction, it generates a 64 ASCII char record (close with CR+LF chars) suitable for UART transmit. This record typically contains:

Here is an example of all microinstructions executed by hex2mem component when a ':' (first char in hex file line) is received:

  .
: 3A 67 trace: if TRACE_CHAR then next e                     .
: 3A 1E emitChar: if TXDREADY then next                      I
: 3A 20 if TXDREADY then next else repea                     I
: 3A 69 if false then emitChar else emit                     I
: 3A 1F if TXDREADY then next else repea                     =
: 3A 21 if TXDSEND then return else retu                     =
: 3A 1E emitChar: if TXDREADY then next                      3
: 3A 20 if TXDREADY then next else repea                     3
: 3A 6B if false then emitChar else emit                     3
: 3A 1F if TXDREADY then next else repea                     A
: 3A 21 if TXDSEND then return else retu                     A
: 3A 1E emitChar: if TXDREADY then next
: 3A 20 if TXDREADY then next else repea
: 3A 6D if false then emitChar else emit
: 3A 1F if TXDREADY then next else repea                     A
: 3A 21 if TXDSEND then return else retu                     A
: 3A 1E emitChar: if TXDREADY then next                      =
: 3A 20 if TXDREADY then next else repea                     =
: 3A 6F if false then printaddr else pri                     =
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 2A if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea                     7
: 3A 21 if TXDSEND then return else retu                     7
: 3A 1E emitChar: if TXDREADY then next                      9
: 3A 20 if TXDREADY then next else repea                     9
: 3A 2C if false then emitChar else emit                     9
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 70 if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea
: 3A 21 if TXDSEND then return else retu
: 3A 1E emitChar: if TXDREADY then next                      C
: 3A 20 if TXDREADY then next else repea                     C
: 3A 72 if false then emitChar else emit                     C
: 3A 1F if TXDREADY then next else repea                     =
: 3A 21 if TXDSEND then return else retu                     =
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 74 if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 76 if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next
: 3A 20 if TXDREADY then next else repea
: 3A 78 if false then emitChar else emit
: 3A 1F if TXDREADY then next else repea                     B
: 3A 21 if TXDSEND then return else retu                     B
: 3A 1E emitChar: if TXDREADY then next                      =
: 3A 20 if TXDREADY then next else repea                     =
: 3A 7A if false then emitChar else emit                     =
: 3A 1F if TXDREADY then next else repea                     3
: 3A 21 if TXDSEND then return else retu                     3
: 3A 1E emitChar: if TXDREADY then next                      C
: 3A 20 if TXDREADY then next else repea                     C
: 3A 7C if false then emitChar else emit                     C
: 3A 1F if TXDREADY then next else repea
: 3A 21 if TXDSEND then return else retu
: 3A 22 printramR: if false then emitCha
: 3A 1F if TXDREADY then next else repea                     R
: 3A 21 if TXDSEND then return else retu                     R
: 3A 1E emitChar: if TXDREADY then next                      =
: 3A 20 if TXDREADY then next else repea                     =
: 3A 24 if false then emitChar else emit                     =
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 26 print_crlf: if false then emitCh                     0
: 3A 1F if TXDREADY then next else repea                     .
: 3A 21 if TXDSEND then return else retu                     .
: 3A 1E emitChar: if TXDREADY then next                      .
: 3A 20 if TXDREADY then next else repea                     .
: 3A 28 if true then return else return;                     .
: 3A 64 colon: checksum <= zero, if byte                     .
: 3A 0D printerror: if false then emitCh                     .
: 3A 1F if TXDREADY then next else repea                     E
: 3A 21 if TXDSEND then return else retu                     E
: 3A 1E emitChar: if TXDREADY then next                      R
: 3A 20 if TXDREADY then next else repea                     R
: 3A 0F if false then emitChar else emit                     R
: 3A 1F if TXDREADY then next else repea                     R
: 3A 21 if TXDSEND then return else retu                     R
: 3A 1E emitChar: if TXDREADY then next                      2
: 3A 20 if TXDREADY then next else repea                     2
: 3A 11 if false then emitChar else emit                     2
: 3A 1F if TXDREADY then next else repea
: 3A 21 if TXDSEND then return else retu
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 13 if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next                      0
: 3A 20 if TXDREADY then next else repea                     0
: 3A 15 if false then emitChar else emit                     0
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next
: 3A 20 if TXDREADY then next else repea
: 3A 17 if false then emitChar else emit
: 3A 1F if TXDREADY then next else repea                     0
: 3A 21 if TXDSEND then return else retu                     0
: 3A 1E emitChar: if TXDREADY then next                      2
: 3A 20 if TXDREADY then next else repea                     2
: 3A 19 if false then emitChar else emit                     2
: 3A 1F if TXDREADY then next else repea
: 3A 21 if TXDSEND then return else retu
: 3A 1E emitChar: if TXDREADY then next                      3
: 3A 20 if TXDREADY then next else repea                     3
: 3A 1B hexcnt <= ptr_colon, if false th                     3
: 3A 1F if TXDREADY then next else repea                     A
: 3A 21 if TXDSEND then return else retu                     A
: 3A 26 print_crlf: if false then emitCh                     A
: 3A 1F if TXDREADY then next else repea                     .
: 3A 21 if TXDSEND then return else retu                     .
: 3A 1E emitChar: if TXDREADY then next                      .
: 3A 20 if TXDREADY then next else repea                     .
: 3A 28 if true then return else return;                     .
. 00
Like

Discussions