[Evaluation and experience of Zhongke Yihaiwei EQ6HL45 development platform] + Using the emerging digital circuit design language Chisel to develop FPGA[Copy link]
Using the emerging digital circuit design language Chisel to develop EHiWAY-FPGA
import chisel3._
class HelloLED extends Module {
val io = IO(new Bundle {
val led = Output(UInt(1.W))
})
val CNT_MAX = (50000000 / 2 -1).U;
val cntReg = RegInit(0.U(32.W))
val blkReg = RegInit(0.U(1.W))
cntReg := cntReg + 1.U
when(cntReg === CNT_MAX) {
cntReg := 0.U
blkReg := ~ blkReg
}
io.led := blkReg
}
object HelloLED extends App {
(new chisel3.stage.ChiselStage).emitVerilog(new HelloLED())
}
PS1: Since the LED on the FPGA development board is lit at a low level, the blkReg initialization value should be changed to 1'b1, that is,
val blkReg = RegInit(1.U(1.W))
Input the top file of the project HelloLED_top.v
Also, since the buttons on the FPGA development board are at a low level when pressed, in order to keep the Scala code simple, add the Verilog source code of the top module to invert the signal. At this time, HelloLED.scala does not need to modify the initial level of the LED, that is, there is no need to follow the changes in the aforementioned PS1.