URL
https://opencores.org/ocsvn/uart2bus/uart2bus/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
11 |
smuller |
library ieee;
|
2 |
|
|
use ieee.std_logic_1164.all;
|
3 |
13 |
smuller |
use ieee.numeric_std.all;
|
4 |
11 |
smuller |
|
5 |
|
|
package helpers_pkg is
|
6 |
|
|
|
7 |
13 |
smuller |
procedure sendSerial(data : integer; baud : in real; parity : in integer; stopbit : in real; bitnumber : in integer; baudError : in real; signal txd : inout std_logic);
|
8 |
|
|
procedure recvSerial( signal rxd : in std_logic; baud : in real; parity : in integer; stopbit : in real; bitnumber : in integer; baudError : in real; signal data : inout std_logic_vector(7 downto 0));
|
9 |
|
|
|
10 |
11 |
smuller |
component regFileModel
|
11 |
|
|
port
|
12 |
|
|
(
|
13 |
|
|
clr : in std_logic;
|
14 |
|
|
clk : in std_logic;
|
15 |
|
|
intAddress : in std_logic_vector(7 downto 0);
|
16 |
|
|
intWrData : in std_logic_vector(7 downto 0);
|
17 |
|
|
intWrite : in std_logic;
|
18 |
|
|
intRead : in std_logic;
|
19 |
|
|
intRdData : out std_logic_vector(7 downto 0));
|
20 |
|
|
end component;
|
21 |
|
|
|
22 |
|
|
end helpers_pkg;
|
23 |
13 |
smuller |
|
24 |
|
|
package body helpers_pkg is
|
25 |
|
|
|
26 |
|
|
procedure sendSerial(data : integer; baud : in real; parity : in integer; stopbit : in real; bitnumber : in integer; baudError : in real; signal txd : inout std_logic) is
|
27 |
|
|
|
28 |
|
|
variable shiftreg : std_logic_vector(7 downto 0);
|
29 |
|
|
variable bitTime : time;
|
30 |
|
|
|
31 |
|
|
begin
|
32 |
|
|
bitTime := 1000 ms / (baud + baud * baudError / 100.0);
|
33 |
|
|
shiftreg := std_logic_vector(to_unsigned(data, shiftreg'length));
|
34 |
|
|
txd <= '0';
|
35 |
|
|
wait for bitTime;
|
36 |
|
|
for index in 0 to bitnumber loop
|
37 |
|
|
txd <= shiftreg(index);
|
38 |
|
|
wait for bitTime;
|
39 |
|
|
end loop;
|
40 |
|
|
txd <= '1';
|
41 |
|
|
wait for stopbit * bitTime;
|
42 |
|
|
end procedure;
|
43 |
|
|
|
44 |
|
|
procedure recvSerial( signal rxd : in std_logic; baud : in real; parity : in integer; stopbit : in real; bitnumber : in integer; baudError : in real; signal data : inout std_logic_vector(7 downto 0)) is
|
45 |
|
|
|
46 |
|
|
variable bitTime : time;
|
47 |
|
|
|
48 |
|
|
begin
|
49 |
|
|
bitTime := 1000 ms / (baud + baud * baudError / 100.0);
|
50 |
|
|
wait until (rxd = '0');
|
51 |
|
|
wait for bitTime / 2;
|
52 |
|
|
wait for bitTime;
|
53 |
|
|
for index in 0 to bitnumber loop
|
54 |
|
|
data <= rxd & data(7 downto 1);
|
55 |
|
|
wait for bitTime;
|
56 |
|
|
end loop;
|
57 |
|
|
wait for stopbit * bitTime;
|
58 |
|
|
end procedure;
|
59 |
|
|
|
60 |
|
|
end;
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.