Question

I am quite new to VHDL and as my first project I created a 20x7 LED display with rotating text. Right now all the STD_LOGIC_VECTORs which printed on the display are set manually.

I was wondering if there is a possibility to get STD_LOGIC_VECTOR representation of rows from a string (or char?). I found usable font, but I don't know where to start...

Was it helpful?

Solution

to implement something like what you asked for in the later comments, you first need a translation function char2int for the addressing of your array. example:

    function char2int (chr: character) return integer is
        variable i: integer;
    begin
        case chr is
        when 'H' => i:=0;
        when 'A' => i:=1;
        when 'L' => i:=2;
        when 'O' => i:=3;
        when others => i:=4;
        end case;

        return i;
    end char2int;

then the main function is as you suggested in your C-example:

    function string_to_bitfile(constant txt_str: string) return text_type is
        variable txt: text_type;
    begin
        for i in 0 to (txt_str'length-1) loop
            for j in 0 to 5 loop
                txt(6*i+j):=font(char2int(txt_str(i)),j);
            end loop;
        end loop;

        return txt;
    end string_to_bitfile;

OTHER TIPS

to represent your font table you can use arrays and constants. see example below:

    type font_array is array(0 to 127, 0 to 5) of std_logic_vector(7 downto 0);
    constant font: font_array :=(
       (X"01",X"02",X"03",X"04",X"05",X"06"), -- row 0
       (X"11",X"12",X"13",X"14",X"15",X"16"), -- row 1
       ...
       (X"11",X"12",X"13",X"14",X"15",X"16") -- last row 
    );

to get a row of your character, you can use a function. see example:

    function get_font_row(char_pos, row: integer) return std_logic_vector is
        variable result: std_logic_vector(5 downto 0);
    begin
        for i in 0 to 5 loop
            result(i):=font(char_pos, i)(row);
        end loop;

        return result;
    end get_font_row;

this character rows can be combined to a LED-row:

    led_row<=get_font_row(ch_h,n) & get_font_row(ch_a,n) & get_font_row(ch_l,n) & ...;

where "n" is your LED-row-number and "ch_h", "ch_a" and "ch_l" are positions of your character font within the font_array.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top