1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from stratus import * |
---|
4 | |
---|
5 | # definition du bloc mux |
---|
6 | class mux ( Model ) : |
---|
7 | |
---|
8 | # declaration des connecteurs |
---|
9 | def Interface ( self ) : |
---|
10 | # recuperation du parametre |
---|
11 | self.n = self._param['nbit'] |
---|
12 | |
---|
13 | # connecteurs |
---|
14 | self.i0 = SignalIn ( "i0", self.n ) |
---|
15 | self.i1 = SignalIn ( "i1", self.n ) |
---|
16 | self.cmd = SignalIn ( "cmd", 1 ) |
---|
17 | self.s = SignalOut ( "s", self.n ) |
---|
18 | self.vdd = VddIn ( "vdd" ) |
---|
19 | self.vss = VssIn ( "vss" ) |
---|
20 | |
---|
21 | # instanciation des cellules |
---|
22 | def Netlist ( self ) : |
---|
23 | for i in range ( self.n ) : |
---|
24 | Inst ( "mx2_x2" |
---|
25 | , map = { 'i0' : self.i0[i] |
---|
26 | , 'i1' : self.i1[i] |
---|
27 | , 'cmd' : self.cmd |
---|
28 | , 'q' : self.s[i] |
---|
29 | , 'vdd' : self.vdd |
---|
30 | , 'vss' : self.vss |
---|
31 | } |
---|
32 | ) |
---|
33 | |
---|
34 | def Pattern ( self ) : |
---|
35 | pat = PatWrite(self._name+'.pat',self) |
---|
36 | |
---|
37 | # declaration de l interface |
---|
38 | pat.declar(self.i0,'X') |
---|
39 | pat.declar(self.i1,'X') |
---|
40 | pat.declar(self.cmd,'B') |
---|
41 | pat.declar(self.s,'X') |
---|
42 | |
---|
43 | pat.declar(self.vdd, 'B') |
---|
44 | pat.declar(self.vss, 'B') |
---|
45 | |
---|
46 | pat.pattern_begin() |
---|
47 | |
---|
48 | # affectation des valeurs |
---|
49 | pat.affect_int(self.vdd,1) |
---|
50 | pat.affect_int(self.vss,0) |
---|
51 | |
---|
52 | for i0 in range ( self.n ) : |
---|
53 | for i1 in range ( self.n ) : |
---|
54 | for c in range ( 2 ) : |
---|
55 | pat.affect_int ( self.i0, i0 ) |
---|
56 | pat.affect_int ( self.i1, i1 ) |
---|
57 | pat.affect_int ( self.cmd, c ) |
---|
58 | if c == 1 : pat.affect_int ( self.s, i1 ) |
---|
59 | else : pat.affect_int ( self.s, i0 ) |
---|
60 | # ajout du pattern |
---|
61 | pat.addpat() |
---|
62 | |
---|
63 | del pat |
---|