1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | ############################################################### |
---|
4 | ### ### |
---|
5 | ### File : mux2.py ### |
---|
6 | ### Date : December 10 2009 ### |
---|
7 | ### Version : 1.02 ### |
---|
8 | ### Author : Belloeil Sophie ### |
---|
9 | ### ### |
---|
10 | ### Origin : This description has been developed at LIP6 ### |
---|
11 | ### University Paris 6 - Pierre et Marie Curie ### |
---|
12 | ### 4 Place Jussieu 75252 Paris Cedex 05 - France ### |
---|
13 | ### ### |
---|
14 | ############################################################### |
---|
15 | |
---|
16 | from stratus import * |
---|
17 | |
---|
18 | class mux ( Model ) : |
---|
19 | |
---|
20 | def Interface ( self ) : |
---|
21 | self.n = self._param['nbit'] |
---|
22 | |
---|
23 | self.i0 = SignalIn ( "i0", self.n ) |
---|
24 | self.i1 = SignalIn ( "i1", self.n ) |
---|
25 | self.cmd = SignalIn ( "cmd", 1 ) |
---|
26 | self.s = SignalOut ( "s", self.n ) |
---|
27 | self.vdd = VddIn ( "vdd" ) |
---|
28 | self.vss = VssIn ( "vss" ) |
---|
29 | |
---|
30 | def Netlist ( self ) : |
---|
31 | for i in range ( self.n ) : |
---|
32 | Inst ( "mx2_x2" |
---|
33 | , map = { 'i0' : self.i0[i] |
---|
34 | , 'i1' : self.i1[i] |
---|
35 | , 'cmd' : self.cmd |
---|
36 | , 'q' : self.s[i] |
---|
37 | , 'vdd' : self.vdd |
---|
38 | , 'vss' : self.vss |
---|
39 | } |
---|
40 | ) |
---|
41 | |
---|
42 | # Description des patterns |
---|
43 | def Pattern ( self ) : |
---|
44 | pat = PatWrite ( self._name + '.pat', self ) |
---|
45 | |
---|
46 | # Declaration de l interface |
---|
47 | pat.declar (self.i0, 'X' ) |
---|
48 | pat.declar (self.i1, 'X' ) |
---|
49 | pat.declar (self.cmd, 'B' ) |
---|
50 | pat.declar (self.s, 'X' ) |
---|
51 | |
---|
52 | pat.declar (self.vdd, 'B' ) |
---|
53 | pat.declar (self.vss, 'B' ) |
---|
54 | |
---|
55 | pat.pattern_begin () |
---|
56 | |
---|
57 | # Affectation des valeurs |
---|
58 | pat.affect_int ( self.vdd, 1 ) |
---|
59 | pat.affect_int ( self.vss, 0 ) |
---|
60 | |
---|
61 | for i0 in range ( self.n ) : |
---|
62 | for i1 in range ( self.n ) : |
---|
63 | for c in range ( 2 ) : |
---|
64 | pat.affect_int ( self.i0, i0 ) |
---|
65 | pat.affect_int ( self.i1, i1 ) |
---|
66 | pat.affect_int ( self.cmd, c ) |
---|
67 | |
---|
68 | if c == 1 : pat.affect_int ( self.s, i1 ) |
---|
69 | else : pat.affect_int ( self.s, i0 ) |
---|
70 | |
---|
71 | # Ajout du pattern |
---|
72 | pat.addpat () |
---|
73 | |
---|
74 | del pat |
---|