Skip to content

Commit 0ef3017

Browse files
authored
Merge pull request #11 from LSC-Unicamp/reestruturando_projeto
Reestruturando projeto
2 parents 3edd873 + 26cea03 commit 0ef3017

35 files changed

+2337
-1662
lines changed

.github/workflows/clk_divider.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: ClkDivider Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout do código
11+
uses: actions/checkout@v4
12+
13+
- name: Instalar Icarus Verilog (iverilog)
14+
run: sudo apt update && sudo apt install -y iverilog
15+
16+
- name: Criar diretório de build
17+
run: mkdir -p build
18+
19+
- name: Compilar o testbench
20+
run: iverilog -o build/ClkDivider_tb -s ClkDivider_tb -g2005-sv -Irtl/core testbenchs/clk_divider_tb.sv rtl/clk_divider.sv
21+
22+
- name: Executar o testbench
23+
run: vvp build/ClkDivider_tb
24+
25+
- name: Salvar VCD como artefato
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: fifo_waveform
29+
path: build/ClkDivider_tb.vcd

.github/workflows/fifo.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: FIFO Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout do código
11+
uses: actions/checkout@v4
12+
13+
- name: Instalar Icarus Verilog (iverilog)
14+
run: sudo apt update && sudo apt install -y iverilog
15+
16+
- name: Criar diretório de build
17+
run: mkdir -p build
18+
19+
- name: Compilar o testbench
20+
run: iverilog -o build/fifo_tb -s fifo_tb -g2005-sv -Irtl/core testbenchs/fifo_tb.sv rtl/fifo.sv
21+
22+
- name: Executar o testbench
23+
run: vvp build/fifo_tb
24+
25+
- name: Salvar VCD como artefato
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: fifo_waveform
29+
path: build/fifo_tb.vcd

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ webtalk*.log
1919
webtalk*.jou
2020
fpga/digilent_arty/usage_statistics_webtalk.xml
2121
fpga/digilent_arty/usage_statistics_webtalk.html
22+
fpga/nexys4_ddr/clockInfo.txt
23+
fpga/nexys4_ddr/usage_statistics_webtalk.html
24+
fpga/nexys4_ddr/usage_statistics_webtalk.xml

.gitmodules

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@
33
url = https://github.com/Unicamp-Odhin/SPI-Slave
44
[submodule "modules/UART"]
55
path = modules/UART
6-
url = https://github.com/ben-marshall/uart
7-
[submodule "modules/Risco-5"]
8-
path = modules/Risco-5
9-
url = https://github.com/JN513/Risco-5
6+
url = https://github.com/ben-marshall/uart

Risco-5

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/Grande-Risco-5.sv

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
module top (
2+
input logic clk,
3+
input logic CPU_RESETN,
4+
5+
input logic rx,
6+
output logic tx,
7+
8+
input logic mosi,
9+
output logic miso,
10+
input logic sck,
11+
input logic cs
12+
);
13+
14+
logic clk_o;
15+
logic clk_core, rst_core;
16+
17+
// Fios do barramento entre Controller e Processor
18+
logic core_cyc;
19+
logic core_stb;
20+
logic core_we;
21+
logic [31:0] core_addr;
22+
logic [31:0] core_data_out;
23+
logic [31:0] core_data_in;
24+
logic core_ack;
25+
26+
Controller #(
27+
.CLK_FREQ (50000000),
28+
.BIT_RATE (BIT_RATE),
29+
.PAYLOAD_BITS (8),
30+
.BUFFER_SIZE (8),
31+
.PULSE_CONTROL_BITS (32),
32+
.BUS_WIDTH (32),
33+
.WORD_SIZE_BY (4),
34+
.ID (32'h7700006A),
35+
.RESET_CLK_CYCLES (20),
36+
.MEMORY_FILE (""),
37+
.MEMORY_SIZE (4096)
38+
) u_Controller (
39+
.clk (clk),
40+
.rst_n (CPU_RESETN),
41+
42+
// SPI signals
43+
.sck_i (sck),
44+
.cs_i (cs),
45+
.mosi_i (mosi),
46+
.miso_o (miso),
47+
48+
// SPI callback signals
49+
.rw_i (),
50+
.intr_o (),
51+
52+
// UART signals
53+
.rx (rx),
54+
.tx (tx),
55+
56+
// Clock, reset, and bus signals
57+
.clk_core_o (clk_core),
58+
.rst_core_o (rst_core),
59+
60+
// Barramento padrão (não AXI4-Lite)
61+
.core_cyc_i (core_cyc),
62+
.core_stb_i (core_stb),
63+
.core_we_i (core_we),
64+
.core_addr_i (core_addr),
65+
.core_data_i (core_data_out),
66+
.core_data_o (core_data_in),
67+
.core_ack_o (core_ack)
68+
);
69+
70+
Grande_Risco5 #(
71+
.BOOT_ADDRESS (32'h00000000),
72+
.I_CACHE_SIZE (256),
73+
.D_CACHE_SIZE (256),
74+
.DATA_WIDTH (32),
75+
.ADDR_WIDTH (32),
76+
.BRANCH_PREDICTION_SIZE (128)
77+
) Processor (
78+
.clk (clk_core),
79+
.rst_n (~rst_core),
80+
.halt (1'b0),
81+
82+
.cyc_o (core_cyc),
83+
.stb_o (core_stb),
84+
.we_o (core_we),
85+
86+
.addr_o (core_addr),
87+
.data_o (core_data_out),
88+
89+
.ack_i (core_ack),
90+
.data_i (core_data_in),
91+
92+
.interruption (1'b0)
93+
);
94+
95+
always_ff @(posedge clk) begin : CLOCK_DIVIDER
96+
if (!CPU_RESETN) begin
97+
clk_o <= 1'b0;
98+
end else begin
99+
clk_o <= ~clk_o;
100+
end
101+
end
102+
103+
endmodule

fpga/nexys4_ddr/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ digilent_arty.hw/
33
digilent_arty.ip_user_files/
44
.Xil/
55
report/
6-
vivado_*.backup.*
6+
vivado_*.backup.*
7+
reports

fpga/nexys4_ddr/Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1+
ifndef VIVADO_PATH
2+
VIVADO=vivado
3+
else
4+
VIVADO=$(VIVADO_PATH)/vivado
5+
endif
6+
17
all: ./build/out.bit
28

39
./build/out.bit: buildFolder
4-
vivado -mode batch -nolog -nojournal -source run.tcl
10+
$(VIVADO) -mode batch -nolog -nojournal -source run.tcl
511
buildFolder:
612
mkdir -p build
13+
mkdir -p reports
714

815
clean:
916
rm -rf build
10-
rm clockInfo.txt
17+
rm -rf clockInfo.txt
18+
rm -rf .Xil
19+
rm -rf reports
1120

12-
flash:
21+
load:
1322
openFPGALoader -b nexys_a7_100 ./build/out.bit
1423

15-
run_all: ./build/out.bit flash
24+
flash:
25+
openFPGALoader -b nexys_a7_100 -f ./build/out.bit
26+
27+
run_all: ./build/out.bit load

fpga/nexys4_ddr/main.sv

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
module top (
2+
input logic clk,
3+
input logic CPU_RESETN,
4+
5+
input logic rx,
6+
output logic tx,
7+
8+
output logic [15:0]LED,
9+
10+
input logic mosi,
11+
output logic miso,
12+
input logic sck,
13+
input logic cs,
14+
15+
input logic [15:0] SW,
16+
17+
output logic [3:0] VGA_R,
18+
output logic [3:0] VGA_G,
19+
output logic [3:0] VGA_B,
20+
output logic VGA_HS,
21+
output logic VGA_VS,
22+
23+
output logic M_CLK, // Clock do microfone
24+
output logic M_LRSEL, // Left/Right Select (Escolha do canal)
25+
26+
input logic M_DATA // Dados do microfone
27+
);
28+
29+
30+
logic clk_o;
31+
32+
logic clk_core, rst_core;
33+
34+
35+
Controller #(
36+
.CLK_FREQ (50000000),
37+
.BIT_RATE (115200),
38+
.PAYLOAD_BITS (8),
39+
.BUFFER_SIZE (8),
40+
.PULSE_CONTROL_BITS (32),
41+
.BUS_WIDTH (32),
42+
.WORD_SIZE_BY (4),
43+
.ID (32'h7700006A),
44+
.RESET_CLK_CYCLES (20),
45+
.MEMORY_FILE (""),
46+
.MEMORY_SIZE (4096)
47+
) u_Controller (
48+
.clk (clk_o),
49+
.rst_n (CPU_RESETN),
50+
51+
// SPI signals
52+
.sck_i (sck),
53+
.cs_i (cs),
54+
.mosi_i (mosi),
55+
.miso_o (miso),
56+
57+
// SPI callback signals
58+
.rw_i (),
59+
.intr_o (),
60+
61+
// UART signals
62+
.rx (rx),
63+
.tx (tx),
64+
65+
// Clock, reset, and bus signals
66+
.clk_core_o (clk_core),
67+
.rst_core_o (rst_core),
68+
69+
// Barramento padrão (não AXI4-Lite)
70+
.core_cyc_i (),
71+
.core_stb_i (),
72+
.core_we_i (),
73+
.core_addr_i (),
74+
.core_data_i (),
75+
.core_data_o (),
76+
.core_ack_o ()
77+
78+
`ifdef ENABLE_SECOND_MEMORY
79+
,
80+
// Segunda memória - memória de dados
81+
.data_mem_cyc_i (data_mem_cyc_i),
82+
.data_mem_stb_i (data_mem_stb_i),
83+
.data_mem_we_i (data_mem_we_i),
84+
.data_mem_addr_i (data_mem_addr_i),
85+
.data_mem_data_i (data_mem_data_i),
86+
.data_mem_data_o (data_mem_data_o),
87+
.data_mem_ack_o (data_mem_ack_o)
88+
`endif
89+
);
90+
91+
92+
always_ff @(posedge clk) begin
93+
if(!CPU_RESETN)
94+
clk_o <= 1'b0;
95+
else
96+
clk_o <= ~clk_o;
97+
end
98+
99+
endmodule

fpga/nexys4_ddr/main.v

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)