Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
js4ngu authored Sep 10, 2024
0 parents commit 2632830
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Scala CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Run tests
run: sbt test
- name: Generate verilog
run: sbt run
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generate Verilog code
doit:
sbt run

# Run the test
test:
sbt test

clean:
git clean -fd

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# chisel-empty

An almost empty chisel project as a starting point for hardware design.

See the `Makefile` for the hardware and test targets.
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
scalaVersion := "2.12.13"

scalacOptions ++= Seq(
"-feature",
"-language:reflectiveCalls",
)

// Chisel 3.5
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.5.6" cross CrossVersion.full)
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.5.6"
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.5.6"
1 change: 1 addition & 0 deletions quartus/add.qpf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJECT_REVISION = "add"
21 changes: 21 additions & 0 deletions quartus/add.qsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set_global_assignment -name FAMILY "Cyclone IV E"
set_global_assignment -name DEVICE EP4CE115F29C7

set_global_assignment -name TOP_LEVEL_ENTITY Add
set_global_assignment -name VERILOG_FILE ../generated/Add.v
set_global_assignment -name VERILOG_MACRO "SYNTHESIS=<None>"

set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
set_global_assignment -name USE_CONFIGURATION_DEVICE OFF
set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "3.3-V LVCMOS"


set_location_assignment PIN_Y2 -to clock

set_global_assignment -name LAST_QUARTUS_VERSION "16.1.0 Lite Edition"
set_global_assignment -name RESERVE_ALL_UNUSED_PINS "AS INPUT TRI-STATED WITH WEAK PULL-UP"


set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
29 changes: 29 additions & 0 deletions src/main/scala/empty/Add.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Dummy file to start a Chisel project.
*
* Author: Martin Schoeberl ([email protected])
*
*/

package empty

import chisel3._
import chisel3.util._

class Add extends Module {
val io = IO(new Bundle {
val a = Input(UInt(8.W))
val b = Input(UInt(8.W))
val c = Output(UInt(8.W))
})

val reg = RegInit(0.U(8.W))
reg := io.a + io.b

io.c := reg
}

object AddMain extends App {
println("Generating the adder hardware")
emitVerilog(new Add(), Array("--target-dir", "generated"))
}
29 changes: 29 additions & 0 deletions src/test/scala/empty/AddTester.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Dummy tester to start a Chisel project.
*
* Author: Martin Schoeberl ([email protected])
*
*/

package empty

import chisel3._
import chiseltest._
import org.scalatest.flatspec.AnyFlatSpec

class AddTester extends AnyFlatSpec with ChiselScalatestTester {

"Add" should "work" in {
test(new Add) { dut =>
for (a <- 0 to 2) {
for (b <- 0 to 3) {
val result = a + b
dut.io.a.poke(a.U)
dut.io.b.poke(b.U)
dut.clock.step(1)
dut.io.c.expect(result.U)
}
}
}
}
}

0 comments on commit 2632830

Please sign in to comment.