OpenCores
URL https://opencores.org/ocsvn/uart2bus/uart2bus/trunk

Subversion Repositories uart2bus

[/] [uart2bus/] [trunk/] [vhdl/] [bench/] [helpers/] [helpers_pkg.vhd] - Diff between revs 11 and 13

Show entire file | Details | Blame | View Log

Rev 11 Rev 13
Line 1... Line 1...
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
 
use ieee.numeric_std.all;
 
 
package helpers_pkg is
package helpers_pkg is
 
 
 
  procedure sendSerial(data : integer; baud : in real; parity : in integer; stopbit : in real; bitnumber : in integer; baudError : in real; signal txd : inout std_logic);
 
  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));
 
 
  component regFileModel
  component regFileModel
    port
    port
    (
    (
      clr        : in  std_logic;
      clr        : in  std_logic;
      clk        : in  std_logic;
      clk        : in  std_logic;
Line 15... Line 19...
      intRdData  : out std_logic_vector(7 downto 0));
      intRdData  : out std_logic_vector(7 downto 0));
  end component;
  end component;
 
 
end helpers_pkg;
end helpers_pkg;
 
 
 No newline at end of file
 No newline at end of file
 
package body helpers_pkg is
 
 
 
  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
 
 
 
    variable shiftreg : std_logic_vector(7 downto 0);
 
    variable bitTime  : time;
 
 
 
    begin
 
      bitTime := 1000 ms / (baud + baud * baudError / 100.0);
 
      shiftreg := std_logic_vector(to_unsigned(data, shiftreg'length));
 
      txd <= '0';
 
      wait for bitTime;
 
      for index in 0 to bitnumber loop
 
        txd <= shiftreg(index);
 
        wait for bitTime;
 
      end loop;
 
      txd <= '1';
 
      wait for stopbit * bitTime;
 
    end procedure;
 
 
 
  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
 
 
 
    variable bitTime  : time;
 
 
 
    begin
 
      bitTime := 1000 ms / (baud + baud * baudError / 100.0);
 
      wait until (rxd = '0');
 
      wait for bitTime / 2;
 
      wait for bitTime;
 
      for index in 0 to bitnumber loop
 
        data <= rxd & data(7 downto 1);
 
        wait for bitTime;
 
      end loop;
 
      wait for stopbit * bitTime;
 
    end procedure;
 
 
 
end;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.