File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 "tasks" : [
44 {
55 "label" : " Test" ,
6- "command" : " sbt run test" ,
6+ "command" : " sbt test" ,
77 "type" : " shell" ,
88 "args" : [],
99 "problemMatcher" : [],
Original file line number Diff line number Diff line change 1+ package RISCV
2+
3+ import chisel3 ._
4+ import chisel3 .util ._
5+ import _root_ .circt .stage .ChiselStage
6+
7+ /**
8+ * @param width Bit width (default: 32 bits)
9+ */
10+ class Decoder (val width : Int = 32 ) extends Module {
11+ val io = IO (new Bundle {
12+ val instruction = Input (UInt (32 .W ));
13+ val operation = Output (UInt (17 .W ));
14+ val rs1 = Output (UInt (5 .W ));
15+ val rs2 = Output (UInt (5 .W ));
16+ val rd = Output (UInt (5 .W ));
17+ val immediate = Output (UInt (32 .W ));
18+ })
19+
20+ io.rs1 := io.instruction(19 , 15 );
21+ io.rs2 := io.instruction(24 , 20 );
22+ io.rd := io.instruction(11 , 7 );
23+
24+ io.operation := 0 .U ;
25+
26+ io.immediate := 0 .U ;
27+ }
28+
29+ object Decoder extends App {
30+ ChiselStage .emitSystemVerilogFile(
31+ new Decoder (),
32+ firtoolOpts = Array (
33+ " -disable-all-randomization" ,
34+ " -strip-debug-info" ,
35+ " -default-layer-specialization=enable"
36+ ),
37+ args = Array (" --target-dir" , " generated" )
38+ )
39+ }
Original file line number Diff line number Diff line change 1+ package RISCV
2+
3+ import chisel3 ._
4+ import chisel3 .experimental .BundleLiterals ._
5+ import chisel3 .simulator .scalatest .ChiselSim
6+ import org .scalatest .freespec .AnyFreeSpec
7+ import org .scalatest .matchers .must .Matchers
8+
9+ class DecoderTest extends AnyFreeSpec with Matchers with ChiselSim {
10+ " Decoder should pass tests" in {
11+ simulate(new Decoder ()) { dut =>
12+ dut.io.instruction.poke(0 .U );
13+ }
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments