Add Batch 4 with 10 repos
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- MIPSfpga_schoolMIPS/README.md +21 -0
- MIPSfpga_schoolMIPS/board/de0/de0_top.sdc +19 -0
- MIPSfpga_schoolMIPS/board/de0/de0_top.v +119 -0
- MIPSfpga_schoolMIPS/board/de0_cv/de0_cv.sdc +19 -0
- MIPSfpga_schoolMIPS/board/de0_cv/de0_cv.v +88 -0
- MIPSfpga_schoolMIPS/board/de0_nano/README.md +22 -0
- MIPSfpga_schoolMIPS/board/de0_nano/de0_nano.sdc +19 -0
- MIPSfpga_schoolMIPS/board/de0_nano/de0_nano.v +35 -0
- MIPSfpga_schoolMIPS/board/de10_lite/de10_lite.sdc +18 -0
- MIPSfpga_schoolMIPS/board/de10_lite/de10_lite.v +66 -0
- MIPSfpga_schoolMIPS/board/de10_nano/de10_nano.sdc +21 -0
- MIPSfpga_schoolMIPS/board/de10_nano/de10_nano.v +62 -0
- MIPSfpga_schoolMIPS/board/de10_standard/de10_standard.sdc +27 -0
- MIPSfpga_schoolMIPS/board/de10_standard/de10_standard.v +58 -0
- MIPSfpga_schoolMIPS/board/de1_soc/de1_soc.sdc +16 -0
- MIPSfpga_schoolMIPS/board/de1_soc/de1_soc.v +226 -0
- MIPSfpga_schoolMIPS/board/de4_230/DE4_230.sdc +25 -0
- MIPSfpga_schoolMIPS/board/de4_230/de4_230.v +59 -0
- MIPSfpga_schoolMIPS/board/marsohod_3/help.txt +4 -0
- MIPSfpga_schoolMIPS/board/marsohod_3/marsohod_3.sdc +10 -0
- MIPSfpga_schoolMIPS/board/marsohod_3/marsohod_3.v +33 -0
- MIPSfpga_schoolMIPS/board/marsohod_3b/help.txt +4 -0
- MIPSfpga_schoolMIPS/board/marsohod_3b/marsohod_3b.sdc +10 -0
- MIPSfpga_schoolMIPS/board/marsohod_3b/marsohod_3b.v +33 -0
- MIPSfpga_schoolMIPS/board/max_10_evkit/README.md +28 -0
- MIPSfpga_schoolMIPS/board/max_10_evkit/max_10_evkit.v +32 -0
- MIPSfpga_schoolMIPS/board/max_10_neek/max_10_neek.sdc +14 -0
- MIPSfpga_schoolMIPS/board/max_10_neek/max_10_neek.v +280 -0
- MIPSfpga_schoolMIPS/board/nexys4/nexys4.v +89 -0
- MIPSfpga_schoolMIPS/board/nexys4_ddr/nexys4_ddr.v +97 -0
- MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/README.md +20 -0
- MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/rz_easyFPGA_A21.sdc +11 -0
- MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/rz_easyFPGA_A21.v +31 -0
- MIPSfpga_schoolMIPS/board/zeowaa/zeowaa.sdc +13 -0
- MIPSfpga_schoolMIPS/board/zeowaa/zeowaa.v +62 -0
- MIPSfpga_schoolMIPS/doc/README.md +2 -0
- MIPSfpga_schoolMIPS/program/00_counter/modelsim_script.tcl +24 -0
- MIPSfpga_schoolMIPS/program/01_fibonacci/modelsim_script.tcl +24 -0
- MIPSfpga_schoolMIPS/program/02_sqrt/modelsim_script.tcl +25 -0
- MIPSfpga_schoolMIPS/src/sm_cpu.v +184 -0
- MIPSfpga_schoolMIPS/src/sm_cpu.vh +41 -0
- MIPSfpga_schoolMIPS/src/sm_hex_display.v +88 -0
- MIPSfpga_schoolMIPS/src/sm_register.v +31 -0
- MIPSfpga_schoolMIPS/src/sm_rom.v +17 -0
- MIPSfpga_schoolMIPS/src/sm_top.v +88 -0
- MIPSfpga_schoolMIPS/testbench/testbench.v +137 -0
- ShawnHymel_introduction-to-fpga/02-install-apio/solution-turn-off-led/leds.v +18 -0
- ShawnHymel_introduction-to-fpga/02-install-apio/solution-turn-off-led/leds_tb.v +45 -0
- ShawnHymel_introduction-to-fpga/03-verilog-gate-logic/example-01-and-gate/and_gate.v +29 -0
- ShawnHymel_introduction-to-fpga/03-verilog-gate-logic/example-02-vectors/vectors.v +36 -0
MIPSfpga_schoolMIPS/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# schoolMIPS
|
| 2 |
+
|
| 3 |
+
A small MIPS CPU core originally based on Sarah L. Harris MIPS CPU ("Digital Design and Computer Arhitecture" by David Money Harris and Sarah L Harris). The first version of schoolMIPS was written for [Young Russian Chip Architects](http://www.silicon-russia.com/2017/06/09/arduino-and-fpga/) summer school.
|
| 4 |
+
|
| 5 |
+
Next version of schoolMIPS is based on RISC-V architecture: [schoolRISCV](https://github.com/zhelnio/schoolRISCV)
|
| 6 |
+
|
| 7 |
+
The CPU have several versions (from simple to complex). Each of them is placed in the separate git branch:
|
| 8 |
+
- **00_simple** - the simplest CPU without data memory, programs compiled with GNU gcc;
|
| 9 |
+
- **01_mmio** - the same but with data memory, simple system bus and peripherals (pwm, gpio, als);
|
| 10 |
+
- **01_mmio_sv_dpi** - the same but with data memory, simple system bus and peripherals (pwm, gpio, als);
|
| 11 |
+
- **02_irq** - data memory, system timer, interrupts and exceptions (CP0 coprocessor);
|
| 12 |
+
- **03_pipeline** - the pipelined version of the simplest core with data memory
|
| 13 |
+
- **04_pipeline_irq** - the pipelined version of 02_irq
|
| 14 |
+
|
| 15 |
+
Examples of using this kernel as an element of a multiprocessor system:
|
| 16 |
+
1. A.E. Ryazanova, A.A. Amerikanov, E. V Lezhnev, Development of multiprocessor system-on-chip based on soft processor cores schoolMIPS, J. Phys. Conf. Ser. 1163 (2019) 012026. [doi:10.1088/1742-6596/1163/1/012026](https://iopscience.iop.org/article/10.1088/1742-6596/1163/1/012026).
|
| 17 |
+
2. [Innovate FPGA 2019 project: EM028 » NoC-based multiprocessing system prototype](http://www.innovatefpga.com/cgi-bin/innovate/teams.pl?Id=EM028)
|
| 18 |
+
|
| 19 |
+
For docs and CPU diagrams please visit the project [wiki](https://github.com/MIPSfpga/schoolMIPS/wiki)
|
| 20 |
+
|
| 21 |
+

|
MIPSfpga_schoolMIPS/board/de0/de0_top.sdc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.0 MHz" [get_ports CLOCK_50]
|
| 3 |
+
create_clock -period "50.0 MHz" [get_ports CLOCK_50_2]
|
| 4 |
+
|
| 5 |
+
derive_clock_uncertainty
|
| 6 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLOCK_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 7 |
+
|
| 8 |
+
set_false_path -from * -to [get_ports {LEDG[*]}]
|
| 9 |
+
set_false_path -from * -to [get_ports {HEX0_D[*]}]
|
| 10 |
+
set_false_path -from * -to [get_ports {HEX1_D[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {HEX2_D[*]}]
|
| 12 |
+
set_false_path -from * -to [get_ports {HEX3_D[*]}]
|
| 13 |
+
set_false_path -from * -to [get_ports {HEX0_DP}]
|
| 14 |
+
set_false_path -from * -to [get_ports {HEX1_DP}]
|
| 15 |
+
set_false_path -from * -to [get_ports {HEX2_DP}]
|
| 16 |
+
set_false_path -from * -to [get_ports {HEX3_DP}]
|
| 17 |
+
|
| 18 |
+
set_false_path -from [get_ports {BUTTON[*]}] -to [all_clocks]
|
| 19 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/de0/de0_top.v
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module de0_top
|
| 3 |
+
(
|
| 4 |
+
input CLOCK_50, // Clock 50 MHz
|
| 5 |
+
input CLOCK_50_2, // Clock 50 MHz
|
| 6 |
+
|
| 7 |
+
input [ 2:0] BUTTON, // Pushbutton[2:0]
|
| 8 |
+
|
| 9 |
+
input [ 9:0] SW, // Toggle Switch[9:0]
|
| 10 |
+
|
| 11 |
+
output [ 6:0] HEX0_D, // Seven Segment Digit 0
|
| 12 |
+
output HEX0_DP, // Seven Segment Digit DP 0
|
| 13 |
+
output [ 6:0] HEX1_D, // Seven Segment Digit 1
|
| 14 |
+
output HEX1_DP, // Seven Segment Digit DP 1
|
| 15 |
+
output [ 6:0] HEX2_D, // Seven Segment Digit 2
|
| 16 |
+
output HEX2_DP, // Seven Segment Digit DP 2
|
| 17 |
+
output [ 6:0] HEX3_D, // Seven Segment Digit 3
|
| 18 |
+
output HEX3_DP, // Seven Segment Digit DP 3
|
| 19 |
+
|
| 20 |
+
output [ 9:0] LEDG, // LED Green[9:0]
|
| 21 |
+
|
| 22 |
+
output UART_TXD, // UART Transmitter
|
| 23 |
+
input UART_RXD, // UART Receiver
|
| 24 |
+
output UART_CTS, // UART Clear To Send
|
| 25 |
+
input UART_RTS, // UART Request To Send
|
| 26 |
+
|
| 27 |
+
inout [15:0] DRAM_DQ, // SDRAM Data bus 16 Bits
|
| 28 |
+
output [12:0] DRAM_ADDR, // SDRAM Address bus 13 Bits
|
| 29 |
+
output DRAM_LDQM, // SDRAM Low-byte Data Mask
|
| 30 |
+
output DRAM_UDQM, // SDRAM High-byte Data Mask
|
| 31 |
+
output DRAM_WE_N, // SDRAM Write Enable
|
| 32 |
+
output DRAM_CAS_N, // SDRAM Column Address Strobe
|
| 33 |
+
output DRAM_RAS_N, // SDRAM Row Address Strobe
|
| 34 |
+
output DRAM_CS_N, // SDRAM Chip Select
|
| 35 |
+
output DRAM_BA_0, // SDRAM Bank Address 0
|
| 36 |
+
output DRAM_BA_1, // SDRAM Bank Address 1
|
| 37 |
+
output DRAM_CLK, // SDRAM Clock
|
| 38 |
+
output DRAM_CKE, // SDRAM Clock Enable
|
| 39 |
+
|
| 40 |
+
inout [14:0] FL_DQ, // FLASH Data bus 15 Bits
|
| 41 |
+
inout FL_DQ15_AM1, // FLASH Data bus Bit 15 or Address A-1
|
| 42 |
+
output [21:0] FL_ADDR, // FLASH Address bus 22 Bits
|
| 43 |
+
output FL_WE_N, // FLASH Write Enable
|
| 44 |
+
output FL_RST_N, // FLASH Reset
|
| 45 |
+
output FL_OE_N, // FLASH Output Enable
|
| 46 |
+
output FL_CE_N, // FLASH Chip Enable
|
| 47 |
+
output FL_WP_N, // FLASH Hardware Write Protect
|
| 48 |
+
output FL_BYTE_N, // FLASH Selects 8/16-bit mode
|
| 49 |
+
input FL_RY, // FLASH Ready/Busy
|
| 50 |
+
|
| 51 |
+
inout [ 7:0] LCD_DATA, // LCD Data bus 8 bits
|
| 52 |
+
output LCD_BLON, // LCD Back Light ON/OFF
|
| 53 |
+
output LCD_RW, // LCD Read/Write Select, 0 = Write, 1 = Read
|
| 54 |
+
output LCD_EN, // LCD Enable
|
| 55 |
+
output LCD_RS, // LCD Command/Data Select, 0 = Command, 1 = Data
|
| 56 |
+
|
| 57 |
+
inout SD_DAT0, // SD Card Data 0
|
| 58 |
+
inout SD_DAT3, // SD Card Data 3
|
| 59 |
+
inout SD_CMD, // SD Card Command Signal
|
| 60 |
+
output SD_CLK, // SD Card Clock
|
| 61 |
+
input SD_WP_N, // SD Card Write Protect
|
| 62 |
+
|
| 63 |
+
inout PS2_KBDAT, // PS2 Keyboard Data
|
| 64 |
+
inout PS2_KBCLK, // PS2 Keyboard Clock
|
| 65 |
+
inout PS2_MSDAT, // PS2 Mouse Data
|
| 66 |
+
inout PS2_MSCLK, // PS2 Mouse Clock
|
| 67 |
+
|
| 68 |
+
output VGA_HS, // VGA H_SYNC
|
| 69 |
+
output VGA_VS, // VGA V_SYNC
|
| 70 |
+
output [3:0] VGA_R, // VGA Red[3:0]
|
| 71 |
+
output [3:0] VGA_G, // VGA Green[3:0]
|
| 72 |
+
output [3:0] VGA_B, // VGA Blue[3:0]
|
| 73 |
+
|
| 74 |
+
input [ 1:0] GPIO0_CLKIN, // GPIO Connection 0 Clock In Bus
|
| 75 |
+
output [ 1:0] GPIO0_CLKOUT, // GPIO Connection 0 Clock Out Bus
|
| 76 |
+
inout [31:0] GPIO0_D, // GPIO Connection 0 Data Bus
|
| 77 |
+
input [ 1:0] GPIO1_CLKIN, // GPIO Connection 1 Clock In Bus
|
| 78 |
+
output [ 1:0] GPIO1_CLKOUT, // GPIO Connection 1 Clock Out Bus
|
| 79 |
+
inout [31:0] GPIO1_D // GPIO Connection 1 Data Bus
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
// wires & inputs
|
| 83 |
+
wire clk;
|
| 84 |
+
wire clkIn = CLOCK_50;
|
| 85 |
+
wire rst_n = BUTTON[0];
|
| 86 |
+
wire clkEnable = SW [9] | ~BUTTON[1];
|
| 87 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 88 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 89 |
+
wire [ 31:0 ] regData;
|
| 90 |
+
|
| 91 |
+
//cores
|
| 92 |
+
sm_top sm_top
|
| 93 |
+
(
|
| 94 |
+
.clkIn ( clkIn ),
|
| 95 |
+
.rst_n ( rst_n ),
|
| 96 |
+
.clkDevide ( clkDevide ),
|
| 97 |
+
.clkEnable ( clkEnable ),
|
| 98 |
+
.clk ( clk ),
|
| 99 |
+
.regAddr ( regAddr ),
|
| 100 |
+
.regData ( regData )
|
| 101 |
+
);
|
| 102 |
+
|
| 103 |
+
//outputs
|
| 104 |
+
assign LEDG[0] = clk;
|
| 105 |
+
assign LEDG[9:1] = regData[8:0];
|
| 106 |
+
|
| 107 |
+
wire [ 31:0 ] h7segment = regData;
|
| 108 |
+
|
| 109 |
+
assign HEX0_DP = 1'b1;
|
| 110 |
+
assign HEX0_DP = 1'b1;
|
| 111 |
+
assign HEX0_DP = 1'b1;
|
| 112 |
+
assign HEX0_DP = 1'b1;
|
| 113 |
+
|
| 114 |
+
sm_hex_display digit_3 ( h7segment [15:12] , HEX3_D [6:0] );
|
| 115 |
+
sm_hex_display digit_2 ( h7segment [11: 8] , HEX2_D [6:0] );
|
| 116 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1_D [6:0] );
|
| 117 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0_D [6:0] );
|
| 118 |
+
|
| 119 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de0_cv/de0_cv.sdc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
create_clock -period 20 [get_ports CLOCK_50]
|
| 2 |
+
create_clock -period 20 [get_ports CLOCK2_50]
|
| 3 |
+
create_clock -period 20 [get_ports CLOCK3_50]
|
| 4 |
+
create_clock -period 20 [get_ports CLOCK4_50]
|
| 5 |
+
|
| 6 |
+
derive_clock_uncertainty
|
| 7 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLOCK_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 8 |
+
|
| 9 |
+
set_false_path -from * -to [get_ports {LEDR[*]}]
|
| 10 |
+
set_false_path -from * -to [get_ports {HEX0[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {HEX1[*]}]
|
| 12 |
+
set_false_path -from * -to [get_ports {HEX2[*]}]
|
| 13 |
+
set_false_path -from * -to [get_ports {HEX3[*]}]
|
| 14 |
+
set_false_path -from * -to [get_ports {HEX4[*]}]
|
| 15 |
+
set_false_path -from * -to [get_ports {HEX5[*]}]
|
| 16 |
+
|
| 17 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 18 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
| 19 |
+
set_false_path -from [get_ports {RESET_N}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/de0_cv/de0_cv.v
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module de0_cv
|
| 3 |
+
(
|
| 4 |
+
input CLOCK2_50,
|
| 5 |
+
input CLOCK3_50,
|
| 6 |
+
inout CLOCK4_50,
|
| 7 |
+
input CLOCK_50,
|
| 8 |
+
|
| 9 |
+
input RESET_N,
|
| 10 |
+
|
| 11 |
+
input [ 3:0] KEY,
|
| 12 |
+
input [ 9:0] SW,
|
| 13 |
+
|
| 14 |
+
output [ 9:0] LEDR,
|
| 15 |
+
|
| 16 |
+
output [ 6:0] HEX0,
|
| 17 |
+
output [ 6:0] HEX1,
|
| 18 |
+
output [ 6:0] HEX2,
|
| 19 |
+
output [ 6:0] HEX3,
|
| 20 |
+
output [ 6:0] HEX4,
|
| 21 |
+
output [ 6:0] HEX5,
|
| 22 |
+
|
| 23 |
+
output [12:0] DRAM_ADDR,
|
| 24 |
+
output [ 1:0] DRAM_BA,
|
| 25 |
+
output DRAM_CAS_N,
|
| 26 |
+
output DRAM_CKE,
|
| 27 |
+
output DRAM_CLK,
|
| 28 |
+
output DRAM_CS_N,
|
| 29 |
+
inout [15:0] DRAM_DQ,
|
| 30 |
+
output DRAM_LDQM,
|
| 31 |
+
output DRAM_RAS_N,
|
| 32 |
+
output DRAM_UDQM,
|
| 33 |
+
output DRAM_WE_N,
|
| 34 |
+
|
| 35 |
+
output [ 3:0] VGA_B,
|
| 36 |
+
output [ 3:0] VGA_G,
|
| 37 |
+
output VGA_HS,
|
| 38 |
+
output [ 3:0] VGA_R,
|
| 39 |
+
output VGA_VS,
|
| 40 |
+
|
| 41 |
+
inout PS2_CLK,
|
| 42 |
+
inout PS2_CLK2,
|
| 43 |
+
inout PS2_DAT,
|
| 44 |
+
inout PS2_DAT2,
|
| 45 |
+
|
| 46 |
+
output SD_CLK,
|
| 47 |
+
inout SD_CMD,
|
| 48 |
+
inout [ 3:0] SD_DATA,
|
| 49 |
+
|
| 50 |
+
inout [35:0] GPIO_0,
|
| 51 |
+
inout [35:0] GPIO_1
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
// wires & inputs
|
| 55 |
+
wire clk;
|
| 56 |
+
wire clkIn = CLOCK_50;
|
| 57 |
+
wire rst_n = KEY[0] & RESET_N;
|
| 58 |
+
wire clkEnable = SW [9] | ~KEY[1];
|
| 59 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 60 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 61 |
+
wire [ 31:0 ] regData;
|
| 62 |
+
|
| 63 |
+
//cores
|
| 64 |
+
sm_top sm_top
|
| 65 |
+
(
|
| 66 |
+
.clkIn ( clkIn ),
|
| 67 |
+
.rst_n ( rst_n ),
|
| 68 |
+
.clkDevide ( clkDevide ),
|
| 69 |
+
.clkEnable ( clkEnable ),
|
| 70 |
+
.clk ( clk ),
|
| 71 |
+
.regAddr ( regAddr ),
|
| 72 |
+
.regData ( regData )
|
| 73 |
+
);
|
| 74 |
+
|
| 75 |
+
//outputs
|
| 76 |
+
assign LEDR[0] = clk;
|
| 77 |
+
assign LEDR[9:1] = regData[8:0];
|
| 78 |
+
|
| 79 |
+
wire [ 31:0 ] h7segment = regData;
|
| 80 |
+
|
| 81 |
+
sm_hex_display digit_5 ( h7segment [23:20] , HEX5 [6:0] );
|
| 82 |
+
sm_hex_display digit_4 ( h7segment [19:16] , HEX4 [6:0] );
|
| 83 |
+
sm_hex_display digit_3 ( h7segment [15:12] , HEX3 [6:0] );
|
| 84 |
+
sm_hex_display digit_2 ( h7segment [11: 8] , HEX2 [6:0] );
|
| 85 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1 [6:0] );
|
| 86 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0 [6:0] );
|
| 87 |
+
|
| 88 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de0_nano/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Terasic DE0-Nano (Altera Cyclone IV)
|
| 2 |
+
|
| 3 |
+
Thanks to [@dbkudryavtsevEduHSE](https://github.com/dbkudryavtsevEduHSE) for this port.
|
| 4 |
+
|
| 5 |
+
## Used pins
|
| 6 |
+
|
| 7 |
+
Pin | Name | Description
|
| 8 |
+
--- | ---- | -----------
|
| 9 |
+
pin_r8 | FPGA_CLK1_50 | system clock
|
| 10 |
+
pin_j15 | KEY0 | system reset
|
| 11 |
+
pin_e1 | KEY1 | clock enable
|
| 12 |
+
pin_a15, a13, b13, a11, s1, f3, b1, l3 | LED0-LED7 | system output
|
| 13 |
+
pin_m1, t8, b9, m15|SW0-SW3|
|
| 14 |
+
|
| 15 |
+
## Board photo
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
|
| 19 |
+
## Board pinout
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+

|
MIPSfpga_schoolMIPS/board/de0_nano/de0_nano.sdc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.0 MHz" [get_ports FPGA_CLK1_50]
|
| 3 |
+
|
| 4 |
+
# for enhancing USB BlasterII to be reliable, 25MHz
|
| 5 |
+
create_clock -name {altera_reserved_tck} -period 40 {altera_reserved_tck}
|
| 6 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tdi]
|
| 7 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tms]
|
| 8 |
+
set_output_delay -clock altera_reserved_tck 3 [get_ports altera_reserved_tdo]
|
| 9 |
+
|
| 10 |
+
derive_pll_clocks
|
| 11 |
+
|
| 12 |
+
derive_clock_uncertainty
|
| 13 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {FPGA_CLK1_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 14 |
+
|
| 15 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 16 |
+
|
| 17 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 18 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
| 19 |
+
|
MIPSfpga_schoolMIPS/board/de0_nano/de0_nano.v
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module de0_nano
|
| 3 |
+
(
|
| 4 |
+
input FPGA_CLK1_50,
|
| 5 |
+
input [ 1:0] KEY,
|
| 6 |
+
output [ 7:0] LED,
|
| 7 |
+
input [ 3:0] SW
|
| 8 |
+
);
|
| 9 |
+
|
| 10 |
+
// wires & inputs
|
| 11 |
+
wire clk;
|
| 12 |
+
wire clkIn = FPGA_CLK1_50;
|
| 13 |
+
wire rst_n = KEY[0];
|
| 14 |
+
wire clkEnable = ~KEY[1];
|
| 15 |
+
wire [ 3:0 ] clkDevide = 4'b1000;
|
| 16 |
+
wire [ 4:0 ] regAddr = { 1'b0, SW [3:0] };
|
| 17 |
+
wire [ 31:0 ] regData;
|
| 18 |
+
|
| 19 |
+
//cores
|
| 20 |
+
sm_top sm_top
|
| 21 |
+
(
|
| 22 |
+
.clkIn ( clkIn ),
|
| 23 |
+
.rst_n ( rst_n ),
|
| 24 |
+
.clkDevide ( clkDevide ),
|
| 25 |
+
.clkEnable ( clkEnable ),
|
| 26 |
+
.clk ( clk ),
|
| 27 |
+
.regAddr ( regAddr ),
|
| 28 |
+
.regData ( regData )
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
//outputs
|
| 32 |
+
assign LED[0] = clk;
|
| 33 |
+
assign LED[7:1] = regData[6:0];
|
| 34 |
+
|
| 35 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de10_lite/de10_lite.sdc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "10.0 MHz" [get_ports ADC_CLK_10]
|
| 3 |
+
create_clock -period "50.0 MHz" [get_ports MAX10_CLK1_50]
|
| 4 |
+
create_clock -period "50.0 MHz" [get_ports MAX10_CLK2_50]
|
| 5 |
+
|
| 6 |
+
derive_clock_uncertainty
|
| 7 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {MAX10_CLK1_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 8 |
+
|
| 9 |
+
set_false_path -from * -to [get_ports {LEDR[*]}]
|
| 10 |
+
set_false_path -from * -to [get_ports {HEX0[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {HEX1[*]}]
|
| 12 |
+
set_false_path -from * -to [get_ports {HEX2[*]}]
|
| 13 |
+
set_false_path -from * -to [get_ports {HEX3[*]}]
|
| 14 |
+
set_false_path -from * -to [get_ports {HEX4[*]}]
|
| 15 |
+
set_false_path -from * -to [get_ports {HEX5[*]}]
|
| 16 |
+
|
| 17 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 18 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/de10_lite/de10_lite.v
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
module de10_lite(
|
| 4 |
+
|
| 5 |
+
input ADC_CLK_10,
|
| 6 |
+
input MAX10_CLK1_50,
|
| 7 |
+
input MAX10_CLK2_50,
|
| 8 |
+
|
| 9 |
+
output [ 7:0 ] HEX0,
|
| 10 |
+
output [ 7:0 ] HEX1,
|
| 11 |
+
output [ 7:0 ] HEX2,
|
| 12 |
+
output [ 7:0 ] HEX3,
|
| 13 |
+
output [ 7:0 ] HEX4,
|
| 14 |
+
output [ 7:0 ] HEX5,
|
| 15 |
+
|
| 16 |
+
input [ 1:0 ] KEY,
|
| 17 |
+
|
| 18 |
+
output [ 9:0 ] LEDR,
|
| 19 |
+
|
| 20 |
+
input [ 9:0 ] SW,
|
| 21 |
+
|
| 22 |
+
inout [ 35:0 ] GPIO
|
| 23 |
+
);
|
| 24 |
+
|
| 25 |
+
// wires & inputs
|
| 26 |
+
wire clk;
|
| 27 |
+
wire clkIn = MAX10_CLK1_50;
|
| 28 |
+
wire rst_n = KEY[0];
|
| 29 |
+
wire clkEnable = SW [9] | ~KEY[1];
|
| 30 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 31 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 32 |
+
wire [ 31:0 ] regData;
|
| 33 |
+
|
| 34 |
+
//cores
|
| 35 |
+
sm_top sm_top
|
| 36 |
+
(
|
| 37 |
+
.clkIn ( clkIn ),
|
| 38 |
+
.rst_n ( rst_n ),
|
| 39 |
+
.clkDevide ( clkDevide ),
|
| 40 |
+
.clkEnable ( clkEnable ),
|
| 41 |
+
.clk ( clk ),
|
| 42 |
+
.regAddr ( regAddr ),
|
| 43 |
+
.regData ( regData )
|
| 44 |
+
);
|
| 45 |
+
|
| 46 |
+
//outputs
|
| 47 |
+
assign LEDR[0] = clk;
|
| 48 |
+
assign LEDR[9:1] = regData[8:0];
|
| 49 |
+
|
| 50 |
+
wire [ 31:0 ] h7segment = regData;
|
| 51 |
+
|
| 52 |
+
assign HEX0 [7] = 1'b1;
|
| 53 |
+
assign HEX1 [7] = 1'b1;
|
| 54 |
+
assign HEX2 [7] = 1'b1;
|
| 55 |
+
assign HEX3 [7] = 1'b1;
|
| 56 |
+
assign HEX4 [7] = 1'b1;
|
| 57 |
+
assign HEX5 [7] = 1'b1;
|
| 58 |
+
|
| 59 |
+
sm_hex_display digit_5 ( h7segment [23:20] , HEX5 [6:0] );
|
| 60 |
+
sm_hex_display digit_4 ( h7segment [19:16] , HEX4 [6:0] );
|
| 61 |
+
sm_hex_display digit_3 ( h7segment [15:12] , HEX3 [6:0] );
|
| 62 |
+
sm_hex_display digit_2 ( h7segment [11: 8] , HEX2 [6:0] );
|
| 63 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1 [6:0] );
|
| 64 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0 [6:0] );
|
| 65 |
+
|
| 66 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de10_nano/de10_nano.sdc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.0 MHz" [get_ports FPGA_CLK1_50]
|
| 3 |
+
create_clock -period "50.0 MHz" [get_ports FPGA_CLK2_50]
|
| 4 |
+
create_clock -period "50.0 MHz" [get_ports FPGA_CLK3_50]
|
| 5 |
+
|
| 6 |
+
# for enhancing USB BlasterII to be reliable, 25MHz
|
| 7 |
+
create_clock -name {altera_reserved_tck} -period 40 {altera_reserved_tck}
|
| 8 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tdi]
|
| 9 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tms]
|
| 10 |
+
set_output_delay -clock altera_reserved_tck 3 [get_ports altera_reserved_tdo]
|
| 11 |
+
|
| 12 |
+
derive_pll_clocks
|
| 13 |
+
|
| 14 |
+
derive_clock_uncertainty
|
| 15 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {FPGA_CLK1_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 16 |
+
|
| 17 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 18 |
+
|
| 19 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 20 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
| 21 |
+
|
MIPSfpga_schoolMIPS/board/de10_nano/de10_nano.v
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module de10_nano
|
| 3 |
+
(
|
| 4 |
+
output ADC_CONVST,
|
| 5 |
+
output ADC_SCK,
|
| 6 |
+
output ADC_SDI,
|
| 7 |
+
input ADC_SDO,
|
| 8 |
+
|
| 9 |
+
inout [15:0] ARDUINO_IO,
|
| 10 |
+
inout ARDUINO_RESET_N,
|
| 11 |
+
|
| 12 |
+
input FPGA_CLK1_50,
|
| 13 |
+
input FPGA_CLK2_50,
|
| 14 |
+
input FPGA_CLK3_50,
|
| 15 |
+
|
| 16 |
+
inout HDMI_I2C_SCL,
|
| 17 |
+
inout HDMI_I2C_SDA,
|
| 18 |
+
inout HDMI_I2S,
|
| 19 |
+
inout HDMI_LRCLK,
|
| 20 |
+
inout HDMI_MCLK,
|
| 21 |
+
inout HDMI_SCLK,
|
| 22 |
+
output HDMI_TX_CLK,
|
| 23 |
+
output HDMI_TX_DE,
|
| 24 |
+
output [23:0] HDMI_TX_D,
|
| 25 |
+
output HDMI_TX_HS,
|
| 26 |
+
input HDMI_TX_INT,
|
| 27 |
+
output HDMI_TX_VS,
|
| 28 |
+
|
| 29 |
+
input [ 1:0] KEY,
|
| 30 |
+
output [ 7:0] LED,
|
| 31 |
+
input [ 3:0] SW,
|
| 32 |
+
|
| 33 |
+
inout [35:0] GPIO_0,
|
| 34 |
+
inout [35:0] GPIO_1
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
// wires & inputs
|
| 38 |
+
wire clk;
|
| 39 |
+
wire clkIn = FPGA_CLK1_50;
|
| 40 |
+
wire rst_n = KEY[0];
|
| 41 |
+
wire clkEnable = ~KEY[1];
|
| 42 |
+
wire [ 3:0 ] clkDevide = 4'b1000;
|
| 43 |
+
wire [ 4:0 ] regAddr = { 1'b0, SW [3:0] };
|
| 44 |
+
wire [ 31:0 ] regData;
|
| 45 |
+
|
| 46 |
+
//cores
|
| 47 |
+
sm_top sm_top
|
| 48 |
+
(
|
| 49 |
+
.clkIn ( clkIn ),
|
| 50 |
+
.rst_n ( rst_n ),
|
| 51 |
+
.clkDevide ( clkDevide ),
|
| 52 |
+
.clkEnable ( clkEnable ),
|
| 53 |
+
.clk ( clk ),
|
| 54 |
+
.regAddr ( regAddr ),
|
| 55 |
+
.regData ( regData )
|
| 56 |
+
);
|
| 57 |
+
|
| 58 |
+
//outputs
|
| 59 |
+
assign LED[0] = clk;
|
| 60 |
+
assign LED[7:1] = regData[6:0];
|
| 61 |
+
|
| 62 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de10_standard/de10_standard.sdc
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.000000 MHz" [get_ports CLOCK2_50]
|
| 3 |
+
create_clock -period "50.000000 MHz" [get_ports CLOCK3_50]
|
| 4 |
+
create_clock -period "50.000000 MHz" [get_ports CLOCK4_50]
|
| 5 |
+
create_clock -period "50.000000 MHz" [get_ports CLOCK_50]
|
| 6 |
+
|
| 7 |
+
# for enhancing USB BlasterII to be reliable, 25MHz
|
| 8 |
+
create_clock -name {altera_reserved_tck} -period 40 {altera_reserved_tck}
|
| 9 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tdi]
|
| 10 |
+
set_input_delay -clock altera_reserved_tck -clock_fall 3 [get_ports altera_reserved_tms]
|
| 11 |
+
set_output_delay -clock altera_reserved_tck 3 [get_ports altera_reserved_tdo]
|
| 12 |
+
|
| 13 |
+
derive_clock_uncertainty
|
| 14 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLOCK_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 15 |
+
|
| 16 |
+
set_false_path -from * -to [get_ports {LEDR[*]}]
|
| 17 |
+
set_false_path -from * -to [get_ports {HEX0[*]}]
|
| 18 |
+
set_false_path -from * -to [get_ports {HEX1[*]}]
|
| 19 |
+
set_false_path -from * -to [get_ports {HEX2[*]}]
|
| 20 |
+
set_false_path -from * -to [get_ports {HEX3[*]}]
|
| 21 |
+
set_false_path -from * -to [get_ports {HEX4[*]}]
|
| 22 |
+
set_false_path -from * -to [get_ports {HEX5[*]}]
|
| 23 |
+
|
| 24 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 25 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
| 26 |
+
|
| 27 |
+
|
MIPSfpga_schoolMIPS/board/de10_standard/de10_standard.v
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
module de10_standard
|
| 4 |
+
(
|
| 5 |
+
input CLOCK2_50,
|
| 6 |
+
input CLOCK3_50,
|
| 7 |
+
input CLOCK4_50,
|
| 8 |
+
input CLOCK_50,
|
| 9 |
+
|
| 10 |
+
input [3:0] KEY,
|
| 11 |
+
|
| 12 |
+
input [9:0] SW,
|
| 13 |
+
|
| 14 |
+
output [9:0] LEDR,
|
| 15 |
+
|
| 16 |
+
output [6:0] HEX0,
|
| 17 |
+
output [6:0] HEX1,
|
| 18 |
+
output [6:0] HEX2,
|
| 19 |
+
output [6:0] HEX3,
|
| 20 |
+
output [6:0] HEX4,
|
| 21 |
+
output [6:0] HEX5
|
| 22 |
+
);
|
| 23 |
+
|
| 24 |
+
// wires & inputs
|
| 25 |
+
wire clk;
|
| 26 |
+
wire clkIn = CLOCK_50;
|
| 27 |
+
wire rst_n = KEY[0];
|
| 28 |
+
wire clkEnable = SW [9] | ~KEY[1];
|
| 29 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 30 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 31 |
+
wire [ 31:0 ] regData;
|
| 32 |
+
|
| 33 |
+
//cores
|
| 34 |
+
sm_top sm_top
|
| 35 |
+
(
|
| 36 |
+
.clkIn ( clkIn ),
|
| 37 |
+
.rst_n ( rst_n ),
|
| 38 |
+
.clkDevide ( clkDevide ),
|
| 39 |
+
.clkEnable ( clkEnable ),
|
| 40 |
+
.clk ( clk ),
|
| 41 |
+
.regAddr ( regAddr ),
|
| 42 |
+
.regData ( regData )
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
//outputs
|
| 46 |
+
assign LEDR[0] = clk;
|
| 47 |
+
assign LEDR[9:1] = regData[8:0];
|
| 48 |
+
|
| 49 |
+
wire [ 31:0 ] h7segment = regData;
|
| 50 |
+
|
| 51 |
+
sm_hex_display digit_5 ( h7segment [23:20] , HEX5 [6:0] );
|
| 52 |
+
sm_hex_display digit_4 ( h7segment [19:16] , HEX4 [6:0] );
|
| 53 |
+
sm_hex_display digit_3 ( h7segment [15:12] , HEX3 [6:0] );
|
| 54 |
+
sm_hex_display digit_2 ( h7segment [11: 8] , HEX2 [6:0] );
|
| 55 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1 [6:0] );
|
| 56 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0 [6:0] );
|
| 57 |
+
|
| 58 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de1_soc/de1_soc.sdc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.0 MHz" [get_ports CLOCK_50]
|
| 3 |
+
|
| 4 |
+
derive_clock_uncertainty
|
| 5 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLOCK_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 6 |
+
|
| 7 |
+
set_false_path -from * -to [get_ports {LEDR[*]}]
|
| 8 |
+
set_false_path -from * -to [get_ports {HEX0[*]}]
|
| 9 |
+
set_false_path -from * -to [get_ports {HEX1[*]}]
|
| 10 |
+
set_false_path -from * -to [get_ports {HEX2[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {HEX3[*]}]
|
| 12 |
+
set_false_path -from * -to [get_ports {HEX4[*]}]
|
| 13 |
+
set_false_path -from * -to [get_ports {HEX5[*]}]
|
| 14 |
+
|
| 15 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 16 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/de1_soc/de1_soc.v
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
//`define ENABLE_ADC
|
| 3 |
+
//`define ENABLE_AUD
|
| 4 |
+
//`define ENABLE_CLOCK2
|
| 5 |
+
//`define ENABLE_CLOCK3
|
| 6 |
+
//`define ENABLE_CLOCK4
|
| 7 |
+
`define ENABLE_CLOCK
|
| 8 |
+
//`define ENABLE_DRAM
|
| 9 |
+
//`define ENABLE_FAN
|
| 10 |
+
`define ENABLE_FPGA
|
| 11 |
+
`define ENABLE_GPIO
|
| 12 |
+
`define ENABLE_HEX
|
| 13 |
+
//`define ENABLE_HPS
|
| 14 |
+
//`define ENABLE_IRDA
|
| 15 |
+
`define ENABLE_KEY
|
| 16 |
+
`define ENABLE_LEDR
|
| 17 |
+
//`define ENABLE_PS2
|
| 18 |
+
//`define ENABLE_TD
|
| 19 |
+
//`define ENABLE_VGA
|
| 20 |
+
`define ENABLE_SW
|
| 21 |
+
|
| 22 |
+
module de1_soc(
|
| 23 |
+
|
| 24 |
+
`ifdef ENABLE_ADC
|
| 25 |
+
output ADC_CONVST,
|
| 26 |
+
output ADC_DIN,
|
| 27 |
+
input ADC_DOUT,
|
| 28 |
+
output ADC_SCLK,
|
| 29 |
+
`endif
|
| 30 |
+
|
| 31 |
+
`ifdef ENABLE_AUD
|
| 32 |
+
input AUD_ADCDAT,
|
| 33 |
+
inout AUD_ADCLRCK,
|
| 34 |
+
inout AUD_BCLK,
|
| 35 |
+
output AUD_DACDAT,
|
| 36 |
+
inout AUD_DACLRCK,
|
| 37 |
+
output AUD_XCK,
|
| 38 |
+
`endif
|
| 39 |
+
|
| 40 |
+
`ifdef ENABLE_CLOCK2
|
| 41 |
+
input CLOCK2_50,
|
| 42 |
+
`endif
|
| 43 |
+
|
| 44 |
+
`ifdef ENABLE_CLOCK3
|
| 45 |
+
input CLOCK3_50,
|
| 46 |
+
`endif
|
| 47 |
+
|
| 48 |
+
`ifdef ENABLE_CLOCK4
|
| 49 |
+
input CLOCK4_50,
|
| 50 |
+
`endif
|
| 51 |
+
|
| 52 |
+
`ifdef ENABLE_CLOCK
|
| 53 |
+
input CLOCK_50,
|
| 54 |
+
`endif
|
| 55 |
+
|
| 56 |
+
`ifdef ENABLE_DRAM
|
| 57 |
+
output [12:0] DRAM_ADDR,
|
| 58 |
+
output [1:0] DRAM_BA,
|
| 59 |
+
output DRAM_CAS_N,
|
| 60 |
+
output DRAM_CKE,
|
| 61 |
+
output DRAM_CLK,
|
| 62 |
+
output DRAM_CS_N,
|
| 63 |
+
inout [15:0] DRAM_DQ,
|
| 64 |
+
output DRAM_LDQM,
|
| 65 |
+
output DRAM_RAS_N,
|
| 66 |
+
output DRAM_UDQM,
|
| 67 |
+
output DRAM_WE_N,
|
| 68 |
+
`endif
|
| 69 |
+
|
| 70 |
+
`ifdef ENABLE_FAN
|
| 71 |
+
output FAN_CTRL,
|
| 72 |
+
`endif
|
| 73 |
+
|
| 74 |
+
`ifdef ENABLE_FPGA
|
| 75 |
+
output FPGA_I2C_SCLK,
|
| 76 |
+
inout FPGA_I2C_SDAT,
|
| 77 |
+
`endif
|
| 78 |
+
|
| 79 |
+
`ifdef ENABLE_GPIO
|
| 80 |
+
inout [35:0] GPIO_0,
|
| 81 |
+
inout [35:0] GPIO_1,
|
| 82 |
+
`endif
|
| 83 |
+
|
| 84 |
+
`ifdef ENABLE_HEX
|
| 85 |
+
output [6:0] HEX0,
|
| 86 |
+
output [6:0] HEX1,
|
| 87 |
+
output [6:0] HEX2,
|
| 88 |
+
output [6:0] HEX3,
|
| 89 |
+
output [6:0] HEX4,
|
| 90 |
+
output [6:0] HEX5,
|
| 91 |
+
`endif
|
| 92 |
+
|
| 93 |
+
`ifdef ENABLE_HPS
|
| 94 |
+
inout HPS_CONV_USB_N,
|
| 95 |
+
output [14:0] HPS_DDR3_ADDR,
|
| 96 |
+
output [2:0] HPS_DDR3_BA,
|
| 97 |
+
output HPS_DDR3_CAS_N,
|
| 98 |
+
output HPS_DDR3_CKE,
|
| 99 |
+
output HPS_DDR3_CK_N,
|
| 100 |
+
output HPS_DDR3_CK_P,
|
| 101 |
+
output HPS_DDR3_CS_N,
|
| 102 |
+
output [3:0] HPS_DDR3_DM,
|
| 103 |
+
inout [31:0] HPS_DDR3_DQ,
|
| 104 |
+
inout [3:0] HPS_DDR3_DQS_N,
|
| 105 |
+
inout [3:0] HPS_DDR3_DQS_P,
|
| 106 |
+
output HPS_DDR3_ODT,
|
| 107 |
+
output HPS_DDR3_RAS_N,
|
| 108 |
+
output HPS_DDR3_RESET_N,
|
| 109 |
+
input HPS_DDR3_RZQ,
|
| 110 |
+
output HPS_DDR3_WE_N,
|
| 111 |
+
output HPS_ENET_GTX_CLK,
|
| 112 |
+
inout HPS_ENET_INT_N,
|
| 113 |
+
output HPS_ENET_MDC,
|
| 114 |
+
inout HPS_ENET_MDIO,
|
| 115 |
+
input HPS_ENET_RX_CLK,
|
| 116 |
+
input [3:0] HPS_ENET_RX_DATA,
|
| 117 |
+
input HPS_ENET_RX_DV,
|
| 118 |
+
output [3:0] HPS_ENET_TX_DATA,
|
| 119 |
+
output HPS_ENET_TX_EN,
|
| 120 |
+
inout [3:0] HPS_FLASH_DATA,
|
| 121 |
+
output HPS_FLASH_DCLK,
|
| 122 |
+
output HPS_FLASH_NCSO,
|
| 123 |
+
inout HPS_GSENSOR_INT,
|
| 124 |
+
inout HPS_I2C1_SCLK,
|
| 125 |
+
inout HPS_I2C1_SDAT,
|
| 126 |
+
inout HPS_I2C2_SCLK,
|
| 127 |
+
inout HPS_I2C2_SDAT,
|
| 128 |
+
inout HPS_I2C_CONTROL,
|
| 129 |
+
inout HPS_KEY,
|
| 130 |
+
inout HPS_LED,
|
| 131 |
+
inout HPS_LTC_GPIO,
|
| 132 |
+
output HPS_SD_CLK,
|
| 133 |
+
inout HPS_SD_CMD,
|
| 134 |
+
inout [3:0] HPS_SD_DATA,
|
| 135 |
+
output HPS_SPIM_CLK,
|
| 136 |
+
input HPS_SPIM_MISO,
|
| 137 |
+
output HPS_SPIM_MOSI,
|
| 138 |
+
inout HPS_SPIM_SS,
|
| 139 |
+
input HPS_UART_RX,
|
| 140 |
+
output HPS_UART_TX,
|
| 141 |
+
input HPS_USB_CLKOUT,
|
| 142 |
+
inout [7:0] HPS_USB_DATA,
|
| 143 |
+
input HPS_USB_DIR,
|
| 144 |
+
input HPS_USB_NXT,
|
| 145 |
+
output HPS_USB_STP,
|
| 146 |
+
`endif
|
| 147 |
+
|
| 148 |
+
`ifdef ENABLE_IRDA
|
| 149 |
+
input IRDA_RXD,
|
| 150 |
+
output IRDA_TXD,
|
| 151 |
+
`endif
|
| 152 |
+
|
| 153 |
+
`ifdef ENABLE_KEY
|
| 154 |
+
input [3:0] KEY,
|
| 155 |
+
`endif
|
| 156 |
+
|
| 157 |
+
`ifdef ENABLE_LEDR
|
| 158 |
+
output [9:0] LEDR,
|
| 159 |
+
`endif
|
| 160 |
+
|
| 161 |
+
`ifdef ENABLE_PS2
|
| 162 |
+
inout PS2_CLK,
|
| 163 |
+
inout PS2_CLK2,
|
| 164 |
+
inout PS2_DAT,
|
| 165 |
+
inout PS2_DAT2,
|
| 166 |
+
`endif
|
| 167 |
+
|
| 168 |
+
`ifdef ENABLE_TD
|
| 169 |
+
input TD_CLK27,
|
| 170 |
+
input [7:0] TD_DATA,
|
| 171 |
+
input TD_HS,
|
| 172 |
+
output TD_RESET_N,
|
| 173 |
+
input TD_VS,
|
| 174 |
+
`endif
|
| 175 |
+
|
| 176 |
+
`ifdef ENABLE_VGA
|
| 177 |
+
output [7:0] VGA_B,
|
| 178 |
+
output VGA_BLANK_N,
|
| 179 |
+
output VGA_CLK,
|
| 180 |
+
output [7:0] VGA_G,
|
| 181 |
+
output VGA_HS,
|
| 182 |
+
output [7:0] VGA_R,
|
| 183 |
+
output VGA_SYNC_N,
|
| 184 |
+
output VGA_VS,
|
| 185 |
+
`endif
|
| 186 |
+
|
| 187 |
+
`ifdef ENABLE_SW
|
| 188 |
+
input [9:0] SW
|
| 189 |
+
`endif
|
| 190 |
+
);
|
| 191 |
+
|
| 192 |
+
// wires & inputs
|
| 193 |
+
wire clk;
|
| 194 |
+
wire clkIn = CLOCK_50;
|
| 195 |
+
wire rst_n = KEY[0];
|
| 196 |
+
wire clkEnable = SW [9] | ~KEY[1];
|
| 197 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 198 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 199 |
+
wire [ 31:0 ] regData;
|
| 200 |
+
|
| 201 |
+
//cores
|
| 202 |
+
sm_top sm_top
|
| 203 |
+
(
|
| 204 |
+
.clkIn ( clkIn ),
|
| 205 |
+
.rst_n ( rst_n ),
|
| 206 |
+
.clkDevide ( clkDevide ),
|
| 207 |
+
.clkEnable ( clkEnable ),
|
| 208 |
+
.clk ( clk ),
|
| 209 |
+
.regAddr ( regAddr ),
|
| 210 |
+
.regData ( regData )
|
| 211 |
+
);
|
| 212 |
+
|
| 213 |
+
//outputs
|
| 214 |
+
assign LEDR[0] = clk;
|
| 215 |
+
assign LEDR[9:1] = regData[8:0];
|
| 216 |
+
|
| 217 |
+
wire [ 31:0 ] h7segment = regData;
|
| 218 |
+
|
| 219 |
+
sm_hex_display digit_5 ( h7segment [23:20] , HEX5 [6:0] );
|
| 220 |
+
sm_hex_display digit_4 ( h7segment [19:16] , HEX4 [6:0] );
|
| 221 |
+
sm_hex_display digit_3 ( h7segment [15:12] , HEX3 [6:0] );
|
| 222 |
+
sm_hex_display digit_2 ( h7segment [11: 8] , HEX2 [6:0] );
|
| 223 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1 [6:0] );
|
| 224 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0 [6:0] );
|
| 225 |
+
|
| 226 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/de4_230/DE4_230.sdc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period 20 [get_ports OSC_50_BANK2]
|
| 3 |
+
create_clock -period 20 [get_ports OSC_50_BANK3]
|
| 4 |
+
create_clock -period 20 [get_ports OSC_50_BANK4]
|
| 5 |
+
create_clock -period 20 [get_ports OSC_50_BANK5]
|
| 6 |
+
create_clock -period 20 [get_ports OSC_50_BANK6]
|
| 7 |
+
create_clock -period 20 [get_ports OSC_50_BANK7]
|
| 8 |
+
|
| 9 |
+
derive_pll_clocks
|
| 10 |
+
|
| 11 |
+
derive_clock_uncertainty
|
| 12 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {OSC_50_BANK2}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 13 |
+
|
| 14 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 15 |
+
set_false_path -from * -to [get_ports {SEG0_D[*]}]
|
| 16 |
+
set_false_path -from * -to [get_ports {SEG1_D[*]}]
|
| 17 |
+
set_false_path -from * -to [get_ports {SEG0_DP}]
|
| 18 |
+
set_false_path -from * -to [get_ports {SEG1_DP}]
|
| 19 |
+
set_false_path -from * -to [get_ports {HEX4[*]}]
|
| 20 |
+
set_false_path -from * -to [get_ports {HEX5[*]}]
|
| 21 |
+
|
| 22 |
+
set_false_path -from [get_ports {SLIDE_SW[*]}] -to [all_clocks]
|
| 23 |
+
set_false_path -from [get_ports {BUTTON[*]}] -to [all_clocks]
|
| 24 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
| 25 |
+
set_false_path -from [get_ports {CPU_RESET_n}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/de4_230/de4_230.v
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module de4_230
|
| 3 |
+
(
|
| 4 |
+
input GCLKIN,
|
| 5 |
+
output GCLKOUT_FPGA,
|
| 6 |
+
input OSC_50_BANK2,
|
| 7 |
+
input OSC_50_BANK3,
|
| 8 |
+
input OSC_50_BANK4,
|
| 9 |
+
input OSC_50_BANK5,
|
| 10 |
+
input OSC_50_BANK6,
|
| 11 |
+
input OSC_50_BANK7,
|
| 12 |
+
input PLL_CLKIN_p,
|
| 13 |
+
|
| 14 |
+
output [7:0] LED,
|
| 15 |
+
input [3:0] BUTTON,
|
| 16 |
+
input CPU_RESET_n, // CPU Reset Push Button
|
| 17 |
+
inout EXT_IO,
|
| 18 |
+
input [7:0] SW, // DIP Switches
|
| 19 |
+
input [3:0] SLIDE_SW, // Slide switches
|
| 20 |
+
output [6:0] SEG0_D,
|
| 21 |
+
output SEG0_DP,
|
| 22 |
+
output [6:0] SEG1_D,
|
| 23 |
+
output SEG1_DP
|
| 24 |
+
);
|
| 25 |
+
|
| 26 |
+
// wires & inputs
|
| 27 |
+
wire clk;
|
| 28 |
+
wire clkIn = OSC_50_BANK2;
|
| 29 |
+
wire rst_n = CPU_RESET_n;
|
| 30 |
+
wire clkEnable = SW [7] | ~BUTTON[0];
|
| 31 |
+
wire [ 3:0 ] clkDevide = SW [3:0];
|
| 32 |
+
wire [ 4:0 ] regAddr = { ~BUTTON[1], SLIDE_SW };
|
| 33 |
+
wire [ 31:0 ] regData;
|
| 34 |
+
|
| 35 |
+
//cores
|
| 36 |
+
sm_top sm_top
|
| 37 |
+
(
|
| 38 |
+
.clkIn ( clkIn ),
|
| 39 |
+
.rst_n ( rst_n ),
|
| 40 |
+
.clkDevide ( clkDevide ),
|
| 41 |
+
.clkEnable ( clkEnable ),
|
| 42 |
+
.clk ( clk ),
|
| 43 |
+
.regAddr ( regAddr ),
|
| 44 |
+
.regData ( regData )
|
| 45 |
+
);
|
| 46 |
+
|
| 47 |
+
//outputs
|
| 48 |
+
assign LED[0] = clk;
|
| 49 |
+
assign LED[7:1] = regData[6:0];
|
| 50 |
+
|
| 51 |
+
wire [ 31:0 ] h7segment = regData;
|
| 52 |
+
|
| 53 |
+
assign SEG0_DP = 1'b1;
|
| 54 |
+
assign SEG1_DP = 1'b1;
|
| 55 |
+
|
| 56 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , SEG1_D );
|
| 57 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , SEG0_D );
|
| 58 |
+
|
| 59 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/marsohod_3/help.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
0-й светодиод отсчитывает такты работы процессора
|
| 2 |
+
1 - 7 светодиод: вывод малдших 7 бит регистра $v0
|
| 3 |
+
нопка разрешени¤ работы процессора: KEY1.
|
| 4 |
+
нопка сброса процессора: KEY0.
|
MIPSfpga_schoolMIPS/board/marsohod_3/marsohod_3.sdc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "100.0 MHz" [get_ports CLK100MHZ]
|
| 3 |
+
|
| 4 |
+
derive_clock_uncertainty
|
| 5 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLK100MHZ}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 6 |
+
|
| 7 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 8 |
+
|
| 9 |
+
set_false_path -from [get_ports {KEY0}] -to [all_clocks]
|
| 10 |
+
set_false_path -from [get_ports {KEY1}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/marsohod_3/marsohod_3.v
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module marsohod_3(
|
| 3 |
+
input CLK100MHZ,
|
| 4 |
+
input KEY0,
|
| 5 |
+
input KEY1,
|
| 6 |
+
output [7:0] LED
|
| 7 |
+
|
| 8 |
+
);
|
| 9 |
+
|
| 10 |
+
// wires & inputs
|
| 11 |
+
wire clk;
|
| 12 |
+
wire clkIn = CLK100MHZ;
|
| 13 |
+
wire rst_n = KEY0;
|
| 14 |
+
wire clkEnable = ~KEY1;
|
| 15 |
+
wire [ 31:0 ] regData;
|
| 16 |
+
|
| 17 |
+
//cores
|
| 18 |
+
sm_top sm_top
|
| 19 |
+
(
|
| 20 |
+
.clkIn ( clkIn ),
|
| 21 |
+
.rst_n ( rst_n ),
|
| 22 |
+
.clkDevide ( 4'b1000 ),
|
| 23 |
+
.clkEnable ( clkEnable ),
|
| 24 |
+
.clk ( clk ),
|
| 25 |
+
.regAddr ( 4'b0010 ),
|
| 26 |
+
.regData ( regData )
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
//outputs
|
| 30 |
+
assign LED[0] = clk;
|
| 31 |
+
assign LED[7:1] = regData[6:0];
|
| 32 |
+
|
| 33 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/marsohod_3b/help.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
0-й светодиод отсчитывает такты работы процессора
|
| 2 |
+
1 - 7 светодиод: вывод младших 7 бит регистра $v0
|
| 3 |
+
Кнопка разрешения работы процессора: KEY1.
|
| 4 |
+
Кнопка сброса процессора: KEY0.
|
MIPSfpga_schoolMIPS/board/marsohod_3b/marsohod_3b.sdc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "100.0 MHz" [get_ports CLK100MHZ]
|
| 3 |
+
|
| 4 |
+
derive_clock_uncertainty
|
| 5 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLK100MHZ}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 6 |
+
|
| 7 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 8 |
+
|
| 9 |
+
set_false_path -from [get_ports {KEY0}] -to [all_clocks]
|
| 10 |
+
set_false_path -from [get_ports {KEY1}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/marsohod_3b/marsohod_3b.v
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module marsohod_3b(
|
| 3 |
+
input CLK100MHZ,
|
| 4 |
+
input KEY0,
|
| 5 |
+
input KEY1,
|
| 6 |
+
output [7:0] LED
|
| 7 |
+
|
| 8 |
+
);
|
| 9 |
+
|
| 10 |
+
// wires & inputs
|
| 11 |
+
wire clk;
|
| 12 |
+
wire clkIn = CLK100MHZ;
|
| 13 |
+
wire rst_n = KEY0;
|
| 14 |
+
wire clkEnable = ~KEY1;
|
| 15 |
+
wire [ 31:0 ] regData;
|
| 16 |
+
|
| 17 |
+
//cores
|
| 18 |
+
sm_top sm_top
|
| 19 |
+
(
|
| 20 |
+
.clkIn ( clkIn ),
|
| 21 |
+
.rst_n ( rst_n ),
|
| 22 |
+
.clkDevide ( 4'b1000 ),
|
| 23 |
+
.clkEnable ( clkEnable ),
|
| 24 |
+
.clk ( clk ),
|
| 25 |
+
.regAddr ( 4'b0010 ),
|
| 26 |
+
.regData ( regData )
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
//outputs
|
| 30 |
+
assign LED[0] = clk;
|
| 31 |
+
assign LED[7:1] = regData[6:0];
|
| 32 |
+
|
| 33 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/max_10_evkit/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MAX 10 FPGA Evaluation Kit
|
| 2 |
+
## Описание платы
|
| 3 |
+
Max 10 FPGA Evaluation Kit отладочная плата компании Intel начального уровня. В плате используется микросхема 10M08SAE144C8G серии MAX 10.
|
| 4 |
+
|
| 5 |
+

|
| 6 |
+
|
| 7 |
+
Плата включает следующие компоненты:
|
| 8 |
+
|
| 9 |
+
- Микросхема серии MAX10 FPGA
|
| 10 |
+
- Intel Enpirion® EP5388QI DC-DC понижающий преобразователь
|
| 11 |
+
- JTAG разъем для программирования платы
|
| 12 |
+
- Тактовый генератор на 50МГц
|
| 13 |
+
- АЦП встроенный в микросхему MAX 10
|
| 14 |
+
- Переключатели, кнопки, перемычки и сигнальные светодиоды
|
| 15 |
+
- Пробная точка для измерения питания микросхемы
|
| 16 |
+
- Разъемы формата Arduino UNO для подключения переферии
|
| 17 |
+
- Отверстия GPIO для подключения переферии
|
| 18 |
+
- Mini-USB разъем для питания платы
|
| 19 |
+

|
| 20 |
+
|
| 21 |
+
Для программирования платы используется внешний программатор, подключаемый через JTAG разъем.
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
|
| 25 |
+
## Ссылки
|
| 26 |
+
1. [Страница с описание платы MAX 10 FPGA Evaluation Kit на сайте Intel](https://www.intel.com/content/www/us/en/programmable/products/boards_and_kits/dev-kits/altera/kit-max-10-evaluation.html#Contents)
|
| 27 |
+
2. [Руководство пользователя платы MAX 10 FPGA Evaluation Kit](https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_max10_eval_10m80.pdf)
|
| 28 |
+
|
MIPSfpga_schoolMIPS/board/max_10_evkit/max_10_evkit.v
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module max_10_evkit(
|
| 2 |
+
input CLK,
|
| 3 |
+
input SW3_1,
|
| 4 |
+
input SW3_2,
|
| 5 |
+
output [4:0] LED
|
| 6 |
+
|
| 7 |
+
);
|
| 8 |
+
|
| 9 |
+
// wires & inputs
|
| 10 |
+
wire clk;
|
| 11 |
+
wire clkIn = CLK;
|
| 12 |
+
wire rst_n = SW3_1;
|
| 13 |
+
wire clkEnable = ~SW3_2;
|
| 14 |
+
wire [ 31:0 ] regData;
|
| 15 |
+
|
| 16 |
+
//cores
|
| 17 |
+
sm_top sm_top
|
| 18 |
+
(
|
| 19 |
+
.clkIn ( clkIn ),
|
| 20 |
+
.rst_n ( rst_n ),
|
| 21 |
+
.clkDevide ( 4'b1010 ),
|
| 22 |
+
.clkEnable ( clkEnable ),
|
| 23 |
+
.clk ( clk ),
|
| 24 |
+
.regAddr ( 4'b0010 ),
|
| 25 |
+
.regData ( regData )
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
//outputs
|
| 29 |
+
assign LED[0] = clk;
|
| 30 |
+
assign LED[4:1] = ~{regData[0], regData[1], regData[2], regData[3]};
|
| 31 |
+
|
| 32 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/max_10_neek/max_10_neek.sdc
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
create_clock -period "50.0 MHz" [get_ports MAX10_CLK1_50]
|
| 3 |
+
create_clock -period "50.0 MHz" [get_ports MAX10_CLK2_50]
|
| 4 |
+
create_clock -period "50.0 MHz" [get_ports MAX10_CLK3_50]
|
| 5 |
+
|
| 6 |
+
derive_clock_uncertainty
|
| 7 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {MAX10_CLK1_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 8 |
+
|
| 9 |
+
set_false_path -from * -to [get_ports {LEDR[*]}]
|
| 10 |
+
set_false_path -from * -to [get_ports {HEX0[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {HEX1[*]}]
|
| 12 |
+
|
| 13 |
+
set_false_path -from [get_ports {KEY[*]}] -to [all_clocks]
|
| 14 |
+
set_false_path -from [get_ports {SW[*]}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/max_10_neek/max_10_neek.v
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
`define ENABLE_ADC
|
| 3 |
+
`define ENABLE_AUDIO
|
| 4 |
+
`define ENABLE_CAMERA
|
| 5 |
+
`define ENABLE_DAC
|
| 6 |
+
// `define ENABLE_DDR3
|
| 7 |
+
`define ENABLE_FLASH
|
| 8 |
+
`define ENABLE_GPIO
|
| 9 |
+
`define ENABLE_GSENSOR
|
| 10 |
+
`define ENABLE_HDMI
|
| 11 |
+
`define ENABLE_HEX0
|
| 12 |
+
`define ENABLE_HEX1
|
| 13 |
+
`define ENABLE_KEY
|
| 14 |
+
`define ENABLE_LEDR
|
| 15 |
+
`define ENABLE_LSENSOR
|
| 16 |
+
`define ENABLE_MAX10
|
| 17 |
+
`define ENABLE_MIPI
|
| 18 |
+
`define ENABLE_MTL2
|
| 19 |
+
`define ENABLE_NET
|
| 20 |
+
`define ENABLE_PM
|
| 21 |
+
`define ENABLE_PS2
|
| 22 |
+
`define ENABLE_RH
|
| 23 |
+
`define ENABLE_SD
|
| 24 |
+
`define ENABLE_SW
|
| 25 |
+
`define ENABLE_UART
|
| 26 |
+
|
| 27 |
+
module golden_top(
|
| 28 |
+
|
| 29 |
+
`ifdef ENABLE_ADC
|
| 30 |
+
///////// ADC 3.3 V /////////
|
| 31 |
+
input ADC_CLK_10,
|
| 32 |
+
`endif
|
| 33 |
+
|
| 34 |
+
`ifdef ENABLE_AUDIO
|
| 35 |
+
///////// AUDIO 2.5 V /////////
|
| 36 |
+
inout AUDIO_BCLK,
|
| 37 |
+
output AUDIO_DIN_MFP1,
|
| 38 |
+
input AUDIO_DOUT_MFP2,
|
| 39 |
+
inout AUDIO_GPIO_MFP5,
|
| 40 |
+
output AUDIO_MCLK,
|
| 41 |
+
input AUDIO_MISO_MFP4,
|
| 42 |
+
inout AUDIO_RESET_n,
|
| 43 |
+
output AUDIO_SCLK_MFP3,
|
| 44 |
+
output AUDIO_SCL_SS_n,
|
| 45 |
+
inout AUDIO_SDA_MOSI,
|
| 46 |
+
output AUDIO_SPI_SELECT,
|
| 47 |
+
inout AUDIO_WCLK,
|
| 48 |
+
`endif
|
| 49 |
+
|
| 50 |
+
`ifdef ENABLE_CAMERA
|
| 51 |
+
// 2.5 V
|
| 52 |
+
output CAMERA_I2C_SCL,
|
| 53 |
+
inout CAMERA_I2C_SDA,
|
| 54 |
+
// 3.3 V LVTTL
|
| 55 |
+
output CAMERA_PWDN_n,
|
| 56 |
+
`endif
|
| 57 |
+
|
| 58 |
+
`ifdef ENABLE_DAC
|
| 59 |
+
///////// DAC 3.3 V LVTTL /////////
|
| 60 |
+
inout DAC_DATA,
|
| 61 |
+
output DAC_SCLK,
|
| 62 |
+
output DAC_SYNC_n,
|
| 63 |
+
`endif
|
| 64 |
+
|
| 65 |
+
`ifdef ENABLE_DDR3
|
| 66 |
+
// "SSTL-15 CLASS I"
|
| 67 |
+
output [14:0] DDR3_A,
|
| 68 |
+
output [2:0] DDR3_BA,
|
| 69 |
+
output DDR3_CKE,
|
| 70 |
+
output DDR3_CAS_n,
|
| 71 |
+
output DDR3_CS_n,
|
| 72 |
+
output [2:0] DDR3_DM,
|
| 73 |
+
inout [23:0] DDR3_DQ,
|
| 74 |
+
output DDR3_ODT,
|
| 75 |
+
output DDR3_RAS_n,
|
| 76 |
+
output DDR3_RESET_n,
|
| 77 |
+
output DDR3_WE_n,
|
| 78 |
+
// "DIFFERENTIAL 1.5-V SSTL CLASS I"
|
| 79 |
+
inout DDR3_CK_n,
|
| 80 |
+
inout DDR3_CK_p,
|
| 81 |
+
inout [2:0] DDR3_DQS_n,
|
| 82 |
+
inout [2:0] DDR3_DQS_p,
|
| 83 |
+
`endif
|
| 84 |
+
|
| 85 |
+
`ifdef ENABLE_FLASH
|
| 86 |
+
// "3.3-V LVTTL"
|
| 87 |
+
inout [3:0] FLASH_DATA,
|
| 88 |
+
output FLASH_DCLK,
|
| 89 |
+
output FLASH_NCSO,
|
| 90 |
+
output FLASH_RESET_n,
|
| 91 |
+
`endif
|
| 92 |
+
|
| 93 |
+
`ifdef ENABLE_GPIO
|
| 94 |
+
// "3.3-V LVTTL"
|
| 95 |
+
inout [7:0] GPIO,
|
| 96 |
+
`endif
|
| 97 |
+
|
| 98 |
+
`ifdef ENABLE_GSENSOR
|
| 99 |
+
// 2.5 V
|
| 100 |
+
output GSENSOR_CS_n,
|
| 101 |
+
input [2:1] GSENSOR_INT,
|
| 102 |
+
inout GSENSOR_SCLK,
|
| 103 |
+
inout GSENSOR_SDI,
|
| 104 |
+
inout GSENSOR_SDO,
|
| 105 |
+
`endif
|
| 106 |
+
|
| 107 |
+
`ifdef ENABLE_HDMI
|
| 108 |
+
// "3.3-V LVTTL"
|
| 109 |
+
input HDMI_AP,
|
| 110 |
+
inout HDMI_I2C_SCL,
|
| 111 |
+
inout HDMI_I2C_SDA,
|
| 112 |
+
inout HDMI_LRCLK,
|
| 113 |
+
inout HDMI_MCLK,
|
| 114 |
+
input HDMI_RX_CLK,
|
| 115 |
+
input [23:0] HDMI_RX_D,
|
| 116 |
+
input HDMI_RX_DE,
|
| 117 |
+
inout HDMI_RX_HS,
|
| 118 |
+
input HDMI_RX_INT1,
|
| 119 |
+
inout HDMI_RX_RESET_n,
|
| 120 |
+
input HDMI_RX_VS,
|
| 121 |
+
inout HDMI_SCLK,
|
| 122 |
+
`endif
|
| 123 |
+
|
| 124 |
+
`ifdef ENABLE_HEX0
|
| 125 |
+
// "3.3-V LVTTL"
|
| 126 |
+
output [6:0] HEX0,
|
| 127 |
+
`endif
|
| 128 |
+
|
| 129 |
+
`ifdef ENABLE_HEX1
|
| 130 |
+
// "3.3-V LVTTL"
|
| 131 |
+
output [6:0] HEX1,
|
| 132 |
+
`endif
|
| 133 |
+
|
| 134 |
+
`ifdef ENABLE_KEY
|
| 135 |
+
// "1.5 V SCHMITT TRIGGER"
|
| 136 |
+
input [4:0] KEY,
|
| 137 |
+
`endif
|
| 138 |
+
|
| 139 |
+
`ifdef ENABLE_LEDR
|
| 140 |
+
// "3.3-V LVTTL"
|
| 141 |
+
output [9:0] LEDR,
|
| 142 |
+
`endif
|
| 143 |
+
|
| 144 |
+
`ifdef ENABLE_LSENSOR
|
| 145 |
+
// "3.3-V LVTTL"
|
| 146 |
+
inout LSENSOR_INT,
|
| 147 |
+
output LSENSOR_SCL,
|
| 148 |
+
inout LSENSOR_SDA,
|
| 149 |
+
`endif
|
| 150 |
+
|
| 151 |
+
`ifdef ENABLE_MAX10
|
| 152 |
+
// "3.3-V LVTTL"
|
| 153 |
+
input MAX10_CLK1_50,
|
| 154 |
+
input MAX10_CLK2_50,
|
| 155 |
+
input MAX10_CLK3_50,
|
| 156 |
+
`endif
|
| 157 |
+
|
| 158 |
+
`ifdef ENABLE_MIPI
|
| 159 |
+
// "3.3-V LVTTL"
|
| 160 |
+
output MIPI_CS_n,
|
| 161 |
+
output MIPI_I2C_SCL,
|
| 162 |
+
inout MIPI_I2C_SDA,
|
| 163 |
+
input MIPI_PIXEL_CLK,
|
| 164 |
+
input [23:0] MIPI_PIXEL_D,
|
| 165 |
+
input MIPI_PIXEL_HS,
|
| 166 |
+
input MIPI_PIXEL_VS,
|
| 167 |
+
output MIPI_REFCLK,
|
| 168 |
+
output MIPI_RESET_n,
|
| 169 |
+
`endif
|
| 170 |
+
|
| 171 |
+
`ifdef ENABLE_MTL2
|
| 172 |
+
// "3.3-V LVTTL"
|
| 173 |
+
output [7:0] MTL2_B,
|
| 174 |
+
inout MTL2_BL_ON_n,
|
| 175 |
+
output MTL2_DCLK,
|
| 176 |
+
output [7:0] MTL2_G,
|
| 177 |
+
output MTL2_HSD,
|
| 178 |
+
output MTL2_I2C_SCL,
|
| 179 |
+
inout MTL2_I2C_SDA,
|
| 180 |
+
input MTL2_INT,
|
| 181 |
+
output [7:0] MTL2_R,
|
| 182 |
+
output MTL2_VSD,
|
| 183 |
+
`endif
|
| 184 |
+
|
| 185 |
+
`ifdef ENABLE_NET
|
| 186 |
+
// 2.5 V
|
| 187 |
+
output NET_GTX_CLK,
|
| 188 |
+
input NET_INT_n,
|
| 189 |
+
input NET_LINK100,
|
| 190 |
+
output NET_MDC,
|
| 191 |
+
inout NET_MDIO,
|
| 192 |
+
output NET_RST_N,
|
| 193 |
+
input NET_RX_CLK,
|
| 194 |
+
input NET_RX_COL,
|
| 195 |
+
input NET_RX_CRS,
|
| 196 |
+
input [3:0] NET_RX_D,
|
| 197 |
+
input NET_RX_DV,
|
| 198 |
+
input NET_RX_ER,
|
| 199 |
+
input NET_TX_CLK,
|
| 200 |
+
output [3:0] NET_TX_D,
|
| 201 |
+
output NET_TX_EN,
|
| 202 |
+
output NET_TX_ER,
|
| 203 |
+
`endif
|
| 204 |
+
|
| 205 |
+
`ifdef ENABLE_PM
|
| 206 |
+
// "3.3-V LVTTL"
|
| 207 |
+
output PM_I2C_SCL,
|
| 208 |
+
inout PM_I2C_SDA,
|
| 209 |
+
`endif
|
| 210 |
+
|
| 211 |
+
`ifdef ENABLE_PS2
|
| 212 |
+
// "3.3-V LVTTL"
|
| 213 |
+
inout PS2_CLK,
|
| 214 |
+
inout PS2_CLK2,
|
| 215 |
+
inout PS2_DAT,
|
| 216 |
+
inout PS2_DAT2,
|
| 217 |
+
`endif
|
| 218 |
+
|
| 219 |
+
`ifdef ENABLE_RH
|
| 220 |
+
// "3.3-V LVTTL"
|
| 221 |
+
input RH_TEMP_DRDY_n,
|
| 222 |
+
output RH_TEMP_I2C_SCL,
|
| 223 |
+
inout RH_TEMP_I2C_SDA,
|
| 224 |
+
`endif
|
| 225 |
+
|
| 226 |
+
`ifdef ENABLE_SD
|
| 227 |
+
// 2.5 V
|
| 228 |
+
output SD_CLK,
|
| 229 |
+
inout SD_CMD,
|
| 230 |
+
inout [3:0] SD_DATA,
|
| 231 |
+
`endif
|
| 232 |
+
|
| 233 |
+
`ifdef ENABLE_SW
|
| 234 |
+
// 1.5 V
|
| 235 |
+
input [9:0] SW,
|
| 236 |
+
`endif
|
| 237 |
+
|
| 238 |
+
`ifdef ENABLE_UART
|
| 239 |
+
// 2.5 V
|
| 240 |
+
output UART_RESET_n,
|
| 241 |
+
input UART_RX,
|
| 242 |
+
output UART_TX,
|
| 243 |
+
`endif
|
| 244 |
+
|
| 245 |
+
///////// FPGA /////////
|
| 246 |
+
input FPGA_RESET_n
|
| 247 |
+
|
| 248 |
+
);
|
| 249 |
+
|
| 250 |
+
// wires & inputs
|
| 251 |
+
wire clk;
|
| 252 |
+
wire clkIn = MAX10_CLK1_50;
|
| 253 |
+
wire rst_n = KEY[0];
|
| 254 |
+
wire clkEnable = SW [9] | ~KEY[1];
|
| 255 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 256 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 257 |
+
wire [ 31:0 ] regData;
|
| 258 |
+
|
| 259 |
+
//cores
|
| 260 |
+
sm_top sm_top
|
| 261 |
+
(
|
| 262 |
+
.clkIn ( clkIn ),
|
| 263 |
+
.rst_n ( rst_n ),
|
| 264 |
+
.clkDevide ( clkDevide ),
|
| 265 |
+
.clkEnable ( clkEnable ),
|
| 266 |
+
.clk ( clk ),
|
| 267 |
+
.regAddr ( regAddr ),
|
| 268 |
+
.regData ( regData )
|
| 269 |
+
);
|
| 270 |
+
|
| 271 |
+
//outputs
|
| 272 |
+
assign LEDR[0] = clk;
|
| 273 |
+
assign LEDR[9:1] = regData[8:0];
|
| 274 |
+
|
| 275 |
+
wire [ 31:0 ] h7segment = regData;
|
| 276 |
+
|
| 277 |
+
sm_hex_display digit_1 ( h7segment [ 7: 4] , HEX1 [6:0] );
|
| 278 |
+
sm_hex_display digit_0 ( h7segment [ 3: 0] , HEX0 [6:0] );
|
| 279 |
+
|
| 280 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/nexys4/nexys4.v
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module nexys4
|
| 3 |
+
(
|
| 4 |
+
input clk,
|
| 5 |
+
input btnCpuReset,
|
| 6 |
+
|
| 7 |
+
input btnC,
|
| 8 |
+
input btnU,
|
| 9 |
+
input btnL,
|
| 10 |
+
input btnR,
|
| 11 |
+
input btnD,
|
| 12 |
+
|
| 13 |
+
input [15:0] sw,
|
| 14 |
+
|
| 15 |
+
output [15:0] led,
|
| 16 |
+
|
| 17 |
+
output RGB1_Red,
|
| 18 |
+
output RGB1_Green,
|
| 19 |
+
output RGB1_Blue,
|
| 20 |
+
output RGB2_Red,
|
| 21 |
+
output RGB2_Green,
|
| 22 |
+
output RGB2_Blue,
|
| 23 |
+
|
| 24 |
+
output [ 6:0] seg,
|
| 25 |
+
output dp,
|
| 26 |
+
output [ 7:0] an,
|
| 27 |
+
|
| 28 |
+
inout [ 7:0] JA,
|
| 29 |
+
inout [ 7:0] JB,
|
| 30 |
+
|
| 31 |
+
input RsRx
|
| 32 |
+
);
|
| 33 |
+
// wires & inputs
|
| 34 |
+
wire clkCpu;
|
| 35 |
+
wire clkIn = clk;
|
| 36 |
+
wire rst_n = btnCpuReset;
|
| 37 |
+
wire clkEnable = sw [9] | btnU;
|
| 38 |
+
wire [ 3:0 ] clkDevide = sw [8:5];
|
| 39 |
+
wire [ 4:0 ] regAddr = sw [4:0];
|
| 40 |
+
wire [ 31:0 ] regData;
|
| 41 |
+
|
| 42 |
+
//cores
|
| 43 |
+
sm_top sm_top
|
| 44 |
+
(
|
| 45 |
+
.clkIn ( clkIn ),
|
| 46 |
+
.rst_n ( rst_n ),
|
| 47 |
+
.clkDevide ( clkDevide ),
|
| 48 |
+
.clkEnable ( clkEnable ),
|
| 49 |
+
.clk ( clkCpu ),
|
| 50 |
+
.regAddr ( regAddr ),
|
| 51 |
+
.regData ( regData )
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
//outputs
|
| 55 |
+
assign led[0] = clkCpu;
|
| 56 |
+
assign led[15:1] = regData[14:0];
|
| 57 |
+
|
| 58 |
+
//hex out
|
| 59 |
+
wire [ 31:0 ] h7segment = regData;
|
| 60 |
+
wire clkHex;
|
| 61 |
+
|
| 62 |
+
sm_clk_divider hex_clk_divider
|
| 63 |
+
(
|
| 64 |
+
.clkIn ( clkIn ),
|
| 65 |
+
.rst_n ( rst_n ),
|
| 66 |
+
.devide ( 4'b1 ),
|
| 67 |
+
.enable ( 1'b1 ),
|
| 68 |
+
.clkOut ( clkHex )
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
sm_hex_display_8 sm_hex_display_8
|
| 72 |
+
(
|
| 73 |
+
.clock ( clkHex ),
|
| 74 |
+
.resetn ( rst_n ),
|
| 75 |
+
.number ( h7segment ),
|
| 76 |
+
|
| 77 |
+
.seven_segments ( seg ),
|
| 78 |
+
.dot ( dp ),
|
| 79 |
+
.anodes ( an )
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
assign RGB1_Red = 1'b0;
|
| 83 |
+
assign RGB1_Green = 1'b0;
|
| 84 |
+
assign RGB1_Blue = 1'b0;
|
| 85 |
+
assign RGB2_Red = 1'b0;
|
| 86 |
+
assign RGB2_Green = 1'b0;
|
| 87 |
+
assign RGB2_Blue = 1'b0;
|
| 88 |
+
|
| 89 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/nexys4_ddr/nexys4_ddr.v
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module nexys4_ddr
|
| 3 |
+
(
|
| 4 |
+
input CLK100MHZ,
|
| 5 |
+
input CPU_RESETN,
|
| 6 |
+
|
| 7 |
+
input BTNC,
|
| 8 |
+
input BTNU,
|
| 9 |
+
input BTNL,
|
| 10 |
+
input BTNR,
|
| 11 |
+
input BTND,
|
| 12 |
+
|
| 13 |
+
input [15:0] SW,
|
| 14 |
+
|
| 15 |
+
output [15:0] LED,
|
| 16 |
+
|
| 17 |
+
output LED16_B,
|
| 18 |
+
output LED16_G,
|
| 19 |
+
output LED16_R,
|
| 20 |
+
output LED17_B,
|
| 21 |
+
output LED17_G,
|
| 22 |
+
output LED17_R,
|
| 23 |
+
|
| 24 |
+
output CA,
|
| 25 |
+
output CB,
|
| 26 |
+
output CC,
|
| 27 |
+
output CD,
|
| 28 |
+
output CE,
|
| 29 |
+
output CF,
|
| 30 |
+
output CG,
|
| 31 |
+
output DP,
|
| 32 |
+
|
| 33 |
+
output [ 7:0] AN,
|
| 34 |
+
|
| 35 |
+
inout [12:1] JA,
|
| 36 |
+
inout [12:1] JB,
|
| 37 |
+
|
| 38 |
+
input UART_TXD_IN
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
// wires & inputs
|
| 42 |
+
wire clk;
|
| 43 |
+
wire clkIn = CLK100MHZ;
|
| 44 |
+
wire rst_n = CPU_RESETN;
|
| 45 |
+
wire clkEnable = SW [9] | BTNU;
|
| 46 |
+
wire [ 3:0 ] clkDevide = SW [8:5];
|
| 47 |
+
wire [ 4:0 ] regAddr = SW [4:0];
|
| 48 |
+
wire [ 31:0 ] regData;
|
| 49 |
+
|
| 50 |
+
//cores
|
| 51 |
+
sm_top sm_top
|
| 52 |
+
(
|
| 53 |
+
.clkIn ( clkIn ),
|
| 54 |
+
.rst_n ( rst_n ),
|
| 55 |
+
.clkDevide ( clkDevide ),
|
| 56 |
+
.clkEnable ( clkEnable ),
|
| 57 |
+
.clk ( clk ),
|
| 58 |
+
.regAddr ( regAddr ),
|
| 59 |
+
.regData ( regData )
|
| 60 |
+
);
|
| 61 |
+
|
| 62 |
+
//outputs
|
| 63 |
+
assign LED[0] = clk;
|
| 64 |
+
assign LED[15:1] = regData[14:0];
|
| 65 |
+
|
| 66 |
+
//hex out
|
| 67 |
+
wire [ 31:0 ] h7segment = regData;
|
| 68 |
+
wire clkHex;
|
| 69 |
+
|
| 70 |
+
sm_clk_divider hex_clk_divider
|
| 71 |
+
(
|
| 72 |
+
.clkIn ( clkIn ),
|
| 73 |
+
.rst_n ( rst_n ),
|
| 74 |
+
.devide ( 4'b1 ),
|
| 75 |
+
.enable ( 1'b1 ),
|
| 76 |
+
.clkOut ( clkHex )
|
| 77 |
+
);
|
| 78 |
+
|
| 79 |
+
sm_hex_display_8 sm_hex_display_8
|
| 80 |
+
(
|
| 81 |
+
.clock ( clkHex ),
|
| 82 |
+
.resetn ( rst_n ),
|
| 83 |
+
.number ( h7segment ),
|
| 84 |
+
|
| 85 |
+
.seven_segments ( { CG, CF, CE, CD, CC, CB, CA } ),
|
| 86 |
+
.dot ( DP ),
|
| 87 |
+
.anodes ( AN )
|
| 88 |
+
);
|
| 89 |
+
|
| 90 |
+
assign LED16_B = 1'b0;
|
| 91 |
+
assign LED16_G = 1'b0;
|
| 92 |
+
assign LED16_R = 1'b0;
|
| 93 |
+
assign LED17_B = 1'b0;
|
| 94 |
+
assign LED17_G = 1'b0;
|
| 95 |
+
assign LED17_R = 1'b0;
|
| 96 |
+
|
| 97 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RZ-EasyFPGA A2.1 (Altera Cyclone IV)
|
| 2 |
+
|
| 3 |
+
Thanks to [@woodywitch](https://github.com/woodywitch) and [@Dluzhnevsky](https://github.com/Dluzhnevsky) for this port.
|
| 4 |
+
|
| 5 |
+
## Used pins
|
| 6 |
+
|
| 7 |
+
Pin | Name | Description
|
| 8 |
+
--- | ---- | -----------
|
| 9 |
+
pin_23 | CLK100MHZ | system clock
|
| 10 |
+
pin_25 | KEY0 | system reset
|
| 11 |
+
pin_88 | KEY1 | clock enable
|
| 12 |
+
pin_87:84 | LED1-LED4 | system output
|
| 13 |
+
|
| 14 |
+
## Board photo
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
|
| 18 |
+
## Board pinout
|
| 19 |
+
|
| 20 |
+

|
MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/rz_easyFPGA_A21.sdc
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
create_clock -period "100.0 MHz" [get_ports CLK100MHZ]
|
| 4 |
+
|
| 5 |
+
derive_clock_uncertainty
|
| 6 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {CLK100MHZ}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 7 |
+
|
| 8 |
+
set_false_path -from * -to [get_ports {LED[*]}]
|
| 9 |
+
|
| 10 |
+
set_false_path -from [get_ports {KEY0}] -to [all_clocks]
|
| 11 |
+
set_false_path -from [get_ports {KEY1}] -to [all_clocks]
|
MIPSfpga_schoolMIPS/board/rz_easyFPGA_A2.1/rz_easyFPGA_A21.v
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module rz_easyFPGA_A21(
|
| 2 |
+
input CLK100MHZ,
|
| 3 |
+
input KEY0,
|
| 4 |
+
input KEY1,
|
| 5 |
+
output [3:0] LED
|
| 6 |
+
);
|
| 7 |
+
|
| 8 |
+
// wires & inputs
|
| 9 |
+
wire clk;
|
| 10 |
+
wire clkIn = CLK100MHZ;
|
| 11 |
+
wire rst_n = KEY0;
|
| 12 |
+
wire clkEnable = ~KEY1;
|
| 13 |
+
wire [ 31:0 ] regData;
|
| 14 |
+
|
| 15 |
+
//cores
|
| 16 |
+
sm_top sm_top
|
| 17 |
+
(
|
| 18 |
+
.clkIn ( clkIn ),
|
| 19 |
+
.rst_n ( rst_n ),
|
| 20 |
+
.clkDevide ( 4'b1000 ),
|
| 21 |
+
.clkEnable ( clkEnable ),
|
| 22 |
+
.clk ( clk ),
|
| 23 |
+
.regAddr ( 4'b0010 ),
|
| 24 |
+
.regData ( regData )
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
//outputs
|
| 28 |
+
assign LED[0] = clk;
|
| 29 |
+
assign LED[3:1] = regData[2:0];
|
| 30 |
+
|
| 31 |
+
endmodule
|
MIPSfpga_schoolMIPS/board/zeowaa/zeowaa.sdc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
create_clock -period "50.0 MHz" [get_ports clk_50]
|
| 2 |
+
|
| 3 |
+
derive_clock_uncertainty
|
| 4 |
+
create_generated_clock -name {clk} -divide_by 2 -source [get_ports {clk_50}] [get_registers {sm_top:sm_top|sm_clk_divider:sm_clk_divider|sm_register_we:r_cntr|q[*]}]
|
| 5 |
+
create_generated_clock -name {clk_hex} -divide_by 2 -source [get_ports {clk_50}] [get_registers {sm_clk_divider:hex_clk_divider|sm_register_we:r_cntr|q[16]}]
|
| 6 |
+
|
| 7 |
+
set_false_path -from [get_ports {key[*]}] -to [all_clocks]
|
| 8 |
+
set_false_path -from [get_ports {sw[*]}] -to [all_clocks]
|
| 9 |
+
|
| 10 |
+
set_false_path -from * -to [get_ports {led[*]}]
|
| 11 |
+
set_false_path -from * -to [get_ports {hex[*]}]
|
| 12 |
+
set_false_path -from * -to [get_ports {digit[*]}]
|
| 13 |
+
set_false_path -from * -to buzzer
|
MIPSfpga_schoolMIPS/board/zeowaa/zeowaa.v
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module zeowaa
|
| 3 |
+
(
|
| 4 |
+
input clk_50,
|
| 5 |
+
input [ 5:2] key,
|
| 6 |
+
input [ 7:0] sw,
|
| 7 |
+
output [11:0] led,
|
| 8 |
+
output [ 7:0] hex,
|
| 9 |
+
output [ 7:0] digit,
|
| 10 |
+
output buzzer
|
| 11 |
+
);
|
| 12 |
+
// wires & inputs
|
| 13 |
+
wire clkCpu;
|
| 14 |
+
wire clkIn = clk_50;
|
| 15 |
+
wire rst_n = key[4];
|
| 16 |
+
wire clkEnable = ~sw[ 7] | ~key[5];
|
| 17 |
+
wire [ 3:0 ] clkDevide = { ~sw[6:5], 2'b00 };
|
| 18 |
+
wire [ 4:0 ] regAddr = ~sw[4:0];
|
| 19 |
+
wire [ 31:0 ] regData;
|
| 20 |
+
|
| 21 |
+
//cores
|
| 22 |
+
sm_top sm_top
|
| 23 |
+
(
|
| 24 |
+
.clkIn ( clkIn ),
|
| 25 |
+
.rst_n ( rst_n ),
|
| 26 |
+
.clkDevide ( clkDevide ),
|
| 27 |
+
.clkEnable ( clkEnable ),
|
| 28 |
+
.clk ( clkCpu ),
|
| 29 |
+
.regAddr ( regAddr ),
|
| 30 |
+
.regData ( regData )
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
//outputs
|
| 34 |
+
assign led[0] = ~clkCpu;
|
| 35 |
+
assign led[11:1] = ~regData[11:0];
|
| 36 |
+
|
| 37 |
+
//hex out
|
| 38 |
+
wire [ 31:0 ] h7segment = regData;
|
| 39 |
+
wire clkHex;
|
| 40 |
+
|
| 41 |
+
sm_clk_divider hex_clk_divider
|
| 42 |
+
(
|
| 43 |
+
.clkIn ( clkIn ),
|
| 44 |
+
.rst_n ( rst_n ),
|
| 45 |
+
.devide ( 4'b0 ),
|
| 46 |
+
.enable ( 1'b1 ),
|
| 47 |
+
.clkOut ( clkHex )
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
sm_hex_display_8 sm_hex_display_8
|
| 51 |
+
(
|
| 52 |
+
.clock ( clkHex ),
|
| 53 |
+
.resetn ( rst_n ),
|
| 54 |
+
.number ( h7segment ),
|
| 55 |
+
.seven_segments ( hex[6:0] ),
|
| 56 |
+
.dot ( hex[7] ),
|
| 57 |
+
.anodes ( digit )
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
assign buzzer = 1'b1;
|
| 61 |
+
|
| 62 |
+
endmodule
|
MIPSfpga_schoolMIPS/doc/README.md
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
For docs and CPU diagrams please visit the project [wiki](https://github.com/MIPSfpga/schoolMIPS/wiki)
|
MIPSfpga_schoolMIPS/program/00_counter/modelsim_script.tcl
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
vlib work
|
| 3 |
+
|
| 4 |
+
set p0 -vlog01compat
|
| 5 |
+
set p1 +define+SIMULATION
|
| 6 |
+
|
| 7 |
+
set i0 +incdir+../../../src
|
| 8 |
+
set i1 +incdir+../../../testbench
|
| 9 |
+
|
| 10 |
+
set s0 ../../../src/*.v
|
| 11 |
+
set s1 ../../../testbench/*.v
|
| 12 |
+
|
| 13 |
+
vlog $p0 $p1 $i0 $i1 $s0 $s1
|
| 14 |
+
|
| 15 |
+
vsim work.sm_testbench
|
| 16 |
+
|
| 17 |
+
# add wave -radix hex sim:/sm_testbench/*
|
| 18 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/*
|
| 19 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/*
|
| 20 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/rf
|
| 21 |
+
|
| 22 |
+
run -all
|
| 23 |
+
|
| 24 |
+
wave zoom full
|
MIPSfpga_schoolMIPS/program/01_fibonacci/modelsim_script.tcl
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
vlib work
|
| 3 |
+
|
| 4 |
+
set p0 -vlog01compat
|
| 5 |
+
set p1 +define+SIMULATION
|
| 6 |
+
|
| 7 |
+
set i0 +incdir+../../../src
|
| 8 |
+
set i1 +incdir+../../../testbench
|
| 9 |
+
|
| 10 |
+
set s0 ../../../src/*.v
|
| 11 |
+
set s1 ../../../testbench/*.v
|
| 12 |
+
|
| 13 |
+
vlog $p0 $p1 $i0 $i1 $s0 $s1
|
| 14 |
+
|
| 15 |
+
vsim work.sm_testbench
|
| 16 |
+
|
| 17 |
+
# add wave -radix hex sim:/sm_testbench/*
|
| 18 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/*
|
| 19 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/*
|
| 20 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/rf
|
| 21 |
+
|
| 22 |
+
run -all
|
| 23 |
+
|
| 24 |
+
wave zoom full
|
MIPSfpga_schoolMIPS/program/02_sqrt/modelsim_script.tcl
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
vlib work
|
| 3 |
+
|
| 4 |
+
set p0 -vlog01compat
|
| 5 |
+
set p1 +define+SIMULATION
|
| 6 |
+
|
| 7 |
+
set i0 +incdir+../../../src
|
| 8 |
+
set i1 +incdir+../../../testbench
|
| 9 |
+
|
| 10 |
+
set s0 ../../../src/*.v
|
| 11 |
+
set s1 ../../../testbench/*.v
|
| 12 |
+
|
| 13 |
+
vlog $p0 $p1 $i0 $i1 $s0 $s1
|
| 14 |
+
|
| 15 |
+
vsim work.sm_testbench
|
| 16 |
+
|
| 17 |
+
# add wave -radix hex sim:/sm_testbench/*
|
| 18 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/*
|
| 19 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/*
|
| 20 |
+
add wave -radix hex sim:/sm_testbench/sm_top/sm_cpu/rf/rf
|
| 21 |
+
add wave sim:/sm_testbench/cycle
|
| 22 |
+
|
| 23 |
+
run -all
|
| 24 |
+
|
| 25 |
+
wave zoom full
|
MIPSfpga_schoolMIPS/src/sm_cpu.v
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* schoolMIPS - small MIPS CPU for "Young Russian Chip Architects"
|
| 3 |
+
* summer school ( yrca@googlegroups.com )
|
| 4 |
+
*
|
| 5 |
+
* originally based on Sarah L. Harris MIPS CPU
|
| 6 |
+
*
|
| 7 |
+
* Copyright(c) 2017 Stanislav Zhelnio
|
| 8 |
+
* Aleksandr Romanov
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
`include "sm_cpu.vh"
|
| 12 |
+
|
| 13 |
+
module sm_cpu
|
| 14 |
+
(
|
| 15 |
+
input clk, // clock
|
| 16 |
+
input rst_n, // reset
|
| 17 |
+
input [ 4:0] regAddr, // debug access reg address
|
| 18 |
+
output [31:0] regData, // debug access reg data
|
| 19 |
+
output [31:0] imAddr, // instruction memory address
|
| 20 |
+
input [31:0] imData // instruction memory data
|
| 21 |
+
);
|
| 22 |
+
//control wires
|
| 23 |
+
wire pcSrc;
|
| 24 |
+
wire regDst;
|
| 25 |
+
wire regWrite;
|
| 26 |
+
wire aluSrc;
|
| 27 |
+
wire aluZero;
|
| 28 |
+
wire [ 2:0] aluControl;
|
| 29 |
+
|
| 30 |
+
//program counter
|
| 31 |
+
wire [31:0] pc;
|
| 32 |
+
wire [31:0] pcBranch;
|
| 33 |
+
wire [31:0] pcNext = pc + 1;
|
| 34 |
+
wire [31:0] pc_new = ~pcSrc ? pcNext : pcBranch;
|
| 35 |
+
sm_register r_pc(clk ,rst_n, pc_new, pc);
|
| 36 |
+
|
| 37 |
+
//program memory access
|
| 38 |
+
assign imAddr = pc;
|
| 39 |
+
wire [31:0] instr = imData;
|
| 40 |
+
|
| 41 |
+
//debug register access
|
| 42 |
+
wire [31:0] rd0;
|
| 43 |
+
assign regData = (regAddr != 0) ? rd0 : pc;
|
| 44 |
+
|
| 45 |
+
//register file
|
| 46 |
+
wire [ 4:0] a3 = regDst ? instr[15:11] : instr[20:16];
|
| 47 |
+
wire [31:0] rd1;
|
| 48 |
+
wire [31:0] rd2;
|
| 49 |
+
wire [31:0] wd3;
|
| 50 |
+
|
| 51 |
+
sm_register_file rf
|
| 52 |
+
(
|
| 53 |
+
.clk ( clk ),
|
| 54 |
+
.a0 ( regAddr ),
|
| 55 |
+
.a1 ( instr[25:21] ),
|
| 56 |
+
.a2 ( instr[20:16] ),
|
| 57 |
+
.a3 ( a3 ),
|
| 58 |
+
.rd0 ( rd0 ),
|
| 59 |
+
.rd1 ( rd1 ),
|
| 60 |
+
.rd2 ( rd2 ),
|
| 61 |
+
.wd3 ( wd3 ),
|
| 62 |
+
.we3 ( regWrite )
|
| 63 |
+
);
|
| 64 |
+
|
| 65 |
+
//sign extension
|
| 66 |
+
wire [31:0] signImm = { {16 { instr[15] }}, instr[15:0] };
|
| 67 |
+
assign pcBranch = pcNext + signImm;
|
| 68 |
+
|
| 69 |
+
//alu
|
| 70 |
+
wire [31:0] srcB = aluSrc ? signImm : rd2;
|
| 71 |
+
|
| 72 |
+
sm_alu alu
|
| 73 |
+
(
|
| 74 |
+
.srcA ( rd1 ),
|
| 75 |
+
.srcB ( srcB ),
|
| 76 |
+
.oper ( aluControl ),
|
| 77 |
+
.shift ( instr[10:6 ] ),
|
| 78 |
+
.zero ( aluZero ),
|
| 79 |
+
.result ( wd3 )
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
//control
|
| 83 |
+
sm_control sm_control
|
| 84 |
+
(
|
| 85 |
+
.cmdOper ( instr[31:26] ),
|
| 86 |
+
.cmdFunk ( instr[ 5:0 ] ),
|
| 87 |
+
.aluZero ( aluZero ),
|
| 88 |
+
.pcSrc ( pcSrc ),
|
| 89 |
+
.regDst ( regDst ),
|
| 90 |
+
.regWrite ( regWrite ),
|
| 91 |
+
.aluSrc ( aluSrc ),
|
| 92 |
+
.aluControl ( aluControl )
|
| 93 |
+
);
|
| 94 |
+
|
| 95 |
+
endmodule
|
| 96 |
+
|
| 97 |
+
module sm_control
|
| 98 |
+
(
|
| 99 |
+
input [5:0] cmdOper,
|
| 100 |
+
input [5:0] cmdFunk,
|
| 101 |
+
input aluZero,
|
| 102 |
+
output pcSrc,
|
| 103 |
+
output reg regDst,
|
| 104 |
+
output reg regWrite,
|
| 105 |
+
output reg aluSrc,
|
| 106 |
+
output reg [2:0] aluControl
|
| 107 |
+
);
|
| 108 |
+
reg branch;
|
| 109 |
+
reg condZero;
|
| 110 |
+
assign pcSrc = branch & (aluZero == condZero);
|
| 111 |
+
|
| 112 |
+
always @ (*) begin
|
| 113 |
+
branch = 1'b0;
|
| 114 |
+
condZero = 1'b0;
|
| 115 |
+
regDst = 1'b0;
|
| 116 |
+
regWrite = 1'b0;
|
| 117 |
+
aluSrc = 1'b0;
|
| 118 |
+
aluControl = `ALU_ADD;
|
| 119 |
+
|
| 120 |
+
casez( {cmdOper,cmdFunk} )
|
| 121 |
+
default : ;
|
| 122 |
+
|
| 123 |
+
{ `C_SPEC, `F_ADDU } : begin regDst = 1'b1; regWrite = 1'b1; aluControl = `ALU_ADD; end
|
| 124 |
+
{ `C_SPEC, `F_OR } : begin regDst = 1'b1; regWrite = 1'b1; aluControl = `ALU_OR; end
|
| 125 |
+
{ `C_SPEC, `F_SRL } : begin regDst = 1'b1; regWrite = 1'b1; aluControl = `ALU_SRL; end
|
| 126 |
+
{ `C_SPEC, `F_SLTU } : begin regDst = 1'b1; regWrite = 1'b1; aluControl = `ALU_SLTU; end
|
| 127 |
+
{ `C_SPEC, `F_SUBU } : begin regDst = 1'b1; regWrite = 1'b1; aluControl = `ALU_SUBU; end
|
| 128 |
+
|
| 129 |
+
{ `C_ADDIU, `F_ANY } : begin regWrite = 1'b1; aluSrc = 1'b1; aluControl = `ALU_ADD; end
|
| 130 |
+
{ `C_LUI, `F_ANY } : begin regWrite = 1'b1; aluSrc = 1'b1; aluControl = `ALU_LUI; end
|
| 131 |
+
|
| 132 |
+
{ `C_BEQ, `F_ANY } : begin branch = 1'b1; condZero = 1'b1; aluControl = `ALU_SUBU; end
|
| 133 |
+
{ `C_BNE, `F_ANY } : begin branch = 1'b1; aluControl = `ALU_SUBU; end
|
| 134 |
+
endcase
|
| 135 |
+
end
|
| 136 |
+
endmodule
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
module sm_alu
|
| 140 |
+
(
|
| 141 |
+
input [31:0] srcA,
|
| 142 |
+
input [31:0] srcB,
|
| 143 |
+
input [ 2:0] oper,
|
| 144 |
+
input [ 4:0] shift,
|
| 145 |
+
output zero,
|
| 146 |
+
output reg [31:0] result
|
| 147 |
+
);
|
| 148 |
+
always @ (*) begin
|
| 149 |
+
case (oper)
|
| 150 |
+
default : result = srcA + srcB;
|
| 151 |
+
`ALU_ADD : result = srcA + srcB;
|
| 152 |
+
`ALU_OR : result = srcA | srcB;
|
| 153 |
+
`ALU_LUI : result = (srcB << 16);
|
| 154 |
+
`ALU_SRL : result = srcB >> shift;
|
| 155 |
+
`ALU_SLTU : result = (srcA < srcB) ? 1 : 0;
|
| 156 |
+
`ALU_SUBU : result = srcA - srcB;
|
| 157 |
+
endcase
|
| 158 |
+
end
|
| 159 |
+
|
| 160 |
+
assign zero = (result == 0);
|
| 161 |
+
endmodule
|
| 162 |
+
|
| 163 |
+
module sm_register_file
|
| 164 |
+
(
|
| 165 |
+
input clk,
|
| 166 |
+
input [ 4:0] a0,
|
| 167 |
+
input [ 4:0] a1,
|
| 168 |
+
input [ 4:0] a2,
|
| 169 |
+
input [ 4:0] a3,
|
| 170 |
+
output [31:0] rd0,
|
| 171 |
+
output [31:0] rd1,
|
| 172 |
+
output [31:0] rd2,
|
| 173 |
+
input [31:0] wd3,
|
| 174 |
+
input we3
|
| 175 |
+
);
|
| 176 |
+
reg [31:0] rf [31:0];
|
| 177 |
+
|
| 178 |
+
assign rd0 = (a0 != 0) ? rf [a0] : 32'b0;
|
| 179 |
+
assign rd1 = (a1 != 0) ? rf [a1] : 32'b0;
|
| 180 |
+
assign rd2 = (a2 != 0) ? rf [a2] : 32'b0;
|
| 181 |
+
|
| 182 |
+
always @ (posedge clk)
|
| 183 |
+
if(we3) rf [a3] <= wd3;
|
| 184 |
+
endmodule
|
MIPSfpga_schoolMIPS/src/sm_cpu.vh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* schoolMIPS - small MIPS CPU for "Young Russian Chip Architects"
|
| 3 |
+
* summer school ( yrca@googlegroups.com )
|
| 4 |
+
*
|
| 5 |
+
* originally based on Sarah L. Harris MIPS CPU
|
| 6 |
+
*
|
| 7 |
+
* Copyright(c) 2017 Stanislav Zhelnio
|
| 8 |
+
* Aleksandr Romanov
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
//ALU commands
|
| 12 |
+
`define ALU_ADD 3'b000
|
| 13 |
+
`define ALU_OR 3'b001
|
| 14 |
+
`define ALU_LUI 3'b010
|
| 15 |
+
`define ALU_SRL 3'b011
|
| 16 |
+
`define ALU_SLTU 3'b100
|
| 17 |
+
`define ALU_SUBU 3'b101
|
| 18 |
+
|
| 19 |
+
//instruction operation code
|
| 20 |
+
`define C_SPEC 6'b000000 // Special instructions (depends on function field)
|
| 21 |
+
`define C_ADDIU 6'b001001 // I-type, Integer Add Immediate Unsigned
|
| 22 |
+
// Rd = Rs + Immed
|
| 23 |
+
`define C_BEQ 6'b000100 // I-type, Branch On Equal
|
| 24 |
+
// if (Rs == Rt) PC += (int)offset
|
| 25 |
+
`define C_LUI 6'b001111 // I-type, Load Upper Immediate
|
| 26 |
+
// Rt = Immed << 16
|
| 27 |
+
`define C_BNE 6'b000101 // I-type, Branch on Not Equal
|
| 28 |
+
// if (Rs != Rt) PC += (int)offset
|
| 29 |
+
|
| 30 |
+
//instruction function field
|
| 31 |
+
`define F_ADDU 6'b100001 // R-type, Integer Add Unsigned
|
| 32 |
+
// Rd = Rs + Rt
|
| 33 |
+
`define F_OR 6'b100101 // R-type, Logical OR
|
| 34 |
+
// Rd = Rs | Rt
|
| 35 |
+
`define F_SRL 6'b000010 // R-type, Shift Right Logical
|
| 36 |
+
// Rd = Rs∅ >> shift
|
| 37 |
+
`define F_SLTU 6'b101011 // R-type, Set on Less Than Unsigned
|
| 38 |
+
// Rd = (Rs∅ < Rt∅) ? 1 : 0
|
| 39 |
+
`define F_SUBU 6'b100011 // R-type, Unsigned Subtract
|
| 40 |
+
// Rd = Rs – Rt
|
| 41 |
+
`define F_ANY 6'b??????
|
MIPSfpga_schoolMIPS/src/sm_hex_display.v
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module sm_hex_display
|
| 3 |
+
(
|
| 4 |
+
input [3:0] digit,
|
| 5 |
+
output reg [6:0] seven_segments
|
| 6 |
+
);
|
| 7 |
+
|
| 8 |
+
always @*
|
| 9 |
+
case (digit)
|
| 10 |
+
'h0: seven_segments = 'b1000000; // g f e d c b a
|
| 11 |
+
'h1: seven_segments = 'b1111001;
|
| 12 |
+
'h2: seven_segments = 'b0100100; // --a--
|
| 13 |
+
'h3: seven_segments = 'b0110000; // | |
|
| 14 |
+
'h4: seven_segments = 'b0011001; // f b
|
| 15 |
+
'h5: seven_segments = 'b0010010; // | |
|
| 16 |
+
'h6: seven_segments = 'b0000010; // --g--
|
| 17 |
+
'h7: seven_segments = 'b1111000; // | |
|
| 18 |
+
'h8: seven_segments = 'b0000000; // e c
|
| 19 |
+
'h9: seven_segments = 'b0011000; // | |
|
| 20 |
+
'ha: seven_segments = 'b0001000; // --d--
|
| 21 |
+
'hb: seven_segments = 'b0000011;
|
| 22 |
+
'hc: seven_segments = 'b1000110;
|
| 23 |
+
'hd: seven_segments = 'b0100001;
|
| 24 |
+
'he: seven_segments = 'b0000110;
|
| 25 |
+
'hf: seven_segments = 'b0001110;
|
| 26 |
+
endcase
|
| 27 |
+
|
| 28 |
+
endmodule
|
| 29 |
+
|
| 30 |
+
//--------------------------------------------------------------------
|
| 31 |
+
|
| 32 |
+
module sm_hex_display_8
|
| 33 |
+
(
|
| 34 |
+
input clock,
|
| 35 |
+
input resetn,
|
| 36 |
+
input [31:0] number,
|
| 37 |
+
|
| 38 |
+
output reg [ 6:0] seven_segments,
|
| 39 |
+
output reg dot,
|
| 40 |
+
output reg [ 7:0] anodes
|
| 41 |
+
);
|
| 42 |
+
|
| 43 |
+
function [6:0] bcd_to_seg (input [3:0] bcd);
|
| 44 |
+
|
| 45 |
+
case (bcd)
|
| 46 |
+
'h0: bcd_to_seg = 'b1000000; // g f e d c b a
|
| 47 |
+
'h1: bcd_to_seg = 'b1111001;
|
| 48 |
+
'h2: bcd_to_seg = 'b0100100; // --a--
|
| 49 |
+
'h3: bcd_to_seg = 'b0110000; // | |
|
| 50 |
+
'h4: bcd_to_seg = 'b0011001; // f b
|
| 51 |
+
'h5: bcd_to_seg = 'b0010010; // | |
|
| 52 |
+
'h6: bcd_to_seg = 'b0000010; // --g--
|
| 53 |
+
'h7: bcd_to_seg = 'b1111000; // | |
|
| 54 |
+
'h8: bcd_to_seg = 'b0000000; // e c
|
| 55 |
+
'h9: bcd_to_seg = 'b0011000; // | |
|
| 56 |
+
'ha: bcd_to_seg = 'b0001000; // --d--
|
| 57 |
+
'hb: bcd_to_seg = 'b0000011;
|
| 58 |
+
'hc: bcd_to_seg = 'b1000110;
|
| 59 |
+
'hd: bcd_to_seg = 'b0100001;
|
| 60 |
+
'he: bcd_to_seg = 'b0000110;
|
| 61 |
+
'hf: bcd_to_seg = 'b0001110;
|
| 62 |
+
endcase
|
| 63 |
+
|
| 64 |
+
endfunction
|
| 65 |
+
|
| 66 |
+
reg [2:0] i;
|
| 67 |
+
|
| 68 |
+
always @ (posedge clock or negedge resetn)
|
| 69 |
+
begin
|
| 70 |
+
if (! resetn)
|
| 71 |
+
begin
|
| 72 |
+
seven_segments <= bcd_to_seg (0);
|
| 73 |
+
dot <= ~ 0;
|
| 74 |
+
anodes <= ~ 8'b00000001;
|
| 75 |
+
|
| 76 |
+
i <= 0;
|
| 77 |
+
end
|
| 78 |
+
else
|
| 79 |
+
begin
|
| 80 |
+
seven_segments <= bcd_to_seg (number [i * 4 +: 4]);
|
| 81 |
+
dot <= ~ 0;
|
| 82 |
+
anodes <= ~ (1 << i);
|
| 83 |
+
|
| 84 |
+
i <= i + 1;
|
| 85 |
+
end
|
| 86 |
+
end
|
| 87 |
+
|
| 88 |
+
endmodule
|
MIPSfpga_schoolMIPS/src/sm_register.v
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
module sm_register
|
| 4 |
+
(
|
| 5 |
+
input clk,
|
| 6 |
+
input rst,
|
| 7 |
+
input [ 31 : 0 ] d,
|
| 8 |
+
output reg [ 31 : 0 ] q
|
| 9 |
+
);
|
| 10 |
+
always @ (posedge clk or negedge rst)
|
| 11 |
+
if(~rst)
|
| 12 |
+
q <= 32'b0;
|
| 13 |
+
else
|
| 14 |
+
q <= d;
|
| 15 |
+
endmodule
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
module sm_register_we
|
| 19 |
+
(
|
| 20 |
+
input clk,
|
| 21 |
+
input rst,
|
| 22 |
+
input we,
|
| 23 |
+
input [ 31 : 0 ] d,
|
| 24 |
+
output reg [ 31 : 0 ] q
|
| 25 |
+
);
|
| 26 |
+
always @ (posedge clk or negedge rst)
|
| 27 |
+
if(~rst)
|
| 28 |
+
q <= 32'b0;
|
| 29 |
+
else
|
| 30 |
+
if(we) q <= d;
|
| 31 |
+
endmodule
|
MIPSfpga_schoolMIPS/src/sm_rom.v
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module sm_rom
|
| 3 |
+
#(
|
| 4 |
+
parameter SIZE = 64
|
| 5 |
+
)
|
| 6 |
+
(
|
| 7 |
+
input [31:0] a,
|
| 8 |
+
output [31:0] rd
|
| 9 |
+
);
|
| 10 |
+
reg [31:0] rom [SIZE - 1:0];
|
| 11 |
+
assign rd = rom [a];
|
| 12 |
+
|
| 13 |
+
initial begin
|
| 14 |
+
$readmemh ("program.hex", rom);
|
| 15 |
+
end
|
| 16 |
+
|
| 17 |
+
endmodule
|
MIPSfpga_schoolMIPS/src/sm_top.v
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
//hardware top level module
|
| 3 |
+
module sm_top
|
| 4 |
+
(
|
| 5 |
+
input clkIn,
|
| 6 |
+
input rst_n,
|
| 7 |
+
input [ 3:0 ] clkDevide,
|
| 8 |
+
input clkEnable,
|
| 9 |
+
output clk,
|
| 10 |
+
input [ 4:0 ] regAddr,
|
| 11 |
+
output [31:0 ] regData
|
| 12 |
+
);
|
| 13 |
+
//metastability input filters
|
| 14 |
+
wire [ 3:0 ] devide;
|
| 15 |
+
wire enable;
|
| 16 |
+
wire [ 4:0 ] addr;
|
| 17 |
+
|
| 18 |
+
sm_debouncer #(.SIZE(4)) f0(clkIn, clkDevide, devide);
|
| 19 |
+
sm_debouncer #(.SIZE(1)) f1(clkIn, clkEnable, enable);
|
| 20 |
+
sm_debouncer #(.SIZE(5)) f2(clkIn, regAddr, addr );
|
| 21 |
+
|
| 22 |
+
//cores
|
| 23 |
+
//clock devider
|
| 24 |
+
sm_clk_divider sm_clk_divider
|
| 25 |
+
(
|
| 26 |
+
.clkIn ( clkIn ),
|
| 27 |
+
.rst_n ( rst_n ),
|
| 28 |
+
.devide ( devide ),
|
| 29 |
+
.enable ( enable ),
|
| 30 |
+
.clkOut ( clk )
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
//instruction memory
|
| 34 |
+
wire [31:0] imAddr;
|
| 35 |
+
wire [31:0] imData;
|
| 36 |
+
sm_rom reset_rom(imAddr, imData);
|
| 37 |
+
|
| 38 |
+
sm_cpu sm_cpu
|
| 39 |
+
(
|
| 40 |
+
.clk ( clk ),
|
| 41 |
+
.rst_n ( rst_n ),
|
| 42 |
+
.regAddr ( addr ),
|
| 43 |
+
.regData ( regData ),
|
| 44 |
+
.imAddr ( imAddr ),
|
| 45 |
+
.imData ( imData )
|
| 46 |
+
);
|
| 47 |
+
|
| 48 |
+
endmodule
|
| 49 |
+
|
| 50 |
+
//metastability input debouncer module
|
| 51 |
+
module sm_debouncer
|
| 52 |
+
#(
|
| 53 |
+
parameter SIZE = 1
|
| 54 |
+
)
|
| 55 |
+
(
|
| 56 |
+
input clk,
|
| 57 |
+
input [ SIZE - 1 : 0] d,
|
| 58 |
+
output reg [ SIZE - 1 : 0] q
|
| 59 |
+
);
|
| 60 |
+
reg [ SIZE - 1 : 0] data;
|
| 61 |
+
|
| 62 |
+
always @ (posedge clk) begin
|
| 63 |
+
data <= d;
|
| 64 |
+
q <= data;
|
| 65 |
+
end
|
| 66 |
+
|
| 67 |
+
endmodule
|
| 68 |
+
|
| 69 |
+
//tunable clock devider
|
| 70 |
+
module sm_clk_divider
|
| 71 |
+
#(
|
| 72 |
+
parameter shift = 16,
|
| 73 |
+
bypass = 0
|
| 74 |
+
)
|
| 75 |
+
(
|
| 76 |
+
input clkIn,
|
| 77 |
+
input rst_n,
|
| 78 |
+
input [ 3:0 ] devide,
|
| 79 |
+
input enable,
|
| 80 |
+
output clkOut
|
| 81 |
+
);
|
| 82 |
+
wire [31:0] cntr;
|
| 83 |
+
wire [31:0] cntrNext = cntr + 1;
|
| 84 |
+
sm_register_we r_cntr(clkIn, rst_n, enable, cntrNext, cntr);
|
| 85 |
+
|
| 86 |
+
assign clkOut = bypass ? clkIn
|
| 87 |
+
: cntr[shift + devide];
|
| 88 |
+
endmodule
|
MIPSfpga_schoolMIPS/testbench/testbench.v
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
`timescale 1 ns / 100 ps
|
| 3 |
+
|
| 4 |
+
`include "sm_cpu.vh"
|
| 5 |
+
|
| 6 |
+
`ifndef SIMULATION_CYCLES
|
| 7 |
+
`define SIMULATION_CYCLES 120
|
| 8 |
+
`endif
|
| 9 |
+
|
| 10 |
+
module sm_testbench;
|
| 11 |
+
|
| 12 |
+
// simulation options
|
| 13 |
+
parameter Tt = 20;
|
| 14 |
+
|
| 15 |
+
reg clk;
|
| 16 |
+
reg rst_n;
|
| 17 |
+
reg [ 4:0] regAddr;
|
| 18 |
+
wire [31:0] regData;
|
| 19 |
+
wire cpuClk;
|
| 20 |
+
|
| 21 |
+
// ***** DUT start ************************
|
| 22 |
+
|
| 23 |
+
sm_top sm_top
|
| 24 |
+
(
|
| 25 |
+
.clkIn ( clk ),
|
| 26 |
+
.rst_n ( rst_n ),
|
| 27 |
+
.clkDevide ( 4'b0 ),
|
| 28 |
+
.clkEnable ( 1'b1 ),
|
| 29 |
+
.clk ( cpuClk ),
|
| 30 |
+
.regAddr ( regAddr ),
|
| 31 |
+
.regData ( regData )
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
defparam sm_top.sm_clk_divider.bypass = 1;
|
| 35 |
+
|
| 36 |
+
// ***** DUT end ************************
|
| 37 |
+
|
| 38 |
+
`ifdef ICARUS
|
| 39 |
+
//iverilog memory dump init workaround
|
| 40 |
+
initial $dumpvars;
|
| 41 |
+
genvar k;
|
| 42 |
+
for (k = 0; k < 32; k = k + 1) begin
|
| 43 |
+
initial $dumpvars(0, sm_top.sm_cpu.rf.rf[k]);
|
| 44 |
+
end
|
| 45 |
+
`endif
|
| 46 |
+
|
| 47 |
+
// simulation init
|
| 48 |
+
initial begin
|
| 49 |
+
clk = 0;
|
| 50 |
+
forever clk = #(Tt/2) ~clk;
|
| 51 |
+
end
|
| 52 |
+
|
| 53 |
+
initial begin
|
| 54 |
+
rst_n = 0;
|
| 55 |
+
repeat (4) @(posedge clk);
|
| 56 |
+
rst_n = 1;
|
| 57 |
+
end
|
| 58 |
+
|
| 59 |
+
//register file reset
|
| 60 |
+
integer i;
|
| 61 |
+
initial begin
|
| 62 |
+
for (i = 0; i < 32; i = i + 1)
|
| 63 |
+
sm_top.sm_cpu.rf.rf[i] = 0;
|
| 64 |
+
end
|
| 65 |
+
|
| 66 |
+
task disasmInstr
|
| 67 |
+
(
|
| 68 |
+
input [31:0] instr
|
| 69 |
+
);
|
| 70 |
+
reg [ 5:0] cmdOper;
|
| 71 |
+
reg [ 5:0] cmdFunk;
|
| 72 |
+
reg [ 4:0] cmdRs;
|
| 73 |
+
reg [ 4:0] cmdRt;
|
| 74 |
+
reg [ 4:0] cmdRd;
|
| 75 |
+
reg [ 4:0] cmdSa;
|
| 76 |
+
reg [15:0] cmdImm;
|
| 77 |
+
reg signed [15:0] cmdImmS;
|
| 78 |
+
|
| 79 |
+
begin
|
| 80 |
+
cmdOper = instr[31:26];
|
| 81 |
+
cmdFunk = instr[ 5:0 ];
|
| 82 |
+
cmdRs = instr[25:21];
|
| 83 |
+
cmdRt = instr[20:16];
|
| 84 |
+
cmdRd = instr[15:11];
|
| 85 |
+
cmdSa = instr[10:6 ];
|
| 86 |
+
cmdImm = instr[15:0 ];
|
| 87 |
+
cmdImmS = instr[15:0 ];
|
| 88 |
+
|
| 89 |
+
$write(" ");
|
| 90 |
+
|
| 91 |
+
casez( {cmdOper,cmdFunk} )
|
| 92 |
+
default : if (instr == 32'b0)
|
| 93 |
+
$write ("nop");
|
| 94 |
+
else
|
| 95 |
+
$write ("new/unknown");
|
| 96 |
+
|
| 97 |
+
{ `C_SPEC, `F_ADDU } : $write ("addu $%1d, $%1d, $%1d", cmdRd, cmdRs, cmdRt);
|
| 98 |
+
{ `C_SPEC, `F_OR } : $write ("or $%1d, $%1d, $%1d", cmdRd, cmdRs, cmdRt);
|
| 99 |
+
{ `C_SPEC, `F_SRL } : $write ("srl $%1d, $%1d, $%1d", cmdRd, cmdRs, cmdRt);
|
| 100 |
+
{ `C_SPEC, `F_SLTU } : $write ("sltu $%1d, $%1d, $%1d", cmdRd, cmdRs, cmdRt);
|
| 101 |
+
{ `C_SPEC, `F_SUBU } : $write ("subu $%1d, $%1d, $%1d", cmdRd, cmdRs, cmdRt);
|
| 102 |
+
|
| 103 |
+
{ `C_ADDIU, `F_ANY } : $write ("addiu $%1d, $%1d, %1d", cmdRt, cmdRs, cmdImm);
|
| 104 |
+
{ `C_LUI, `F_ANY } : $write ("lui $%1d, %1d", cmdRt, cmdImm);
|
| 105 |
+
|
| 106 |
+
{ `C_BEQ, `F_ANY } : $write ("beq $%1d, $%1d, %1d", cmdRs, cmdRt, cmdImmS + 1);
|
| 107 |
+
{ `C_BNE, `F_ANY } : $write ("bne $%1d, $%1d, %1d", cmdRs, cmdRt, cmdImmS + 1);
|
| 108 |
+
endcase
|
| 109 |
+
end
|
| 110 |
+
|
| 111 |
+
endtask
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
//simulation debug output
|
| 115 |
+
integer cycle; initial cycle = 0;
|
| 116 |
+
|
| 117 |
+
initial regAddr = 0; // get PC
|
| 118 |
+
|
| 119 |
+
always @ (posedge clk)
|
| 120 |
+
begin
|
| 121 |
+
$write ("%5d pc = %2d pcaddr = %h instr = %h v0 = %1d",
|
| 122 |
+
cycle, regData, (regData << 2), sm_top.sm_cpu.instr, sm_top.sm_cpu.rf.rf[2]);
|
| 123 |
+
|
| 124 |
+
disasmInstr(sm_top.sm_cpu.instr);
|
| 125 |
+
|
| 126 |
+
$write("\n");
|
| 127 |
+
|
| 128 |
+
cycle = cycle + 1;
|
| 129 |
+
|
| 130 |
+
if (cycle > `SIMULATION_CYCLES)
|
| 131 |
+
begin
|
| 132 |
+
$display ("Timeout");
|
| 133 |
+
$stop;
|
| 134 |
+
end
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
endmodule
|
ShawnHymel_introduction-to-fpga/02-install-apio/solution-turn-off-led/leds.v
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//------------------------------------------------------------------
|
| 2 |
+
//-- Hello world example for the iCEstick board
|
| 3 |
+
//-- Turn on all the leds
|
| 4 |
+
//------------------------------------------------------------------
|
| 5 |
+
|
| 6 |
+
module leds(output wire D1,
|
| 7 |
+
output wire D2,
|
| 8 |
+
output wire D3,
|
| 9 |
+
output wire D4,
|
| 10 |
+
output wire D5);
|
| 11 |
+
|
| 12 |
+
assign D1 = 1'b1;
|
| 13 |
+
assign D2 = 1'b1;
|
| 14 |
+
assign D3 = 1'b1;
|
| 15 |
+
assign D4 = 1'b1;
|
| 16 |
+
assign D5 = 1'b0;
|
| 17 |
+
|
| 18 |
+
endmodule
|
ShawnHymel_introduction-to-fpga/02-install-apio/solution-turn-off-led/leds_tb.v
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//-------------------------------------------------------------------
|
| 2 |
+
//-- leds_tb.v
|
| 3 |
+
//-- Testbench
|
| 4 |
+
//-------------------------------------------------------------------
|
| 5 |
+
//-- Juan Gonzalez (Obijuan)
|
| 6 |
+
//-- Jesus Arroyo Torrens
|
| 7 |
+
//-- GPL license
|
| 8 |
+
//-------------------------------------------------------------------
|
| 9 |
+
`default_nettype none
|
| 10 |
+
`define DUMPSTR(x) `"x.vcd`"
|
| 11 |
+
`timescale 100 ns / 10 ns
|
| 12 |
+
|
| 13 |
+
module leds_tb();
|
| 14 |
+
|
| 15 |
+
//-- Simulation time: 1us (10 * 100ns)
|
| 16 |
+
parameter DURATION = 10;
|
| 17 |
+
|
| 18 |
+
//-- Clock signal. It is not used in this simulation
|
| 19 |
+
reg clk = 0;
|
| 20 |
+
always #0.5 clk = ~clk;
|
| 21 |
+
|
| 22 |
+
//-- Leds port
|
| 23 |
+
wire d1, d2, d3, d4, d5;
|
| 24 |
+
|
| 25 |
+
//-- Instantiate the unit to test
|
| 26 |
+
leds UUT (
|
| 27 |
+
.D1(d1),
|
| 28 |
+
.D2(d2),
|
| 29 |
+
.D3(d3),
|
| 30 |
+
.D4(d4),
|
| 31 |
+
.D5(d5)
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
initial begin
|
| 36 |
+
|
| 37 |
+
//-- File were to store the simulation results
|
| 38 |
+
$dumpfile(`DUMPSTR(`VCD_OUTPUT));
|
| 39 |
+
$dumpvars(0, leds_tb);
|
| 40 |
+
|
| 41 |
+
#(DURATION) $display("End of simulation");
|
| 42 |
+
$finish;
|
| 43 |
+
end
|
| 44 |
+
|
| 45 |
+
endmodule
|
ShawnHymel_introduction-to-fpga/03-verilog-gate-logic/example-01-and-gate/and_gate.v
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AND gate example
|
| 2 |
+
//
|
| 3 |
+
// Inputs:
|
| 4 |
+
// pmod_0 - pushbutton
|
| 5 |
+
// pmod_1 - pushbutton
|
| 6 |
+
// Outputs:
|
| 7 |
+
// led_0 - LED
|
| 8 |
+
//
|
| 9 |
+
// LED will turn on if both pushbuttons are pressed (~pmod_0 & ~pmod_1).
|
| 10 |
+
//
|
| 11 |
+
// Date: October 13, 2021
|
| 12 |
+
// Author: Shawn Hymel
|
| 13 |
+
// License: 0BSD
|
| 14 |
+
|
| 15 |
+
// Module: when buttons 1 and 2 are pressed, turn on LED
|
| 16 |
+
module and_gate (
|
| 17 |
+
|
| 18 |
+
// Inputs
|
| 19 |
+
input pmod_0,
|
| 20 |
+
input pmod_1,
|
| 21 |
+
|
| 22 |
+
// Outputs
|
| 23 |
+
output led_0
|
| 24 |
+
);
|
| 25 |
+
|
| 26 |
+
// Continuous assignment: NOT and AND operators
|
| 27 |
+
assign led_0 = ~pmod_0 & ~pmod_1;
|
| 28 |
+
|
| 29 |
+
endmodule
|
ShawnHymel_introduction-to-fpga/03-verilog-gate-logic/example-02-vectors/vectors.v
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Vector and intermediate (wire) value example
|
| 2 |
+
//
|
| 3 |
+
// Inputs:
|
| 4 |
+
// pmod[1:0] - pushbuttons (x2)
|
| 5 |
+
//
|
| 6 |
+
// Outputs:
|
| 7 |
+
// led[2:0] - LEDs (x3)
|
| 8 |
+
//
|
| 9 |
+
// LEDs 0 and 1 turn on if pmod[0] button is pressed. LED 2 turns on if pmod[0]
|
| 10 |
+
// and pmod[1] are pressed together.
|
| 11 |
+
//
|
| 12 |
+
// Date: October 13, 2021
|
| 13 |
+
// Author: Shawn Hymel
|
| 14 |
+
// License: 0BSD
|
| 15 |
+
|
| 16 |
+
// Module: button 0 lights up 2 LEDs, button 0 and 1 light up another LED
|
| 17 |
+
module and_gate (
|
| 18 |
+
|
| 19 |
+
// Inputs
|
| 20 |
+
input [1:0] pmod,
|
| 21 |
+
|
| 22 |
+
// Output
|
| 23 |
+
output [2:0] led
|
| 24 |
+
);
|
| 25 |
+
|
| 26 |
+
// Wire (net) declarations (internal to module)
|
| 27 |
+
wire not_pmod_0;
|
| 28 |
+
|
| 29 |
+
// Continuous assignment: replicate 1 wire to 2 outputs
|
| 30 |
+
assign not_pmod_0 = ~pmod[0];
|
| 31 |
+
assign led[1:0] = {2{not_pmod_0}};
|
| 32 |
+
|
| 33 |
+
// Continuous assignment: NOT and AND operators
|
| 34 |
+
assign led[2] = not_pmod_0 & ~pmod[1];
|
| 35 |
+
|
| 36 |
+
endmodule
|