-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinverter_test.py
38 lines (31 loc) · 995 Bytes
/
inverter_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pywire import *
class Inverter(Component):
count = 0
@staticmethod
def identity(x):
return x
def __init__(self, size, signal_in, signal_out):
Component.__init__(self)
Inverter.count += 1
self.id = Inverter.count
self.size = size
self.signal_in = signal_in
self.signal_out = signal_out
def header(self):
return """
component inverter is
generic (N: positive);
port(
clock : in std_logic_vector(0 to 0);
a, b : in_std_logic_vector(0 to N-1));
end component;
"""
def body(self):
return "INVERTER_" + str(self.id) + " : inverter \n" +\
"generic map (N => " + str(self.size) + ")\n port map (" +\
self.signal_in.name + ", " + self.signal_out.name + ")\n"
width = 4
a = Signal(width, io="in")
b = Signal(width, io="out")
Inverter(width, a, b)
print(generate())