w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
rlink_cext_iface_vhpi.vhd
Go to the documentation of this file.
1-- $Id: rlink_cext_iface_vhpi.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: rlink_cext_iface - sim
7-- Description: Interface to external C code for tbcore_rlink - VHPI version
8--
9-- Dependencies: -
10--
11-- To test: -
12--
13-- Target Devices: generic
14-- Tool versions: ghdl 0.31
15-- Revision History:
16-- Date Rev Version Comment
17-- 2016-02-07 729 1.0 Initial version
18------------------------------------------------------------------------------
19
20library ieee;
21use ieee.std_logic_1164.all;
22use ieee.numeric_std.all;
23use ieee.std_logic_textio.all;
24use std.textio.all;
25
26use work.slvtypes.all;
27use work.rlink_cext_vhpi.all;
28
29entity rlink_cext_iface is -- interface to external C code - VHPI
30 port (
31 CLK : in slbit; -- clock
32 CLK_CYCLE : in slv32; -- clock cycle number
33 RX_DATA : out slv32; -- read data (data ext->tb)
34 RX_VAL : out slbit; -- read data valid (data ext->tb)
35 RX_HOLD : in slbit; -- read data hold (data ext->tb)
36 TX_DATA : in slv8; -- write data (data tb->ext)
37 TX_ENA : in slbit -- write data enable (data tb->ext)
38 );
40
41architecture sim of rlink_cext_iface is
42 signal R_RXDATA : slv32 := (others=>'1');
43 signal R_RXVAL : slbit := '0';
44begin
45
46 proc_put: process (CLK)
47 variable itxrc : integer := 0;
48 begin
49 if rising_edge(CLK) then
50 if TX_ENA = '1' then
51 itxrc := rlink_cext_putbyte(to_integer(unsigned(TX_DATA)));
52 assert itxrc=0
53 report "rlink_cext_putbyte error: " & integer'image(itxrc)
54 severity failure;
55 end if;
56
57 end if;
58
59 end process proc_put;
60
61 proc_get: process (CLK)
62 variable irxint : integer := 0;
63 begin
64 if rising_edge(CLK) then
65 if RX_HOLD = '0' or R_RXVAL = '0' then
66 irxint := rlink_cext_getbyte(to_integer(signed(CLK_CYCLE)));
67 R_RXDATA <= slv(to_signed(irxint, 32));
68 if irxint >= 0 then
69 R_RXVAL <= '1';
70 else
71 R_RXVAL <= '0';
72 end if;
73 end if;
74 end if;
75
76 end process proc_get;
77
79 RX_VAL <= R_RXVAL;
80
81end sim;
std_logic_vector( 31 downto 0) slv32
Definition: slvtypes.vhd:59
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector slv
Definition: slvtypes.vhd:31