blob: 8a609e9ccffe437be0ddf632c8e1841af1c26aeb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity repro2_1 is
port (
clk : std_logic;
rst : std_logic;
tx : out std_logic_vector(7 downto 0));
end repro2_1;
architecture behav of repro2_1 is
subtype byte_t is std_logic_vector(7 downto 0);
-- Define terminal newline characters (CR+LF)
constant NEWLINE_CR : byte_t := x"0d";
constant NEWLINE_LF : byte_t := x"0a";
-- Create ROM array with all concatenated messages.
type array_t is array(0 to 15) of byte_t;
impure function get_msg_array return array_t is
variable result : array_t := (others => (others => '0'));
variable ridx : integer := 0;
procedure append(constant msg : string) is
begin
-- Append the message to the output array.
for c in 0 to msg'length-1 loop
result(ridx) := x"00";
ridx := ridx + 1;
end loop;
-- Then append the CR+LF characters.
result(ridx+0) := NEWLINE_CR;
result(ridx+1) := NEWLINE_LF;
ridx := ridx + 2;
end procedure;
begin
-- For each fixed message...
append("xx");
return result;
end function;
constant MESSAGE_ROM : array_t := get_msg_array;
begin
process (clk)
variable p : natural;
begin
if rising_edge(clk) then
if rst = '1' then
p := 0;
else
tx <= message_rom (p);
if p = message_rom'right then
p := message_rom'left;
else
p := p + 1;
end if;
end if;
end if;
end process;
end behav;
|