| 1 | /* |
| 2 | Copyright (c) 2005-2019 Intel Corporation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __TBBexample_graph_logicsim_dlatch_H |
| 18 | #define __TBBexample_graph_logicsim_dlatch_H 1 |
| 19 | |
| 20 | #include "basics.h" |
| 21 | |
| 22 | class D_latch : public composite_node< tuple< signal_t, signal_t >, tuple< signal_t, signal_t > > { |
| 23 | broadcast_node<signal_t> D_port; |
| 24 | broadcast_node<signal_t> E_port; |
| 25 | not_gate a_not; |
| 26 | and_gate<2> first_and; |
| 27 | and_gate<2> second_and; |
| 28 | nor_gate<2> first_nor; |
| 29 | nor_gate<2> second_nor; |
| 30 | graph& my_graph; |
| 31 | typedef composite_node< tuple< signal_t, signal_t >, tuple< signal_t, signal_t > > base_type; |
| 32 | |
| 33 | public: |
| 34 | D_latch(graph& g) : base_type(g), my_graph(g), D_port(g), E_port(g), a_not(g), first_and(g), second_and(g), |
| 35 | first_nor(g), second_nor(g) |
| 36 | { |
| 37 | make_edge(D_port, input_port<0>(a_not)); |
| 38 | make_edge(D_port, input_port<1>(second_and)); |
| 39 | make_edge(E_port, input_port<1>(first_and)); |
| 40 | make_edge(E_port, input_port<0>(second_and)); |
| 41 | make_edge(a_not, input_port<0>(first_and)); |
| 42 | make_edge(first_and, input_port<0>(first_nor)); |
| 43 | make_edge(second_and, input_port<1>(second_nor)); |
| 44 | make_edge(first_nor, input_port<0>(second_nor)); |
| 45 | make_edge(second_nor, input_port<1>(first_nor)); |
| 46 | |
| 47 | base_type::input_ports_type input_tuple(D_port, E_port); |
| 48 | base_type::output_ports_type output_tuple(output_port<0>(first_nor), output_port<0>(second_nor)); |
| 49 | |
| 50 | base_type::set_external_ports(input_tuple, output_tuple); |
| 51 | base_type::add_visible_nodes(D_port, E_port, a_not, first_and, second_and, first_nor, second_nor); |
| 52 | } |
| 53 | ~D_latch() {} |
| 54 | }; |
| 55 | |
| 56 | #endif /* __TBBexample_graph_logicsim_dlatch_H */ |
| 57 | |