-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported the Verilog version which I've been working on
This now works with Icarus and Verilator, and the design can be synthesized with the IceStorm toolchain to run on the TinyFPGA B2 device.
- Loading branch information
Warren Toomey
committed
Jan 3, 2018
1 parent
0e70f5f
commit b964da6
Showing
25 changed files
with
919 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
test.vcd: cscv2_tb.out alu.rom toprom.rom botrom.rom | ||
vvp cscv2_tb.out | less | ||
test.vcd: icarus_tb.out toprom.rom botrom.rom | ||
vvp icarus_tb.out | less | ||
|
||
alu.rom: ../alu.rom | ||
grep -v raw ../alu.rom > alu.rom | ||
icarus_tb.out: icarus_tb.v icarus_top.v alu.v botrom.v cscv2.v pc.v ram.v \ | ||
register.v toprom.v | ||
iverilog -o icarus_tb.out icarus_tb.v | ||
|
||
toprom.rom: ../toprom.rom | ||
grep -v raw ../toprom.rom > toprom.rom | ||
|
||
botrom.rom: ../botrom.rom | ||
grep -v raw ../botrom.rom > botrom.rom | ||
|
||
cscv2_tb.out: cscv2_tb.v alu.v botrom.v cscv2.v pc.v ram.v register.v toprom.v | ||
iverilog -o cscv2_tb.out cscv2_tb.v | ||
|
||
clean: | ||
rm -f *.vcd *.out | ||
|
||
realclean: | ||
rm -f *.out *.vcd *.rom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,67 @@ | ||
# Icarus Verilog Version of Crazy Small CPU Version 2 | ||
# Verilog Version of Crazy Small CPU Version 2 | ||
|
||
This is an implementation of the CSCv2 CPU in Icarus Verilog. Assuming | ||
that you have this installed, and you have the three *.rom files already | ||
built in the parent directory, you can do: | ||
This directory contains an implementation of the CSCv2 CPU in Verilog, | ||
which can both be simulated and synthesised on to an FPGA. There are | ||
three make files: Makefile, VerMakefile and YoMakefile. | ||
|
||
## Icarus Verilog | ||
|
||
If you have Icarus Verilog and you have assembled botrom.rom and toprom.rom | ||
files in the parent directory, you can do: | ||
|
||
``` | ||
make | ||
``` | ||
|
||
to compile the Verilog sources here and run the CPU with those ROM images. | ||
to compile the Verilog sources here and run the CPU with these ROM images. | ||
This will also produce a ```test.vcd`` waveform output file. You can also | ||
```make clean``` to remove the output files, and ```make realclean``` to | ||
do the same but also to remove the copies of the ROM images in this directory. | ||
|
||
## Verilator | ||
|
||
If you have Verilator installed, you can simulate the CPU with this tool. | ||
Once you have assembled botrom.rom and toprom.rom files in the parent | ||
directory, you can do: | ||
|
||
``` | ||
make -f VerMakefile | ||
``` | ||
|
||
to compile the Verilog sources here with Verilator and run the CPU with these | ||
ROM images. You can also ```make clean``` to remove the output files. | ||
|
||
## IceStorm and TinyFPGA B2 | ||
|
||
If you have a TinyFPGA B2 and the IceStorm toolchain installed, you can | ||
synthesize a bitstream to program onto this device. | ||
Once you have assembled botrom.rom and toprom.rom files in the parent | ||
directory, you can do: | ||
|
||
``` | ||
make -f VerMakefile | ||
``` | ||
|
||
to compile the Verilog sources here with yosys and friends, and this will | ||
produce the bitstream file TinyFPGA_B.bin. | ||
You can also ```make clean``` to remove the output files. | ||
|
||
## Changes from the Chip Version of CSCv2 | ||
|
||
Firstly, the ram.v component waits a clock cycle before it | ||
outputs when the address changes. So we give it a clock signal | ||
twice the frequency of the main CPU clock signal. | ||
|
||
A synthesised design can't have "initial" values for registers and the PC, | ||
so there is now a reset line which, when high, resets the registers and the | ||
PC to zero. | ||
|
||
The UART is now separate from the CPU, but we output the TX | ||
control line which is still the OR of Aload, Bload and the clock. | ||
|
||
Because the high impedance logic state doesn't get synthesised well, | ||
there is a new multiplexer, databus. This chooses either the RAM | ||
output or the ALU output based on the RAMwrite control line. | ||
|
||
Note: This is the first Verilog code that I've written, so it is probably | ||
simplistic and could be improved. Feel free to let me know how I can | ||
improve it. | ||
Apart from the above, everything else is exactly the same as the | ||
CSCv2 version made from 7400-style chips. |
Oops, something went wrong.