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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [verify/] [lxp32/] [src/] [platform/] [coprocessor.vhd] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 ring0_mipt
---------------------------------------------------------------------
2
-- Coprocessor
3
--
4
-- Part of the LXP32 test platform
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- Performs a simple arithmetic operation, uses interrupt to wake
9
-- up the CPU.
10
--
11
-- Note: regardless of whether this description is synthesizable,
12
-- it was designed exclusively for simulation purposes.
13
---------------------------------------------------------------------
14
 
15
library ieee;
16
use ieee.std_logic_1164.all;
17
use ieee.numeric_std.all;
18
 
19
entity coprocessor is
20
        port(
21
                clk_i: in std_logic;
22
                rst_i: in std_logic;
23
 
24
                wbs_cyc_i: in std_logic;
25
                wbs_stb_i: in std_logic;
26
                wbs_we_i: in std_logic;
27
                wbs_sel_i: in std_logic_vector(3 downto 0);
28
                wbs_ack_o: out std_logic;
29
                wbs_adr_i: in std_logic_vector(27 downto 2);
30
                wbs_dat_i: in std_logic_vector(31 downto 0);
31
                wbs_dat_o: out std_logic_vector(31 downto 0);
32
 
33
                irq_o: out std_logic
34
        );
35
end entity;
36
 
37
architecture rtl of coprocessor is
38
 
39
signal value: unsigned(31 downto 0):=(others=>'0');
40
signal result: unsigned(31 downto 0):=(others=>'0');
41
signal cnt: integer range 0 to 5:=0;
42
signal irq: std_logic:='0';
43
 
44
begin
45
 
46
process (clk_i) is
47
begin
48
        if rising_edge(clk_i) then
49
                if rst_i='1' then
50
                        value<=(others=>'0');
51
                        cnt<=0;
52
                        irq<='0';
53
                else
54
                        if cnt>0 then
55
                                cnt<=cnt-1;
56
                        end if;
57
 
58
                        if cnt=1 then
59
                                irq<='1';
60
                        else
61
                                irq<='0';
62
                        end if;
63
 
64
                        if wbs_cyc_i='1' and wbs_stb_i='1' and wbs_we_i='1' then
65
                                for i in wbs_sel_i'range loop
66
                                        if wbs_sel_i(i)='1' then
67
                                                if wbs_adr_i="00"&X"000000" then
68
                                                        value(i*8+7 downto i*8)<=
69
                                                                unsigned(wbs_dat_i(i*8+7 downto i*8));
70
                                                        cnt<=5;
71
                                                end if;
72
                                        end if;
73
                                end loop;
74
                        end if;
75
                end if;
76
        end if;
77
end process;
78
 
79
process (clk_i) is
80
begin
81
        if rising_edge(clk_i) then
82
                if rst_i='1' then
83
                        result<=(others=>'0');
84
                else
85
                        result<=shift_left(value,1)+value;
86
                end if;
87
        end if;
88
end process;
89
 
90
wbs_ack_o<=wbs_cyc_i and wbs_stb_i;
91
wbs_dat_o<=std_logic_vector(value) when wbs_adr_i="00"&X"000000" else
92
        std_logic_vector(result) when wbs_adr_i="00"&X"000001" else
93
        (others=>'-');
94
 
95
irq_o<=irq;
96
 
97
end architecture;

powered by: WebSVN 2.1.0

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