From: Sebastien Bourdeauducq Date: Fri, 6 Jan 2012 13:32:00 +0000 (+0100) Subject: ALA: use records for tokens X-Git-Tag: 24jan2021_ls180~2099^2~1102 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3bf87780271d5ad9b7b0410dbddd5f321ffd59c;p=litex.git ALA: use records for tokens --- diff --git a/migen/flow/ala.py b/migen/flow/ala.py index 03dd9af2..d8693115 100644 --- a/migen/flow/ala.py +++ b/migen/flow/ala.py @@ -1,27 +1,29 @@ from migen.fhdl.structure import * from migen.flow.actor import * +from migen.corelogic.record import * from migen.corelogic import divider -class Sum(Actor): +class Adder(Actor): def __init__(self, width): - self.a = Signal(BV(width)) - self.b = Signal(BV(width)) - self.r = Signal(BV(width+1)) + self.operands = Record([('a', BV(width)), ('b', BV(width))]) + self.result = Record(['sum', BV(width+1)]) Actor.__init__(self, SchedulingModel(SchedulingModel.COMBINATORIAL), - [Sink(self, [self.a, self.b])], - [Source(self, self.r)]) - + [Sink(self, self.operands)], + [Source(self, self.result)]) + def get_process_fragment(self): - return Fragment([self.r.eq(self.a + self.b)]) + return Fragment([self.result.sum.eq(self.operands.a + self.operands.b)]) class Divider(Actor): def __init__(self, width): self.div = divider.Inst(width) + self.operands = Record([('dividend', self.div.dividend_i), ('divisor', self.div.divisor_i)]) + self.result = Record([('quotient', self.div.quotient_o), ('remainder', self.div.remainder_o)]) Actor.__init__(self, SchedulingModel(SchedulingModel.SEQUENTIAL, width), - [Sink(self, [self.div.dividend_i]), Sink(self, [self.div.divisor_i])], - [Source(self, [self.div.quotient_o]), Source(self, [self.div.remainder_o])]) - + [Sink(self, [self.operands])], + [Source(self, [self.result])]) + def get_process_fragment(self): return self.div.get_fragment() + Fragment([self.div.start_i.eq(self.trigger)])