From 16c8af7deabff84fb22de1159f825290a8261c33 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Thu, 7 Mar 2024 18:17:51 +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.6.19=20#1-?= =?UTF-8?q?NixOS=20SMP=20PREEMPT=5FDYNAMIC=20Fri=20Mar=20=201=2012:35:11?= =?UTF-8?q?=20UTC=202024=20x86=5F64=20GNU/Linux=20=20=2018:17:51=20=20up?= =?UTF-8?q?=20=20=203:37,=20=202=20users,=20=20load=20average:=201.58,=200?= =?UTF-8?q?.74,=200.51?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npc/CMakeLists.txt | 11 +---------- npc/core/src/main/scala/Main.scala | 10 +++++++++- npc/core/src/main/scala/ProgramCounter.scala | 11 +++++++++++ npc/core/src/main/scala/RegisterFile.scala | 2 +- npc/flake.nix | 2 -- 5 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 npc/core/src/main/scala/ProgramCounter.scala diff --git a/npc/CMakeLists.txt b/npc/CMakeLists.txt index 2ed0a4c..ef78ddd 100644 --- a/npc/CMakeLists.txt +++ b/npc/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.20) project(npc) -include(CTest) set (CMAKE_CXX_STANDARD 11) cmake_policy(SET CMP0144 NEW) @@ -84,15 +83,7 @@ foreach(TOPMODULE IN LISTS TOPMODULES) add_dependencies(V${TOPMODULE} ChiselBuild_${TOPMODULE}) enable_testing() - add_test(V${TOPMODULE}_build - "${CMAKE_COMMAND}" - --build "${CMAKE_BINARY_DIR}" - --config "$" - --target V${TOPMODULE} - ) - set_tests_properties(V${TOPMODULE}_build PROPERTIES FIXTURES_SETUP V${TOPMODULE}_fixture) - add_test(V${TOPMODULE} V${TOPMODULE}) - set_tests_properties(V${TOPMODULE} PROPERTIES FIXTURES_REQUIRED V${TOPMODULE}_fixture) + add_test(NAME V${TOPMODULE} COMMAND V${TOPMODULE}) # -- Add build tracking add_custom_command( diff --git a/npc/core/src/main/scala/Main.scala b/npc/core/src/main/scala/Main.scala index b58c078..d34a038 100644 --- a/npc/core/src/main/scala/Main.scala +++ b/npc/core/src/main/scala/Main.scala @@ -2,8 +2,10 @@ package npc import chisel3._ import chisel3.util.{MuxLookup, Fill, Decoupled, Counter, Queue, Reverse} +import chisel3.util.{SRAM} import chisel3.stage.ChiselOption -import npc.util.KeyboardSegController +import npc.util.{ KeyboardSegController, RegisterFile } +import flowpc.components.ProgramCounter class Switch extends Module { val io = IO(new Bundle { @@ -30,3 +32,9 @@ class Keyboard extends Module { keyboard_controller.io.ps2 := io.ps2 io.segs := seg_handler.io.segs } + +class Flowpc extends Module { + val io = IO(new Bundle { }) + val register_file = new RegisterFile(readPorts = 2); + val pc = new ProgramCounter(32); +} diff --git a/npc/core/src/main/scala/ProgramCounter.scala b/npc/core/src/main/scala/ProgramCounter.scala new file mode 100644 index 0000000..0687f9a --- /dev/null +++ b/npc/core/src/main/scala/ProgramCounter.scala @@ -0,0 +1,11 @@ +package flowpc.components +import chisel3._ +import chisel3.util.{Valid} + +class ProgramCounter (width: Int) extends Module { + val io = new Bundle { + val next_pc = Input(Flipped(Valid(UInt(width.W)))) + val pc = Output(UInt(width.W)) + } + io.pc := Mux(io.next_pc.valid, io.next_pc.bits, io.pc) +} diff --git a/npc/core/src/main/scala/RegisterFile.scala b/npc/core/src/main/scala/RegisterFile.scala index c6f9229..fbf8a94 100644 --- a/npc/core/src/main/scala/RegisterFile.scala +++ b/npc/core/src/main/scala/RegisterFile.scala @@ -2,7 +2,7 @@ package npc.util import chisel3._ -class RegisterFile(readPorts: Int = 1) extends Module { +class RegisterFile(readPorts: Int) extends Module { require(readPorts >= 0) val io = IO(new Bundle { val writeEnable = Input(Bool()) diff --git a/npc/flake.nix b/npc/flake.nix index b2f65cd..32aa36a 100644 --- a/npc/flake.nix +++ b/npc/flake.nix @@ -19,8 +19,6 @@ packages = [ clang-tools rnix-lsp - coursier - metals gdb jre