FPGA

I'm playing with Lattice MachXO2 FPGA. At this place I will add interesting stuff about learning FPGA.



VHDL type conversions - std_vector, signed, unsigned, integer
This page really explains what data types are available. There's also nice graph showing possible conversions and functions. Examples are also displayed

8x8 font ROM
https://github.com/dhepper/font8x8/blob/master/font8x8_basic.h

http://vhdlguru.blogspot.cz/2010/03/usage-of-packages-and-functions.html

void valToBin(int val, char *str)
{
    sprintf(str,"%d%d%d%d%d%d%d%d",
        (val & 1<<0) ? 1:0,
        (val & 1<<1) ? 1:0,
        (val & 1<<2) ? 1:0,
        (val & 1<<3) ? 1:0,
        (val & 1<<4) ? 1:0,
        (val & 1<<5) ? 1:0,
        (val & 1<<6) ? 1:0,
        (val & 1<<7) ? 1:0);
}

#define FONT_SIZE sizeof(font8x8_basic)
#define FONT_CHARS (FONT_SIZE/8)

int _tmain(int argc, _TCHAR* argv[])
{
    char str[256];

    printf("size %d\n", FONT_CHARS);

    for(int i = 0; i < FONT_CHARS; i++)
    {
         
        for(int j = 0; j < 8; j++)
        {
            char val = font8x8_basic[i][j];
            valToBin(val, str);
            printf("\"%s\",",  str);

        }
        printf("-- %c\n", i);
    }

    getchar();

    return 0;
}

Font ROM package

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- modulo
use IEEE.NUMERIC_STD.ALL;

package fontROM is
    subtype lutout is std_logic_vector (7 downto 0);
   type lut is array (natural range 0 to 39) of lutout;
   CONSTANT sendData:  lut;
end fontROM;
 
PACKAGE body fontROM is


CONSTANT sendData:  lut := (

-- A
"00000000",
"00111000",
"01000100",
"01000100",
"01111100",
"01000100",
"01000100",
"00000000",

-- B
"00000000",
"01111000",
"01000100",
"01111000",
"01000100",
"01000100",
"01111000",
"00000000",

-- C
"00000000",
"00111000",
"01000100",
"01000000",
"01000000",
"01000100",
"00111000",
"00000000",


-- D
"00000000",
"01111000",
"01000100",
"01000100",
"01000100",
"01000100",
"01111000",
"00000000",

"11111110","01100010","01101000","01111000","01101000","01100010","11111110","00000000" -- E

);


end fontROM;

And implementation then

use work.fontRom.all;



Variable outside process has to be SHARED

Subpages (1): LVDS LCD Hacking
Comments