1 from nmigen
.compat
.sim
import run_simulation
2 from nmigen
.cli
import verilog
, rtlil
3 from nmigen
import Module
, Signal
, Array
, Elaboratable
5 from regfile
.regfile
import RegFileArray
6 from scoreboard
.fn_unit
import IntFnUnit
, FPFnUnit
, LDFnUnit
, STFnUnit
7 from scoreboard
.fu_fu_matrix
import FUFUDepMatrix
9 from alu_hier
import Adder
, Subtractor
11 class Scoreboard(Elaboratable
):
12 def __init__(self
, reg_width
, reg_depth
):
13 self
.reg_width
= reg_width
14 self
.reg_depth
= reg_depth
17 self
.intregs
= RegFileArray(reg_width
, reg_depth
)
18 self
.int_dest
= self
.intregs
.write_port()
19 self
.int_src1
= self
.intregs
.read_port()
20 self
.int_src2
= self
.intregs
.read_port()
22 self
.fpregs
= RegFileArray(reg_width
, reg_depth
)
23 self
.fp_dest
= self
.fpregs
.write_port()
24 self
.fp_src1
= self
.fpregs
.read_port()
25 self
.fp_src2
= self
.fpregs
.read_port()
27 def elaborate(self
, platform
):
29 m
.submodules
.intregs
= self
.intregs
30 m
.submodules
.fpregs
= self
.fpregs
33 m
.submodules
.adder
= adder
= Adder(self
.reg_width
)
34 m
.submodules
.subtractor
= subtractor
= Subtractor(self
.reg_width
)
35 int_alus
= [adder
, subtractor
]
39 for i
, a
in enumerate(int_alus
):
40 fu
= IntFnUnit(self
.reg_width
, shadow_wid
=0)
41 setattr(m
.submodules
, "intfu%d" % i
, fu
)
48 m
.submodules
.fudeps
= fudeps
= FUFUDepMatrix(n_fus
, n_fus
)
54 yield from self
.intregs
55 yield from self
.fpregs
56 #yield from self.int_src1
57 #yield from self.int_dest
58 #yield from self.int_src1
59 #yield from self.int_src2
60 #yield from self.fp_dest
61 #yield from self.fp_src1
62 #yield from self.fp_src2
68 def scoreboard_sim(dut
):
69 yield dut
.dest_i
.eq(1)
70 yield dut
.issue_i
.eq(1)
72 yield dut
.issue_i
.eq(0)
74 yield dut
.src1_i
.eq(1)
75 yield dut
.issue_i
.eq(1)
79 yield dut
.issue_i
.eq(0)
81 yield dut
.go_read_i
.eq(1)
83 yield dut
.go_read_i
.eq(0)
85 yield dut
.go_write_i
.eq(1)
87 yield dut
.go_write_i
.eq(0)
90 def test_scoreboard():
91 dut
= Scoreboard(32, 8)
92 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
93 with
open("test_scoreboard.il", "w") as f
:
96 run_simulation(dut
, scoreboard_sim(dut
), vcd_name
='test_scoreboard.vcd')
98 if __name__
== '__main__':