Ejemplo n.º 1
0
 def build(self):
     self.clock = Transmitter(self, 'CLOCK')
     self.data = Transmitter(self, 'DATA')
     self.not_ = NOT(self, '!')
     self.latch1 = Latch(self, '1')
     self.latch2 = Latch(self, 'OUTPUT')
     self.outputs.append(self.latch2)
     self.clock >> self.not_
     self.clock >> self.latch1.enable
     self.data >> self.latch1.data
     self.not_ >> self.latch2.enable
     self.latch1 >> self.latch2.data
Ejemplo n.º 2
0
 def build(self):
     not_ = NOT(self, '!')
     latch1 = Latch(self, 'L1')
     latch2 = Latch(self, 'L2')
     clock = Transmitter(self, 'CLK')
     data = Transmitter(self, 'DTA')
     clock >> not_
     clock >> latch1.enable
     data >> latch1.data
     not_ >> latch2.enable
     latch1 >> latch2.data
     self.output = latch2.default_output
     self.clock = clock.default_input
     self.data = data.default_input
     self.inputs.extend([self.clock, self.data])
     self.outputs.append(self.output)
def test_Transmitter():
    transmitter = Transmitter(root)
    transmitter.default_input.force(1)
    work(transmitter)
    assert value(transmitter) == 1
    transmitter.default_input.force(0)
    work(transmitter)
    assert value(transmitter) == 0
Ejemplo n.º 4
0
 def build(self):
     self.enable = Transmitter(self, 'enable')
     self.data = Transmitter(self, 'data')
     self.initializer = self.enable & self.data
     self.not_data = -self.data
     self.face = []
     prev = self.initializer
     ticker = [self.data, self.not_data]
     ticker_i = 0
     for i in range(self.length * 2):
         switch = prev >> PersistentSwitch(self, 'switch_%i' % i).on
         self.face.append(switch)
         prev = switch & ticker[ticker_i]
         prev._name = 'and_%i' % i
         ticker_i = int(not (ticker_i))
     for node in self.face:
         self.face[-1] >> node.off
     self._inputs = [self.enable, self.data]
Ejemplo n.º 5
0
 def build(self):
     super(RecetablePersistentCell, self).build()
     self.reset = Transmitter(self, 'RESET')
     self.inputs.append(self.reset)
     self.reset_switch = PersistentSwitch(self, 'RESETSWITCH')
     self.reset >> self.reset_switch.on
     self.complete_indicator = NOT(self, 'COMPLETE')
     for bit in self.bits:
         self.reset_switch >> bit.off
         bit >> self.complete_indicator
     self.complete_indicator >> self.reset_switch.off
Ejemplo n.º 6
0
 def build(self):
     inp = Transmitter(self, 'SNL')
     not_ = NOT(self, '!')
     inp >> not_
     prev = not_
     for i in range(self.ticks - 1):
         repeater = XOR(self, 'R%i' % i)
         prev >> repeater.first
         prev = repeater
     and_ = AND(self, 'PLS')
     prev >> and_.first
     inp >> and_.second
     self.inputs.append(inp.default_input)
     self.outputs.append(and_.default_output)
Ejemplo n.º 7
0
 def build(self):
     switches = Compound(self, 'SWITCHES')
     self.logic = Compound(self, 'LOGIC')
     self.input = Transmitter(self, 'INPUT')
     self.inputs.append(input)
     prev_switch = None
     self.switches = []
     for i, bit in enumerate(self.cell.bits):
         switch = Switch(switches, 'S%i' % i)
         self.switches.append(switch)
         switch >> bit.on
         (-switch) >> bit.off
         if prev_switch:
             not_ = NOT(self.logic, 'L%i' % i)
             prev_switch >> not_
             not_ >> switch
         else:
             self.input >> switch
         prev_switch = switch
Ejemplo n.º 8
0
 def build(self):
     logic_compound = Compound(self, 'LOGIC')
     enable = Transmitter(self, 'ENABLE')
     clk = PulseShortener(1, self, 'CLK')
     self.bits = []
     bit = FlipFlop(self, 'B0')
     enable >> bit.enable
     self.bits.append(bit)
     prev = bit
     for i in range(1, self.bits_n):
         bit = FlipFlop(self, 'B%i' % i)
         self.bits.append(bit)
         prev >> bit.enable
         if i != self.bits_n - 1:
             and_ = AND(logic_compound, 'L%i' % i)
             prev >> and_.first
             bit >> and_.second
             prev = and_
     for bit in self.bits:
         clk >> bit.data
     self.enable = enable.default_input
     self.data = clk.default_input