contributed by < terry23304 >
class Hello 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
}
Switch the LED output every CNT_MAX
clock cycles.
It is a I/O Bundle that has only one output signal and no input signals. It includes two registers, cntReg
and blkReg
, cntReg
is used to count the number of clock cycles passed. When it reachesCNT_MAX
, which is 24999999
, reset cntReg
to 0 and invert the value of blkReg
. The output will be the same as blkReg
jump_flag_id
to determine next pc will be jump_address_id
or pc + 4
.instruction valid
is false only in the beginning. Therefore, the instruction is 0x00000013
, and after that, the instruction will be 0x00000000
.
The testing instruction would be:
Set memory_read_enable
to 1
when the instruction is of L type and set memory_write_enable
to 1
when the instruction is of S type. Therefore, memory_write_enable
is set to 1
only when executing the instruction sw x10
, 4(x0).
Using aluop_source to determine the values of op1
and op2
. When aluop_source is 0, op will be set to the data in register; otherwise, op will be set to 0 and immediate value.
BINS = \
fibonacci.asmbin \
hello.asmbin \
mmio.asmbin \
quicksort.asmbin \
sb.asmbin \
binarization.asmbin
make update
sbt "testOnly riscv.singlecycle.BinarizationTest"
[info] BinarizationTest:
[info] Single Cycle CPU
[info] - should do binarization with threshold 128
[info] Run completed in 3 seconds, 314 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 4 s, completed Dec 1, 2023, 12:24:30 AM
Execute the following command to generate Verilog file.z
$ make verilator
$ ./run-verilator.sh -instruction src/main/resources/binarization.asmbin -time 2000 -vcd dump.vcd
Then, run gtkwave dump.vcd
to check waveform.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing