|
1 | 1 | from migen.fhdl.structure import *
|
| 2 | +from migen.fhdl.specials import Instance |
| 3 | +from migen.bus import wishbone |
2 | 4 | from migen.fhdl import verilog
|
3 | 5 |
|
4 | 6 | class LM32:
|
5 | 7 | def __init__(self):
|
6 |
| - self.inst = Instance("lm32_top", |
| 8 | + self.ibus = i = wishbone.Interface() |
| 9 | + self.dbus = d = wishbone.Interface() |
| 10 | + self.interrupt = Signal(32) |
| 11 | + self.ext_break = Signal() |
| 12 | + self._i_adr_o = Signal(32) |
| 13 | + self._d_adr_o = Signal(32) |
| 14 | + self._inst = Instance("lm32_top", |
7 | 15 | Instance.ClockPort("clk_i"),
|
8 | 16 | Instance.ResetPort("rst_i"),
|
9 |
| - |
10 |
| - Instance.Input("interrupt", 32), |
11 |
| - Instance.Input("ext_break", 1), |
12 |
| - |
13 |
| - Instance.Output("I_ADR_O", 32), |
14 |
| - Instance.Output("I_DAT_O", 32), |
15 |
| - Instance.Output("I_SEL_O", 4), |
16 |
| - Instance.Output("I_CYC_O", 1), |
17 |
| - Instance.Output("I_STB_O", 1), |
18 |
| - Instance.Output("I_WE_O", 1), |
19 |
| - Instance.Output("I_CTI_O", 3), |
20 |
| - Instance.Output("I_LOCK_O", 1), |
21 |
| - Instance.Output("I_BTE_O", 1), |
22 |
| - Instance.Input("I_DAT_I", 32), |
23 |
| - Instance.Input("I_ACK_I", 1), |
24 |
| - Instance.Input("I_ERR_I", 1), |
25 |
| - Instance.Input("I_RTY_I", 1), |
26 | 17 |
|
27 |
| - Instance.Output("D_ADR_O", 32), |
28 |
| - Instance.Output("D_DAT_O", 32), |
29 |
| - Instance.Output("D_SEL_O", 4), |
30 |
| - Instance.Output("D_CYC_O", 1), |
31 |
| - Instance.Output("D_STB_O", 1), |
32 |
| - Instance.Output("D_WE_O", 1), |
33 |
| - Instance.Output("D_CTI_O", 3), |
34 |
| - Instance.Output("D_LOCK_O", 1), |
35 |
| - Instance.Output("D_BTE_O", 1), |
36 |
| - Instance.Input("D_DAT_I", 32), |
37 |
| - Instance.Input("D_ACK_I", 1), |
38 |
| - Instance.Input("D_ERR_I", 1), |
39 |
| - Instance.Input("D_RTY_I", 1), |
| 18 | + Instance.Input("interrupt", self.interrupt), |
| 19 | + #Instance.Input("ext_break", self.ext_break), |
| 20 | + |
| 21 | + Instance.Output("I_ADR_O", self._i_adr_o), |
| 22 | + Instance.Output("I_DAT_O", i.dat_w), |
| 23 | + Instance.Output("I_SEL_O", i.sel), |
| 24 | + Instance.Output("I_CYC_O", i.cyc), |
| 25 | + Instance.Output("I_STB_O", i.stb), |
| 26 | + Instance.Output("I_WE_O", i.we), |
| 27 | + Instance.Output("I_CTI_O", i.cti), |
| 28 | + Instance.Output("I_LOCK_O"), |
| 29 | + Instance.Output("I_BTE_O", i.bte), |
| 30 | + Instance.Input("I_DAT_I", i.dat_r), |
| 31 | + Instance.Input("I_ACK_I", i.ack), |
| 32 | + Instance.Input("I_ERR_I", i.err), |
| 33 | + Instance.Input("I_RTY_I", 0), |
40 | 34 |
|
41 |
| - name="lm32") |
42 |
| - |
| 35 | + Instance.Output("D_ADR_O", self._d_adr_o), |
| 36 | + Instance.Output("D_DAT_O", d.dat_w), |
| 37 | + Instance.Output("D_SEL_O", d.sel), |
| 38 | + Instance.Output("D_CYC_O", d.cyc), |
| 39 | + Instance.Output("D_STB_O", d.stb), |
| 40 | + Instance.Output("D_WE_O", d.we), |
| 41 | + Instance.Output("D_CTI_O", d.cti), |
| 42 | + Instance.Output("D_LOCK_O"), |
| 43 | + Instance.Output("D_BTE_O", d.bte), |
| 44 | + Instance.Input("D_DAT_I", d.dat_r), |
| 45 | + Instance.Input("D_ACK_I", d.ack), |
| 46 | + Instance.Input("D_ERR_I", d.err), |
| 47 | + Instance.Input("D_RTY_I", 0)) |
| 48 | + |
43 | 49 | def get_fragment(self):
|
44 |
| - return Fragment(instances=[self.inst]) |
| 50 | + comb = [ |
| 51 | + self.ibus.adr.eq(self._i_adr_o[2:]), |
| 52 | + self.dbus.adr.eq(self._d_adr_o[2:]) |
| 53 | + ] |
| 54 | + return Fragment(comb=comb, specials={self._inst}) |
45 | 55 |
|
46 | 56 | cpus = [LM32() for i in range(4)]
|
47 | 57 | frag = Fragment()
|
48 | 58 | for cpu in cpus:
|
49 | 59 | frag += cpu.get_fragment()
|
50 |
| -print(verilog.convert(frag, set([cpus[0].inst.get_io("interrupt"), cpus[0].inst.get_io("I_WE_O")]))) |
| 60 | +print(verilog.convert(frag, {cpus[0].interrupt})) |
0 commit comments