From 3ccbccee77a7a68662e6cd68f53e090d20fcd4b5 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Tue, 9 Jan 2024 20:40:32 +0800 Subject: [PATCH] =?UTF-8?q?>=20configure(npc)=20=20ysyx=5F22040000=20?= =?UTF-8?q?=E6=9D=8E=E5=BF=83=E6=9D=A8=20=20Linux=20calcite=206.1.69=20#1-?= =?UTF-8?q?NixOS=20SMP=20PREEMPT=5FDYNAMIC=20Wed=20Dec=2020=2016:00:29=20U?= =?UTF-8?q?TC=202023=20x86=5F64=20GNU/Linux=20=20=2020:40:32=20=20up=201?= =?UTF-8?q?=20day=2019:41,=20=202=20users,=20=20load=20average:=202.01,=20?= =?UTF-8?q?1.24,=200.95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npc/constr/Keyboard.nxdc | 11 +++-------- npc/core/src/main/scala/Keyboard.scala | 2 +- npc/core/src/main/scala/Main.scala | 8 ++++---- npc/core/src/test/scala/Keyboard.scala | 1 + 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/npc/constr/Keyboard.nxdc b/npc/constr/Keyboard.nxdc index db298e2..1493c31 100644 --- a/npc/constr/Keyboard.nxdc +++ b/npc/constr/Keyboard.nxdc @@ -2,11 +2,6 @@ top=Keyboard io_ps2_clk PS2_CLK io_ps2_data PS2_DAT -io_seg_0 (SEG0A, SEG0B, SEG0C, SEG0D, SEG0E, SEG0F, SEG0G, DEC0P) -io_seg_1 (SEG1A, SEG1B, SEG1C, SEG1D, SEG1E, SEG1F, SEG1G, DEC1P) -io_seg_2 (SEG2A, SEG2B, SEG2C, SEG2D, SEG2E, SEG2F, SEG2G, DEC2P) -io_seg_3 (SEG3A, SEG3B, SEG3C, SEG3D, SEG3E, SEG3F, SEG3G, DEC3P) -io_seg_4 (SEG4A, SEG4B, SEG4C, SEG4D, SEG4E, SEG4F, SEG4G, DEC4P) -io_seg_5 (SEG5A, SEG5B, SEG5C, SEG5D, SEG5E, SEG5F, SEG5G, DEC5P) -io_seg_6 (SEG6A, SEG6B, SEG6C, SEG6D, SEG6E, SEG6F, SEG6G, DEC6P) -io_seg_7 (SEG7A, SEG7B, SEG7C, SEG7D, SEG7E, SEG7F, SEG7G, DEC7P) +io_seg_0 (SEG1A, SEG1B, SEG1C, SEG1D, SEG1E, SEG1F, SEG1G, DEC1P, SEG0A, SEG0B, SEG0C, SEG0D, SEG0E, SEG0F, SEG0G, DEC0P) +io_seg_1 (SEG3A, SEG3B, SEG3C, SEG3D, SEG3E, SEG3F, SEG3G, DEC3P, SEG2A, SEG2B, SEG2C, SEG2D, SEG2E, SEG2F, SEG2G, DEC2P) +io_seg_2 (SEG5A, SEG5B, SEG5C, SEG5D, SEG5E, SEG5F, SEG5G, DEC5P, SEG4A, SEG4B, SEG4C, SEG4D, SEG4E, SEG4F, SEG4G, DEC4P) diff --git a/npc/core/src/main/scala/Keyboard.scala b/npc/core/src/main/scala/Keyboard.scala index 92126e3..d523a84 100644 --- a/npc/core/src/main/scala/Keyboard.scala +++ b/npc/core/src/main/scala/Keyboard.scala @@ -63,7 +63,7 @@ class SegHandler(seg_count: Int) extends Module { }) - val seg_regs = RegInit(VecInit(Seq.fill(seg_count)(0.U(4.W)))) + val seg_regs = RegInit(VecInit(Seq.fill(seg_count / 2)(0.U(8.W)))) val last_keycode = RegInit(0.U(8.W)) val counter = Counter(0xFF) val digit_to_seg = Seq( diff --git a/npc/core/src/main/scala/Main.scala b/npc/core/src/main/scala/Main.scala index 6ec8ae7..38a7e60 100644 --- a/npc/core/src/main/scala/Main.scala +++ b/npc/core/src/main/scala/Main.scala @@ -85,14 +85,14 @@ import npc.keyboard._ class Keyboard extends Module { val io = IO(new Bundle { val ps2 = PS2Port() - val segs = Output(Vec(6, UInt(4.W))) + val segs = Output(Vec(3, UInt(8.W))) }) - val keyboard_controller = Module(new KeyboardController) val seg_handler = Module(new SegHandler(6)) + val keyboard_controller = Module(new KeyboardController) seg_handler.io.keycode <> keyboard_controller.io.out - io <> keyboard_controller.io - io <> seg_handler.io + keyboard_controller.io.ps2 := io.ps2 + io.segs := seg_handler.io.segs } \ No newline at end of file diff --git a/npc/core/src/test/scala/Keyboard.scala b/npc/core/src/test/scala/Keyboard.scala index ee7ec28..625859e 100644 --- a/npc/core/src/test/scala/Keyboard.scala +++ b/npc/core/src/test/scala/Keyboard.scala @@ -57,6 +57,7 @@ class KeyboardControllerSpec extends AnyFreeSpec with ChiselScalatestTester { }) } } + import npc.Keyboard "Keyboard Simulation" in { test(new Keyboard) { c => }