File: /__w/ctu-can-regression/ctu-can-regression/test/main_tb/agents/reset_agent/reset_agent.vhd
0: --------------------------------------------------------------------------------
1: --
2: -- CTU CAN FD IP Core
3: -- Copyright (C) 2021-2023 Ondrej Ille
4: -- Copyright (C) 2023- Logic Design Services Ltd.s
5: --
6: -- Permission is hereby granted, free of charge, to any person obtaining a copy
7: -- of this VHDL component and associated documentation files (the "Component"),
8: -- to use, copy, modify, merge, publish, distribute the Component for
9: -- non-commercial purposes. Using the Component for commercial purposes is
10: -- forbidden unless previously agreed with Copyright holder.
11: --
12: -- The above copyright notice and this permission notice shall be included in
13: -- all copies or substantial portions of the Component.
14: --
15: -- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16: -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17: -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18: -- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19: -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20: -- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS
21: -- IN THE COMPONENT.
22: --
23: -- The CAN protocol is developed by Robert Bosch GmbH and protected by patents.
24: -- Anybody who wants to implement this IP core on silicon has to obtain a CAN
25: -- protocol license from Bosch.
26: --
27: -- -------------------------------------------------------------------------------
28: --
29: -- CTU CAN FD IP Core
30: -- Copyright (C) 2015-2020 MIT License
31: --
32: -- Authors:
33: -- Ondrej Ille <ondrej.ille@gmail.com>
34: -- Martin Jerabek <martin.jerabek01@gmail.com>
35: --
36: -- Project advisors:
37: -- Jiri Novak <jnovak@fel.cvut.cz>
38: -- Pavel Pisa <pisa@cmp.felk.cvut.cz>
39: --
40: -- Department of Measurement (http://meas.fel.cvut.cz/)
41: -- Faculty of Electrical Engineering (http://www.fel.cvut.cz)
42: -- Czech Technical University (http://www.cvut.cz/)
43: --
44: -- Permission is hereby granted, free of charge, to any person obtaining a copy
45: -- of this VHDL component and associated documentation files (the "Component"),
46: -- to deal in the Component without restriction, including without limitation
47: -- the rights to use, copy, modify, merge, publish, distribute, sublicense,
48: -- and/or sell copies of the Component, and to permit persons to whom the
49: -- Component is furnished to do so, subject to the following conditions:
50: --
51: -- The above copyright notice and this permission notice shall be included in
52: -- all copies or substantial portions of the Component.
53: --
54: -- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55: -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56: -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57: -- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58: -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
59: -- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS
60: -- IN THE COMPONENT.
61: --
62: -- The CAN protocol is developed by Robert Bosch GmbH and protected by patents.
63: -- Anybody who wants to implement this IP core on silicon has to obtain a CAN
64: -- protocol license from Bosch.
65: --
66: --------------------------------------------------------------------------------
67:
68: --------------------------------------------------------------------------------
69: -- @Purpose:
70: -- Reset generator agent with configurable polarity.
71: --
72: --------------------------------------------------------------------------------
73: -- Revision History:
74: -- 19.1.2020 Created file
75: -- 04.2.2021 Adjusted to work without Vunits COM library.
76: --------------------------------------------------------------------------------
77:
78: Library ctu_can_fd_tb;
79: context ctu_can_fd_tb.ieee_context;
80: context ctu_can_fd_tb.tb_common_context;
81:
82: use ctu_can_fd_tb.reset_agent_pkg.all;
83: use ctu_can_fd_tb.tb_shared_vars_pkg.all;
84:
85:
86: entity reset_agent is
87: port (
88: -- Generated reset output
89: reset : out std_logic
90: );
91: end entity;
92:
93: architecture tb of reset_agent is
94:
95: ---------------------------------------------------------------------------
96: -- Parameters configured over communication library
97: ---------------------------------------------------------------------------
98: signal reset_polarity : std_logic := '1';
99: signal reset_active : boolean := false;
100:
101: begin
102:
103: ---------------------------------------------------------------------------
104: -- Comunication receiver process
105: ---------------------------------------------------------------------------
106: receiver_proc : process
107: variable cmd : integer;
108: variable reply_code : integer;
109: begin
110: receive_start(default_channel, C_RESET_AGENT_ID);
111:
112: -- Command is sent as message type
113: cmd := com_channel_data.get_msg_code;
114: reply_code := C_REPLY_CODE_OK;
115:
116: case cmd is
117: when RST_AGNT_CMD_ASSERT =>
118: reset <= reset_polarity;
119: reset_active <= true;
120:
121: when RST_AGNT_CMD_DEASSERT =>
122: reset <= not reset_polarity;
123: reset_active <= false;
124:
125: when RST_AGNT_CMD_POLARITY_SET =>
126: reset_polarity <= com_channel_data.get_param;
127: wait for 0 ns;
128: if (reset_active) then
129: reset <= reset_polarity;
130: else
131: reset <= not reset_polarity;
132: end if;
133:
134: when RST_AGNT_CMD_POLARITY_GET =>
135: com_channel_data.set_param(reset_polarity);
136:
137: when others =>
138: info_m("Invalid message type: " & integer'image(cmd));
139: reply_code := C_REPLY_CODE_ERR;
140:
141: end case;
142: receive_finish(default_channel, reply_code);
143: end process;
144:
145: end architecture;