Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <cstdint>
  6.  
  7. /*
  8.  * Aufgabe 1: Implementiere die Klasse Bitarray
  9.  * Aufgabe 2: Schreibe den Konstruktor der Abstract Class LogicGate
  10.  * Aufgabe 3a: Implementiere die Abstract Class LogicGate
  11.  * Aufgabe 3b: Implementiere AND, OR und NOT Gates (leite sie von LogicGate ab)
  12.  * Aufgabe 4a: Implementiere die Abstract Class Latch (wenn nötig füge weitere private member variables hinzu)
  13.  * Aufgabe 4b: Implementiere JK und D Latches (FlipFlop ohne Clock)
  14.  * Aufgabe 5: Implementiere die Klasse Schaltung, die eine Liste von Bauteilen beinhaltet und diese sinnvoll verbindet
  15.  *            Schaltzeit wird vernachlässigt (Keine Hasards)!
  16.  */
  17.  
  18. //Namespace sn (->Schaltnetz) erstellt einen besonderen Scope auf den man mit sn:: (bsw. sn::Bit oder sn::Bauteil) zugreifen kann
  19. namespace sn {
  20.  
  21.     typedef bool Bit;
  22.  
  23.     void flip(Bit& bit){
  24.         bit ^= 1;
  25.     }
  26.  
  27.     class Bitarray{
  28.         Bitarray(int n /*Größe des Bitarrays*/);
  29.  
  30.         Bitarray(const Bitarray& other);
  31.  
  32.         ~Bitarray();
  33.  
  34.         //Benutze bitwise operatoren um das Bitarray als Integer darzustellen
  35.         int toInt();
  36.  
  37.         Bit operator[] (int pos) const;
  38.  
  39.         Bit& operator[] (int pos);
  40.  
  41.     private:
  42.         Bit* data;
  43.     };
  44.  
  45.     class Bauteil {
  46.     public:
  47.         virtual Bitarray getOutput() const = 0;
  48.  
  49.         virtual Bitarray getInput() const = 0;
  50.  
  51.         virtual void setInput(const Bitarray& input) = 0;
  52.  
  53.     };
  54.  
  55.     class LogicGate: public Bauteil{
  56.     public:
  57.         LogicGate(int num_inputs, int num_outputs);
  58.         /* ... */
  59.  
  60.     private:
  61.         Bitarray input;
  62.         Bitarray output;
  63.     };
  64.  
  65.     class Latch: public Bauteil{
  66.     public:
  67.         /* ... */
  68.  
  69.     private:
  70.         /* ... */
  71.         Bitarray input;
  72.         Bitarray output;
  73.     };
  74.  
  75.     class NOTGate;
  76.  
  77.     class ANDGate;
  78.  
  79.     class ORGate;
  80.  
  81.     class DLatch;
  82.  
  83.     class JKLatch;
  84.  
  85.     class Schaltung: public Bauteil{};
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement